Skip to content

Commit 64ad451

Browse files
nrspruitomarahmed1111
authored andcommitted
[L0] Fix program get info
Signed-off-by: Neil R. Spruit <neil.r.spruit@intel.com>
1 parent 27135eb commit 64ad451

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

source/adapters/level_zero/program.cpp

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -658,21 +658,23 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetInfo(
658658
// device. Since Level Zero supports only one device, there is only one
659659
// pointer. If the pointer is NULL, we don't do anything. Otherwise, we
660660
// copy the program's binary image to the buffer at that pointer.
661-
uint8_t **PBinary = ur_cast<uint8_t **>(ProgramInfo);
662-
if (!PBinary[0])
663-
break;
661+
if (ProgramInfo) {
662+
uint8_t **PBinary = ur_cast<uint8_t **>(ProgramInfo);
663+
if (!PBinary[0])
664+
break;
664665

665-
std::shared_lock<ur_shared_mutex> Guard(Program->Mutex);
666-
if (Program->State == ur_program_handle_t_::IL ||
667-
Program->State == ur_program_handle_t_::Native ||
668-
Program->State == ur_program_handle_t_::Object) {
669-
std::memcpy(PBinary[0], Program->Code.get(), Program->CodeLength);
670-
} else if (Program->State == ur_program_handle_t_::Exe) {
671-
size_t SzBinary = 0;
672-
ZE2UR_CALL(zeModuleGetNativeBinary,
673-
(Program->ZeModule, &SzBinary, PBinary[0]));
674-
} else {
675-
return UR_RESULT_ERROR_INVALID_PROGRAM;
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) {
670+
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+
}
676678
}
677679
break;
678680
}
@@ -720,8 +722,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramGetInfo(
720722
} catch (...) {
721723
return UR_RESULT_ERROR_UNKNOWN;
722724
}
725+
case UR_PROGRAM_INFO_SOURCE:
726+
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
723727
default:
724-
die("urProgramGetInfo: not implemented");
728+
return UR_RESULT_ERROR_INVALID_ENUMERATION;
725729
}
726730

727731
return UR_RESULT_SUCCESS;

0 commit comments

Comments
 (0)