Skip to content

Commit 911fa71

Browse files
committed
Implement INFO_BINARIES properly
1 parent 45bd2b0 commit 911fa71

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

unified-runtime/source/adapters/offload/program.cpp

Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,25 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
171171
return ReturnValue(reinterpret_cast<const char *>(0), 0);
172172
case UR_PROGRAM_INFO_BINARY_SIZES:
173173
return ReturnValue(&hProgram->BinarySizeInBytes, 1);
174-
case UR_PROGRAM_INFO_BINARIES:
175-
return ReturnValue(&hProgram->Binary, 1);
174+
case UR_PROGRAM_INFO_BINARIES: {
175+
if (!pPropValue && !pPropSizeRet) {
176+
return UR_RESULT_ERROR_INVALID_NULL_POINTER;
177+
}
178+
179+
if (pPropValue != nullptr) {
180+
if (propSize < sizeof(void *)) {
181+
return UR_RESULT_ERROR_INVALID_SIZE;
182+
}
183+
184+
std::memcpy(*reinterpret_cast<void **>(pPropValue), hProgram->Binary,
185+
hProgram->BinarySizeInBytes);
186+
}
187+
188+
if (pPropSizeRet != nullptr) {
189+
*pPropSizeRet = sizeof(void *);
190+
}
191+
break;
192+
}
176193
default:
177194
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
178195
}

0 commit comments

Comments
 (0)