Skip to content

[UR][Offload] Implement a number of urProgram* entry points/infos #19307

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: sycl
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 29 additions & 1 deletion unified-runtime/source/adapters/offload/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
phProgram);
}

ur_program_handle_t Program = new ur_program_handle_t_();
ur_program_handle_t Program = new ur_program_handle_t_{};
Program->URContext = hContext;
Program->Binary = RealBinary;
Program->BinarySizeInBytes = RealLength;
auto Res = olCreateProgram(hContext->Device->OffloadDevice, RealBinary,
RealLength, &Program->OffloadProgram);

Expand Down Expand Up @@ -137,6 +140,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t,
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL urProgramCompile(ur_context_handle_t,
ur_program_handle_t,
const char *) {
// Do nothing, program is built upon creation
return UR_RESULT_SUCCESS;
}

UR_APIEXPORT ur_result_t UR_APICALL
urProgramCreateWithIL(ur_context_handle_t, const void *, size_t,
const ur_program_properties_t *, ur_program_handle_t *) {
return UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE;
}

UR_APIEXPORT ur_result_t UR_APICALL
urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
size_t propSize, void *pPropValue, size_t *pPropSizeRet) {
Expand All @@ -145,6 +161,18 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
switch (propName) {
case UR_PROGRAM_INFO_REFERENCE_COUNT:
return ReturnValue(hProgram->RefCount.load());
case UR_PROGRAM_INFO_CONTEXT:
return ReturnValue(hProgram->URContext);
case UR_PROGRAM_INFO_NUM_DEVICES:
return ReturnValue(1);
case UR_PROGRAM_INFO_DEVICES:
return ReturnValue(&hProgram->URContext->Device, 1);
case UR_PROGRAM_INFO_IL:
return ReturnValue(reinterpret_cast<const char *>(0), 0);
case UR_PROGRAM_INFO_BINARY_SIZES:
return ReturnValue(&hProgram->BinarySizeInBytes, 1);
case UR_PROGRAM_INFO_BINARIES:
return ReturnValue(&hProgram->Binary, 1);
default:
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
}
Expand Down
3 changes: 3 additions & 0 deletions unified-runtime/source/adapters/offload/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@

struct ur_program_handle_t_ : RefCounted {
ol_program_handle_t OffloadProgram;
ur_context_handle_t URContext;
const uint8_t *Binary;
size_t BinarySizeInBytes;
};
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable(
return result;
}
pDdiTable->pfnBuild = urProgramBuild;
pDdiTable->pfnCompile = nullptr;
pDdiTable->pfnCompile = urProgramCompile;
pDdiTable->pfnCreateWithBinary = urProgramCreateWithBinary;
pDdiTable->pfnCreateWithIL = nullptr;
pDdiTable->pfnCreateWithIL = urProgramCreateWithIL;
pDdiTable->pfnCreateWithNativeHandle = urProgramCreateWithNativeHandle;
pDdiTable->pfnGetBuildInfo = nullptr;
pDdiTable->pfnGetFunctionPointer = nullptr;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ inline std::ostream &operator<<(std::ostream &out, const Result &result) {
do { \
auto status = ret; \
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE || \
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { \
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION || \
status == UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE) { \
GTEST_SKIP(); \
} else { \
ASSERT_EQ(status, UR_RESULT_SUCCESS); \
Expand Down