Revert "SWDEV-425605 - Add new comgr compile to reloc"
This reverts commit b26fdcc77c2aa20f39f7dec9afa24e755d2c03f5.
Reason for revert: breaks windows-psdb
Change-Id: I8b2fcaf0d0be09a9364e386127cabafb68a67e0d
[ROCm/clr commit: baf61b6a02]
Этот коммит содержится в:
коммит произвёл
Maneesh Gupta
родитель
4e5d704c0c
Коммит
3e3ca21c09
@@ -585,86 +585,6 @@ bool createAction(amd_comgr_action_info_t& action, std::vector<std::string>& opt
|
||||
return AMD_COMGR_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
bool compileToExecutable(const amd_comgr_data_set_t compileInputs, const std::string& isa,
|
||||
std::vector<std::string>& compileOptions, std::string& buildLog,
|
||||
std::vector<char>& exe) {
|
||||
amd_comgr_language_t lang = AMD_COMGR_LANGUAGE_HIP;
|
||||
amd_comgr_action_info_t action;
|
||||
amd_comgr_data_set_t reloc;
|
||||
amd_comgr_data_set_t output;
|
||||
amd_comgr_data_set_t input = compileInputs;
|
||||
|
||||
if (auto res = createAction(action, compileOptions, isa, lang); res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto res = amd::Comgr::create_data_set(&reloc); res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto res = amd::Comgr::create_data_set(&output); res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto res = amd::Comgr::do_action(AMD_COMGR_ACTION_COMPILE_SOURCE_TO_RELOCATABLE, action,
|
||||
input, reloc);
|
||||
res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
extractBuildLog(reloc, buildLog);
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!extractBuildLog(reloc, buildLog)) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
return false;
|
||||
}
|
||||
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
if (auto res = createAction(action, compileOptions, isa, lang); res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto res = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_RELOCATABLE_TO_EXECUTABLE, action,
|
||||
reloc, output);
|
||||
res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
extractBuildLog(output, buildLog);
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!extractBuildLog(output, buildLog)) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!extractByteCodeBinary(output, AMD_COMGR_DATA_KIND_EXECUTABLE, exe)) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
return false;
|
||||
}
|
||||
|
||||
// Clean up
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
amd::Comgr::destroy_data_set(reloc);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool compileToBitCode(const amd_comgr_data_set_t compileInputs, const std::string& isa,
|
||||
std::vector<std::string>& compileOptions, std::string& buildLog,
|
||||
std::vector<char>& LLVMBitcode) {
|
||||
@@ -726,7 +646,8 @@ bool linkLLVMBitcode(const amd_comgr_data_set_t linkInputs, const std::string& i
|
||||
return false;
|
||||
}
|
||||
|
||||
if (auto res = amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action, linkInputs, output);
|
||||
if (auto res =
|
||||
amd::Comgr::do_action(AMD_COMGR_ACTION_LINK_BC_TO_BC, action, linkInputs, output);
|
||||
res != AMD_COMGR_STATUS_SUCCESS) {
|
||||
amd::Comgr::destroy_action_info(action);
|
||||
amd::Comgr::destroy_data_set(output);
|
||||
@@ -994,9 +915,9 @@ bool fillMangledNames(std::vector<char>& dataVec, std::map<std::string, std::str
|
||||
return false;
|
||||
}
|
||||
|
||||
for (auto& it : mangledNames) {
|
||||
for (auto &it : mangledNames) {
|
||||
size_t Size;
|
||||
char* data = const_cast<char*>(it.first.data());
|
||||
char *data = const_cast<char*>(it.first.data());
|
||||
|
||||
if (auto res = amd::Comgr::map_name_expression_to_symbol_name(dataObject, &Size, data, NULL)) {
|
||||
amd::Comgr::release_data(dataObject);
|
||||
@@ -1004,8 +925,7 @@ bool fillMangledNames(std::vector<char>& dataVec, std::map<std::string, std::str
|
||||
}
|
||||
|
||||
std::unique_ptr<char[]> mName(new char[Size]());
|
||||
if (auto res =
|
||||
amd::Comgr::map_name_expression_to_symbol_name(dataObject, &Size, data, mName.get())) {
|
||||
if (auto res = amd::Comgr::map_name_expression_to_symbol_name(dataObject, &Size, data, mName.get())) {
|
||||
amd::Comgr::release_data(dataObject);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -41,9 +41,6 @@ bool extractByteCodeBinary(const amd_comgr_data_set_t inDataSet,
|
||||
bool createAction(amd_comgr_action_info_t& action, std::vector<std::string>& options,
|
||||
const std::string& isa,
|
||||
const amd_comgr_language_t lang = AMD_COMGR_LANGUAGE_NONE);
|
||||
bool compileToExecutable(const amd_comgr_data_set_t compileInputs, const std::string& isa,
|
||||
std::vector<std::string>& compileOptions, std::string& buildLog,
|
||||
std::vector<char>& exe);
|
||||
bool compileToBitCode(const amd_comgr_data_set_t compileInputs, const std::string& isa,
|
||||
std::vector<std::string>& compileOptions, std::string& buildLog,
|
||||
std::vector<char>& LLVMBitcode);
|
||||
@@ -57,8 +54,8 @@ bool dumpIsaFromBC(const amd_comgr_data_set_t isaInputs, const std::string& isa,
|
||||
std::vector<std::string>& exeOptions, std::string name, std::string& buildLog);
|
||||
bool demangleName(const std::string& mangledName, std::string& demangledName);
|
||||
std::string handleMangledName(std::string loweredName);
|
||||
bool fillMangledNames(std::vector<char>& executable,
|
||||
std::map<std::string, std::string>& mangledNames, bool isBitcode);
|
||||
bool fillMangledNames(std::vector<char>& executable, std::map<std::string, std::string>& mangledNames,
|
||||
bool isBitcode);
|
||||
void GenerateUniqueFileName(std::string& name);
|
||||
} // namespace helpers
|
||||
} // namespace hiprtc
|
||||
|
||||
@@ -116,6 +116,7 @@ bool RTCProgram::findIsa() {
|
||||
|
||||
// RTC Compile Program Member Functions
|
||||
void RTCProgram::AppendOptions(const std::string app_env_var, std::vector<std::string>* options) {
|
||||
|
||||
if (options == nullptr) {
|
||||
LogError("Append options passed is nullptr.");
|
||||
return;
|
||||
@@ -260,6 +261,10 @@ bool RTCCompileProgram::transformOptions(std::vector<std::string>& compile_optio
|
||||
i = "--offload-arch=" + val;
|
||||
continue;
|
||||
}
|
||||
if (i == "--save-temps") {
|
||||
settings_.dumpISA = true;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// Removed consumed options
|
||||
@@ -295,27 +300,78 @@ bool RTCCompileProgram::compile(const std::vector<std::string>& options, bool fg
|
||||
compileOpts.reserve(compile_options_.size() + options.size() + 2);
|
||||
compileOpts.insert(compileOpts.end(), options.begin(), options.end());
|
||||
|
||||
if (!fgpu_rdc_) {
|
||||
compileOpts.push_back("-Xclang");
|
||||
compileOpts.push_back("-disable-llvm-passes");
|
||||
}
|
||||
|
||||
if (!transformOptions(compileOpts)) {
|
||||
LogError("Error in hiprtc: unable to transform options");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fgpu_rdc_) {
|
||||
if (!compileToBitCode(compile_input_, isa_, compileOpts, build_log_, LLVMBitcode_)) {
|
||||
LogError("Error in hiprtc: unable to compile source to bitcode");
|
||||
if (!compileToBitCode(compile_input_, isa_, compileOpts, build_log_, LLVMBitcode_)) {
|
||||
LogError("Error in hiprtc: unable to compile source to bitcode");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fgpu_rdc_ && !mangled_names_.empty()) {
|
||||
if (!fillMangledNames(LLVMBitcode_, mangled_names_, true)) {
|
||||
LogError("Error in hiprtc: unable to fill mangled names");
|
||||
return false;
|
||||
}
|
||||
} else {
|
||||
LogInfo("Using the new path of comgr");
|
||||
if (!compileToExecutable(compile_input_, isa_, compileOpts, build_log_, executable_)) {
|
||||
LogError("Failing to compile to realloc");
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string linkFileName = "linked";
|
||||
if (!addCodeObjData(link_input_, LLVMBitcode_, linkFileName, AMD_COMGR_DATA_KIND_BC)) {
|
||||
LogError("Error in hiprtc: unable to add linked code object");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<char> LinkedLLVMBitcode;
|
||||
if (!linkLLVMBitcode(link_input_, isa_, link_options_, build_log_, LinkedLLVMBitcode)) {
|
||||
LogError("Error in hiprtc: unable to add device libs to linked bitcode");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string linkedFileName = "LLVMBitcode.bc";
|
||||
if (!addCodeObjData(exec_input_, LinkedLLVMBitcode, linkedFileName, AMD_COMGR_DATA_KIND_BC)) {
|
||||
LogError("Error in hiprtc: unable to add device libs linked code object");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> exe_options;
|
||||
// Find the options passed by the app which can be used during BC to Relocatable phase.
|
||||
if (!findExeOptions(options, exe_options)) {
|
||||
LogError("Error in hiprtc: unable to find executable options");
|
||||
return false;
|
||||
}
|
||||
|
||||
std::vector<std::string> exeOpts(exe_options_);
|
||||
exeOpts.reserve(exeOpts.size() + exe_options.size() + 2);
|
||||
// Add these below options by default for optimizations during BC to Relocatable phase.
|
||||
exeOpts.push_back("-mllvm");
|
||||
exeOpts.push_back("-amdgpu-internalize-symbols");
|
||||
// User provided options are appended at the end since they can override the above
|
||||
// default options if necessary
|
||||
exeOpts.insert(exeOpts.end(), exe_options.begin(), exe_options.end());
|
||||
|
||||
if (settings_.dumpISA) {
|
||||
if (!dumpIsaFromBC(exec_input_, isa_, exeOpts, name_, build_log_)) {
|
||||
LogError("Error in hiprtc: unable to dump isa code");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!createExecutable(exec_input_, isa_, exeOpts, build_log_, executable_)) {
|
||||
LogError("Error in hiprtc: unable to create executable");
|
||||
return false;
|
||||
}
|
||||
|
||||
if (!mangled_names_.empty()) {
|
||||
auto& compile_step_output = fgpu_rdc_ ? LLVMBitcode_ : executable_;
|
||||
if (!fillMangledNames(compile_step_output, mangled_names_, fgpu_rdc_)) {
|
||||
if (!fillMangledNames(executable_, mangled_names_, false)) {
|
||||
LogError("Error in hiprtc: unable to fill mangled names");
|
||||
return false;
|
||||
}
|
||||
@@ -324,7 +380,6 @@ bool RTCCompileProgram::compile(const std::vector<std::string>& options, bool fg
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
void RTCCompileProgram::stripNamedExpression(std::string& strippedName) {
|
||||
if (strippedName.back() == ')') {
|
||||
strippedName.pop_back();
|
||||
@@ -398,6 +453,7 @@ RTCLinkProgram::RTCLinkProgram(std::string name) : RTCProgram(name) {
|
||||
bool RTCLinkProgram::AddLinkerOptions(unsigned int num_options, hiprtcJIT_option* options_ptr,
|
||||
void** options_vals_ptr) {
|
||||
for (size_t opt_idx = 0; opt_idx < num_options; ++opt_idx) {
|
||||
|
||||
switch (options_ptr[opt_idx]) {
|
||||
case HIPRTC_JIT_MAX_REGISTERS:
|
||||
link_args_.max_registers_ = *(reinterpret_cast<unsigned int*>(&options_vals_ptr[opt_idx]));
|
||||
|
||||
@@ -107,6 +107,7 @@ static void crashWithMessage(std::string message) {
|
||||
}
|
||||
|
||||
struct Settings {
|
||||
bool dumpISA{false};
|
||||
bool offloadArchProvided{false};
|
||||
};
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user