@@ -58,6 +58,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL(
58
58
*Program // /< [out] pointer to handle of program object created.
59
59
) {
60
60
std::ignore = Properties;
61
+ UR_ASSERT (Context, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
62
+ UR_ASSERT (IL && Program, UR_RESULT_ERROR_INVALID_NULL_POINTER);
61
63
try {
62
64
ur_program_handle_t_ *UrProgram =
63
65
new ur_program_handle_t_ (ur_program_handle_t_::IL, Context, IL, Length);
@@ -658,23 +660,34 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetInfo(
658
660
// device. Since Level Zero supports only one device, there is only one
659
661
// pointer. If the pointer is NULL, we don't do anything. Otherwise, we
660
662
// copy the program's binary image to the buffer at that pointer.
663
+ uint8_t **PBinary = nullptr ;
661
664
if (ProgramInfo) {
662
- uint8_t ** PBinary = ur_cast<uint8_t **>(ProgramInfo);
663
- if (!PBinary[0 ])
665
+ PBinary = ur_cast<uint8_t **>(ProgramInfo);
666
+ if (!PBinary[0 ]) {
664
667
break ;
665
-
666
- std::shared_lock<ur_shared_mutex> Guard (Program->Mutex );
667
- if (Program->State == ur_program_handle_t_::IL ||
668
- Program->State == ur_program_handle_t_::Native ||
669
- Program->State == ur_program_handle_t_::Object) {
668
+ }
669
+ }
670
+ std::shared_lock<ur_shared_mutex> Guard (Program->Mutex );
671
+ if (Program->State == ur_program_handle_t_::IL ||
672
+ Program->State == ur_program_handle_t_::Native ||
673
+ Program->State == ur_program_handle_t_::Object) {
674
+ if (PropSizeRet)
675
+ *PropSizeRet = Program->CodeLength ;
676
+ if (PBinary) {
670
677
std::memcpy (PBinary[0 ], Program->Code .get (), Program->CodeLength );
671
- } else if (Program->State == ur_program_handle_t_::Exe) {
672
- size_t SzBinary = 0 ;
673
- ZE2UR_CALL (zeModuleGetNativeBinary,
674
- (Program->ZeModule , &SzBinary, PBinary[0 ]));
675
- } else {
676
- return UR_RESULT_ERROR_INVALID_PROGRAM;
677
678
}
679
+ } else if (Program->State == ur_program_handle_t_::Exe) {
680
+ size_t SzBinary = 0 ;
681
+ uint8_t *NativeBinaryPtr = nullptr ;
682
+ if (PBinary) {
683
+ NativeBinaryPtr = PBinary[0 ];
684
+ }
685
+ ZE2UR_CALL (zeModuleGetNativeBinary,
686
+ (Program->ZeModule , &SzBinary, NativeBinaryPtr));
687
+ if (PropSizeRet)
688
+ *PropSizeRet = SzBinary;
689
+ } else {
690
+ return UR_RESULT_ERROR_INVALID_PROGRAM;
678
691
}
679
692
break ;
680
693
}
@@ -723,7 +736,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetInfo(
723
736
return UR_RESULT_ERROR_UNKNOWN;
724
737
}
725
738
case UR_PROGRAM_INFO_SOURCE:
726
- return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION ;
739
+ return ReturnValue (Program-> Code . get ()) ;
727
740
default :
728
741
return UR_RESULT_ERROR_INVALID_ENUMERATION;
729
742
}
@@ -765,6 +778,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetBuildInfo(
765
778
// return for programs that were built outside and registered
766
779
// with urProgramRegister?
767
780
return ReturnValue (" " );
781
+ } else if (PropName == UR_PROGRAM_BUILD_INFO_STATUS) {
782
+ return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
768
783
} else if (PropName == UR_PROGRAM_BUILD_INFO_LOG) {
769
784
// Check first to see if the plugin code recorded an error message.
770
785
if (!Program->ErrorMessage .empty ()) {
@@ -856,6 +871,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithNativeHandle(
856
871
// /< program object created.
857
872
) {
858
873
std::ignore = Properties;
874
+ UR_ASSERT (Context && NativeProgram, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
875
+ UR_ASSERT (Program, UR_RESULT_ERROR_INVALID_NULL_POINTER);
859
876
auto ZeModule = ur_cast<ze_module_handle_t >(NativeProgram);
860
877
861
878
// We assume here that programs created from a native handle always
0 commit comments