Skip to content

Commit

Permalink
[CUDA] Add support for binary type query
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomestre committed Oct 23, 2023
1 parent 3a3aae3 commit 989db55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
9 changes: 8 additions & 1 deletion source/adapters/cuda/program.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,9 @@ urProgramCreateWithIL(ur_context_handle_t hContext, const void *pIL,
UR_APIEXPORT ur_result_t UR_APICALL
urProgramCompile(ur_context_handle_t hContext, ur_program_handle_t hProgram,
const char *pOptions) {
return urProgramBuild(hContext, hProgram, pOptions);
UR_CHECK_ERROR(urProgramBuild(hContext, hProgram, pOptions));
hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_COMPILED_OBJECT;
return UR_RESULT_SUCCESS;
}

/// Loads the images from a UR program into a CUmodule that can be
Expand All @@ -202,6 +204,7 @@ UR_APIEXPORT ur_result_t UR_APICALL urProgramBuild(ur_context_handle_t hContext,
ScopedContext Active(hProgram->getContext());

hProgram->buildProgram(pOptions);
hProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_EXECUTABLE;

} catch (ur_result_t Err) {
Result = Err;
Expand Down Expand Up @@ -241,6 +244,7 @@ urProgramLink(ur_context_handle_t hContext, uint32_t count,
RetProgram->setBinary(static_cast<const char *>(CuBin), CuBinSize);

Result = RetProgram->buildProgram(pOptions);
RetProgram->BinaryType = UR_PROGRAM_BINARY_TYPE_EXECUTABLE;
} catch (...) {
// Upon error attempt cleanup
UR_CHECK_ERROR(cuLinkDestroy(State));
Expand Down Expand Up @@ -287,6 +291,9 @@ urProgramGetBuildInfo(ur_program_handle_t hProgram, ur_device_handle_t hDevice,
return ReturnValue(hProgram->BuildOptions.c_str());
case UR_PROGRAM_BUILD_INFO_LOG:
return ReturnValue(hProgram->InfoLog, hProgram->MaxLogSize);
case UR_PROGRAM_BUILD_INFO_BINARY_TYPE: {
return ReturnValue(hProgram->BinaryType);
}
default:
break;
}
Expand Down
1 change: 1 addition & 0 deletions source/adapters/cuda/program.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ struct ur_program_handle_t_ {
size_t BinarySizeInBytes;
std::atomic_uint32_t RefCount;
ur_context_handle_t Context;
ur_program_binary_type_t BinaryType = UR_PROGRAM_BINARY_TYPE_NONE;

// Metadata
std::unordered_map<std::string, std::tuple<uint32_t, uint32_t, uint32_t>>
Expand Down

0 comments on commit 989db55

Please sign in to comment.