Skip to content

Commit 94e8395

Browse files
authored
Merge pull request #1661 from frasercrmck/fix-hip-program-info-build-type
[HIP] Add support for querying program binary type
2 parents 15c789d + db05ea4 commit 94e8395

File tree

3 files changed

+16
-4
lines changed

3 files changed

+16
-4
lines changed

source/adapters/hip/program.cpp

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,11 @@ urProgramCreateWithIL(ur_context_handle_t, const void *, size_t,
283283
UR_APIEXPORT ur_result_t UR_APICALL
284284
urProgramCompile(ur_context_handle_t hContext, ur_program_handle_t hProgram,
285285
const char *pOptions) {
286-
return urProgramBuild(hContext, hProgram, pOptions);
286+
UR_CHECK_ERROR(urProgramBuild(hContext, hProgram, pOptions));
287+
// urProgramBuild sets the BinaryType to UR_PROGRAM_BINARY_TYPE_EXECUTABLE, so
288+
// set it to the correct value for urProgramCompile post-hoc.
289+
hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
290+
return UR_RESULT_SUCCESS;
287291
}
288292

289293
UR_APIEXPORT ur_result_t UR_APICALL urProgramCompileExp(ur_program_handle_t,
@@ -312,6 +316,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t,
312316
ScopedContext Active(hProgram->getDevice());
313317

314318
hProgram->buildProgram(pOptions);
319+
hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_EXECUTABLE;
315320

316321
} catch (ur_result_t Err) {
317322
Result = Err;
@@ -355,13 +360,14 @@ urProgramGetBuildInfo(ur_program_handle_t hProgram, ur_device_handle_t,
355360
UrReturnHelper ReturnValue(propSize, pPropValue, pPropSizeRet);
356361

357362
switch (propName) {
358-
case UR_PROGRAM_BUILD_INFO_STATUS: {
363+
case UR_PROGRAM_BUILD_INFO_STATUS:
359364
return ReturnValue(hProgram->BuildStatus);
360-
}
361365
case UR_PROGRAM_BUILD_INFO_OPTIONS:
362366
return ReturnValue(hProgram->BuildOptions.c_str());
363367
case UR_PROGRAM_BUILD_INFO_LOG:
364368
return ReturnValue(hProgram->InfoLog, hProgram->MAX_LOG_SIZE);
369+
case UR_PROGRAM_BUILD_INFO_BINARY_TYPE:
370+
return ReturnValue(hProgram->BinaryType);
365371
default:
366372
break;
367373
}
@@ -494,6 +500,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramCreateWithBinary(
494500
UR_ASSERT(Result == UR_RESULT_SUCCESS, Result);
495501

496502
*phProgram = RetProgram.release();
503+
(*phProgram)->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
497504

498505
return Result;
499506
}

source/adapters/hip/program.hpp

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,12 @@ struct ur_program_handle_t_ {
2727
ur_device_handle_t Device;
2828
std::string ExecutableCache;
2929

30+
// The ur_program_binary_type_t property is defined individually for every
31+
// device in a program. However, since the HIP adapter only has 1 device per
32+
// program, there is no need to keep track of its value for each
33+
// device.
34+
ur_program_binary_type_t BinaryType = UR_PROGRAM_BINARY_TYPE_NONE;
35+
3036
// Metadata
3137
bool IsRelocatable = false;
3238

test/conformance/program/program_adapter_hip.match

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
urProgramBuildTest.BuildFailure/AMD_HIP_BACKEND___{{.*}}_
22
# HIP hasn't implemented urProgramCreateWithNativeHandleTest
33
{{OPT}}urProgramCreateWithNativeHandleTest.Success/AMD_HIP_BACKEND___{{.*}}_
4-
urProgramGetBuildInfoTest.Success/AMD_HIP_BACKEND___{{.*}}___UR_PROGRAM_BUILD_INFO_BINARY_TYPE
54
# This test flakily fails
65
{{OPT}}urProgramGetBuildInfoSingleTest.LogIsNullTerminated/AMD_HIP_BACKEND___{{.*}}_
76
# HIP doesn't expose kernel numbers or names

0 commit comments

Comments
 (0)