SWDEV-371628 Use integrated Comgr action to link ROCm device libs
Previously, we used the following approach and Comgr actions
for device lib linking:
AMD_COMGR_COMPILE_SOURCE_TO_BC (compile with clang driver)
AMD_COMGR_ADD_DEVICE_LIBRARIES (link in device libs with
llvm-link API)
However, the clang driver can link in device libraries as part
of compilation, assuming a --rocm-path is set. In this context,
this is accomplished by using the following Comgr action instead:
AMD_COMGR_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC (compile and
link in device libs with clang driver)
Change-Id: Ie0bbee7d9a12672536b6d751056a941128ed58be
[ROCm/clr commit: 6311ed8a8e]
Cette révision appartient à :
révisé par
Jacob Lambert
Parent
5af8ba8513
révision
6733795fee
@@ -342,7 +342,7 @@ amd_comgr_status_t Program::createAction(const amd_comgr_language_t oclver,
|
||||
bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
|
||||
const std::vector<std::string>& options,
|
||||
amd::option::Options* amdOptions, amd_comgr_data_set_t* output,
|
||||
char* binaryData[], size_t* binarySize, const bool link_dev_libs) {
|
||||
char* binaryData[], size_t* binarySize) {
|
||||
|
||||
amd_comgr_language_t langver = getCOMGRLanguage(isHIP(), *amdOptions);
|
||||
if (langver == AMD_COMGR_LANGUAGE_NONE) {
|
||||
@@ -351,28 +351,13 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
|
||||
|
||||
// Create the action for linking
|
||||
amd_comgr_action_info_t action;
|
||||
amd_comgr_data_set_t dataSetDevLibs;
|
||||
bool hasAction = false;
|
||||
bool hasDataSetDevLibs = false;
|
||||
|
||||
amd_comgr_status_t status = createAction(langver, options, &action, &hasAction);
|
||||
|
||||
if (link_dev_libs) {
|
||||
if (status == AMD_COMGR_STATUS_SUCCESS) {
|
||||
status = amd::Comgr::create_data_set(&dataSetDevLibs);
|
||||
}
|
||||
|
||||
if (status == AMD_COMGR_STATUS_SUCCESS) {
|
||||
hasDataSetDevLibs = true;
|
||||
status = amd::Comgr::do_action(AMD_COMGR_ACTION_ADD_DEVICE_LIBRARIES, action, inputs,
|
||||
dataSetDevLibs);
|
||||
extractBuildLog(dataSetDevLibs);
|
||||
}
|
||||
}
|
||||
|
||||
if (status == AMD_COMGR_STATUS_SUCCESS) {
|
||||
status = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action,
|
||||
(link_dev_libs) ? dataSetDevLibs : inputs, *output);
|
||||
inputs, *output);
|
||||
extractBuildLog(*output);
|
||||
}
|
||||
|
||||
@@ -389,17 +374,14 @@ bool Program::linkLLVMBitcode(const amd_comgr_data_set_t inputs,
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
}
|
||||
|
||||
if (hasDataSetDevLibs) {
|
||||
amd::Comgr::destroy_data_set(dataSetDevLibs);
|
||||
}
|
||||
|
||||
return (status == AMD_COMGR_STATUS_SUCCESS);
|
||||
}
|
||||
|
||||
bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t compileInputs,
|
||||
const std::vector<std::string>& options,
|
||||
amd::option::Options* amdOptions,
|
||||
char* binaryData[], size_t* binarySize) {
|
||||
char* binaryData[], size_t* binarySize,
|
||||
const bool link_dev_libs) {
|
||||
|
||||
amd_comgr_language_t langver = getCOMGRLanguage(isHIP(), *amdOptions);
|
||||
if (langver == AMD_COMGR_LANGUAGE_NONE) {
|
||||
@@ -473,8 +455,14 @@ bool Program::compileToLLVMBitcode(const amd_comgr_data_set_t compileInputs,
|
||||
|
||||
// Compiling the source codes with precompiled headers or directly compileInputs
|
||||
if (status == AMD_COMGR_STATUS_SUCCESS) {
|
||||
status = amd::Comgr::do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC,
|
||||
action, input, output);
|
||||
if (link_dev_libs) {
|
||||
status = amd::Comgr::do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_WITH_DEVICE_LIBS_TO_BC,
|
||||
action, input, output);
|
||||
}
|
||||
else {
|
||||
status = amd::Comgr::do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_TO_BC,
|
||||
action, input, output);
|
||||
}
|
||||
extractBuildLog(output);
|
||||
}
|
||||
|
||||
@@ -960,9 +948,8 @@ bool Program::linkImplLC(const std::vector<Program*>& inputPrograms,
|
||||
char* binaryData = nullptr;
|
||||
size_t binarySize = 0;
|
||||
std::vector<std::string> linkOptions;
|
||||
constexpr bool kLinkDevLibs = false;
|
||||
bool ret = linkLLVMBitcode(inputs, linkOptions, options, &output, &binaryData,
|
||||
&binarySize, kLinkDevLibs);
|
||||
&binarySize);
|
||||
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
amd::Comgr::destroy_data_set(inputs);
|
||||
|
||||
@@ -460,13 +460,13 @@ class Program : public amd::HeapObject {
|
||||
bool linkLLVMBitcode(const amd_comgr_data_set_t inputs,
|
||||
const std::vector<std::string>& options,
|
||||
amd::option::Options* amdOptions, amd_comgr_data_set_t* output,
|
||||
char* binaryData[] = nullptr, size_t* binarySize = nullptr,
|
||||
const bool link_dev_libs = true);
|
||||
char* binaryData[] = nullptr, size_t* binarySize = nullptr);
|
||||
|
||||
//! Create the bitcode of the compiled input dataset
|
||||
bool compileToLLVMBitcode(const amd_comgr_data_set_t compileInputs,
|
||||
const std::vector<std::string>& options, amd::option::Options* amdOptions,
|
||||
char* binaryData[], size_t* binarySize);
|
||||
char* binaryData[], size_t* binarySize,
|
||||
const bool link_dev_libs = true);
|
||||
|
||||
//! Compile and create the excutable of the input dataset
|
||||
bool compileAndLinkExecutable(const amd_comgr_data_set_t inputs,
|
||||
|
||||
Référencer dans un nouveau ticket
Bloquer un utilisateur