@@ -58,6 +58,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithIL(
5858 *Program // /< [out] pointer to handle of program object created.
5959) {
6060 std::ignore = Properties;
61+ UR_ASSERT (Context, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
62+ UR_ASSERT (IL && Program, UR_RESULT_ERROR_INVALID_NULL_POINTER);
6163 try {
6264 ur_program_handle_t_ *UrProgram =
6365 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(
658660 // device. Since Level Zero supports only one device, there is only one
659661 // pointer. If the pointer is NULL, we don't do anything. Otherwise, we
660662 // copy the program's binary image to the buffer at that pointer.
663+ uint8_t **PBinary = nullptr ;
661664 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 ]) {
664667 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) {
670677 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;
677678 }
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;
678691 }
679692 break ;
680693 }
@@ -723,7 +736,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetInfo(
723736 return UR_RESULT_ERROR_UNKNOWN;
724737 }
725738 case UR_PROGRAM_INFO_SOURCE:
726- return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION ;
739+ return ReturnValue (Program-> Code . get ()) ;
727740 default :
728741 return UR_RESULT_ERROR_INVALID_ENUMERATION;
729742 }
@@ -765,6 +778,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetBuildInfo(
765778 // return for programs that were built outside and registered
766779 // with urProgramRegister?
767780 return ReturnValue (" " );
781+ } else if (PropName == UR_PROGRAM_BUILD_INFO_STATUS) {
782+ return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
768783 } else if (PropName == UR_PROGRAM_BUILD_INFO_LOG) {
769784 // Check first to see if the plugin code recorded an error message.
770785 if (!Program->ErrorMessage .empty ()) {
@@ -856,6 +871,8 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithNativeHandle(
856871 // /< program object created.
857872) {
858873 std::ignore = Properties;
874+ UR_ASSERT (Context && NativeProgram, UR_RESULT_ERROR_INVALID_NULL_HANDLE);
875+ UR_ASSERT (Program, UR_RESULT_ERROR_INVALID_NULL_POINTER);
859876 auto ZeModule = ur_cast<ze_module_handle_t >(NativeProgram);
860877
861878 // We assume here that programs created from a native handle always
0 commit comments