Skip to content

Commit 45bd2b0

Browse files
committed
[UR][Offload] Implement a number of urProgram* entry points/infos
Mostly just trivial implementations to improve the pass rate.
1 parent cf8dab2 commit 45bd2b0

File tree

4 files changed

+36
-4
lines changed

4 files changed

+36
-4
lines changed

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,10 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
108108
phProgram);
109109
}
110110

111-
ur_program_handle_t Program = new ur_program_handle_t_();
111+
ur_program_handle_t Program = new ur_program_handle_t_{};
112+
Program->URContext = hContext;
113+
Program->Binary = RealBinary;
114+
Program->BinarySizeInBytes = RealLength;
112115
auto Res = olCreateProgram(hContext->Device->OffloadDevice, RealBinary,
113116
RealLength, &Program->OffloadProgram);
114117

@@ -137,6 +140,19 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuildExp(ur_program_handle_t,
137140
return UR_RESULT_SUCCESS;
138141
}
139142

143+
UR_APIEXPORT ur_result_t UR_APICALL urProgramCompile(ur_context_handle_t,
144+
ur_program_handle_t,
145+
const char *) {
146+
// Do nothing, program is built upon creation
147+
return UR_RESULT_SUCCESS;
148+
}
149+
150+
UR_APIEXPORT ur_result_t UR_APICALL
151+
urProgramCreateWithIL(ur_context_handle_t, const void *, size_t,
152+
const ur_program_properties_t *, ur_program_handle_t *) {
153+
return UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE;
154+
}
155+
140156
UR_APIEXPORT ur_result_t UR_APICALL
141157
urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
142158
size_t propSize, void *pPropValue, size_t *pPropSizeRet) {
@@ -145,6 +161,18 @@ urProgramGetInfo(ur_program_handle_t hProgram, ur_program_info_t propName,
145161
switch (propName) {
146162
case UR_PROGRAM_INFO_REFERENCE_COUNT:
147163
return ReturnValue(hProgram->RefCount.load());
164+
case UR_PROGRAM_INFO_CONTEXT:
165+
return ReturnValue(hProgram->URContext);
166+
case UR_PROGRAM_INFO_NUM_DEVICES:
167+
return ReturnValue(1);
168+
case UR_PROGRAM_INFO_DEVICES:
169+
return ReturnValue(&hProgram->URContext->Device, 1);
170+
case UR_PROGRAM_INFO_IL:
171+
return ReturnValue(reinterpret_cast<const char *>(0), 0);
172+
case UR_PROGRAM_INFO_BINARY_SIZES:
173+
return ReturnValue(&hProgram->BinarySizeInBytes, 1);
174+
case UR_PROGRAM_INFO_BINARIES:
175+
return ReturnValue(&hProgram->Binary, 1);
148176
default:
149177
return UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION;
150178
}

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,7 @@
1717

1818
struct ur_program_handle_t_ : RefCounted {
1919
ol_program_handle_t OffloadProgram;
20+
ur_context_handle_t URContext;
21+
const uint8_t *Binary;
22+
size_t BinarySizeInBytes;
2023
};

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,9 @@ UR_DLLEXPORT ur_result_t UR_APICALL urGetProgramProcAddrTable(
8686
return result;
8787
}
8888
pDdiTable->pfnBuild = urProgramBuild;
89-
pDdiTable->pfnCompile = nullptr;
89+
pDdiTable->pfnCompile = urProgramCompile;
9090
pDdiTable->pfnCreateWithBinary = urProgramCreateWithBinary;
91-
pDdiTable->pfnCreateWithIL = nullptr;
91+
pDdiTable->pfnCreateWithIL = urProgramCreateWithIL;
9292
pDdiTable->pfnCreateWithNativeHandle = urProgramCreateWithNativeHandle;
9393
pDdiTable->pfnGetBuildInfo = nullptr;
9494
pDdiTable->pfnGetFunctionPointer = nullptr;

unified-runtime/test/conformance/testing/include/uur/checks.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ inline std::ostream &operator<<(std::ostream &out, const Result &result) {
4141
do { \
4242
auto status = ret; \
4343
if (status == UR_RESULT_ERROR_UNSUPPORTED_FEATURE || \
44-
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION) { \
44+
status == UR_RESULT_ERROR_UNSUPPORTED_ENUMERATION || \
45+
status == UR_RESULT_ERROR_COMPILER_NOT_AVAILABLE) { \
4546
GTEST_SKIP(); \
4647
} else { \
4748
ASSERT_EQ(status, UR_RESULT_SUCCESS); \

0 commit comments

Comments
 (0)