SWDEV-252745 - Adding rtc options transformer
Change-Id: Ib250689906a35f81255398e53da979774361dbfa
This commit is contained in:
@@ -141,6 +141,34 @@ static std::string handleMangledName(std::string name) {
|
||||
return loweredName;
|
||||
}
|
||||
|
||||
static std::string getValueOf(const std::string& option) {
|
||||
std::string res;
|
||||
auto f = std::find(option.begin(), option.end(), '=');
|
||||
if (f != option.end()) res = std::string(f + 1, option.end());
|
||||
return res;
|
||||
}
|
||||
|
||||
static void transformOptions(std::vector<const char*>& options, amd::Program* program) {
|
||||
std::vector<const char*> t_option;
|
||||
for (auto& i : options) {
|
||||
std::string t_str(i);
|
||||
// Use precompiled header for hip
|
||||
if (t_str == "-hip-pch") {
|
||||
const char* pch = nullptr;
|
||||
unsigned int pch_size = 0;
|
||||
__hipGetPCH(&pch, &pch_size);
|
||||
program->addPreCompiledHeader(std::string(pch, pch_size));
|
||||
i = "-nogpuinc";
|
||||
}
|
||||
// To maintain compatibility with nvrtc
|
||||
if (t_str.find("--gpu-architecture=") != std::string::npos) {
|
||||
auto value = getValueOf(t_str);
|
||||
std::string newValue = "--offload-arch=" + value;
|
||||
i = newValue.c_str();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
const char* hiprtcGetErrorString(hiprtcResult x) {
|
||||
switch (x) {
|
||||
case HIPRTC_SUCCESS:
|
||||
@@ -217,6 +245,7 @@ hiprtcResult hiprtcCompileProgram(hiprtcProgram prog, int numOptions, const char
|
||||
|
||||
std::ostringstream ostrstr;
|
||||
std::vector<const char*> oarr(&options[0], &options[numOptions]);
|
||||
transformOptions(oarr, program);
|
||||
std::copy(oarr.begin(), oarr.end(), std::ostream_iterator<std::string>(ostrstr, " "));
|
||||
|
||||
ostrstr.str().append(" -DHIP_VERSION_MAJOR=9");
|
||||
|
||||
Reference in New Issue
Block a user