diff --git a/rocclr/compiler/lib/backends/common/codegen.cpp b/rocclr/compiler/lib/backends/common/codegen.cpp index 739a28cb87..ca235d7487 100644 --- a/rocclr/compiler/lib/backends/common/codegen.cpp +++ b/rocclr/compiler/lib/backends/common/codegen.cpp @@ -42,6 +42,10 @@ using namespace amdcl; using namespace llvm; +namespace llvm { + extern int HsailOptimizeFor; +} + //!--------------------------------------------------------------------------!// // JIT Memory manager //!--------------------------------------------------------------------------!// @@ -614,6 +618,7 @@ llvmCodeGen( #ifdef WITH_TARGET_HSAIL if (isHSAILTarget(binary->target)) { + llvm::HsailOptimizeFor = getIsaType(aclutGetTargetInfo(binary)); if (Target.addPassesToEmitFile(Passes, *Out, TargetMachine::CGFT_ObjectFile, true)) { delete Out; return 1; diff --git a/rocclr/compiler/lib/backends/common/linker.cpp b/rocclr/compiler/lib/backends/common/linker.cpp index 4d66c0061b..49ca3c6e74 100644 --- a/rocclr/compiler/lib/backends/common/linker.cpp +++ b/rocclr/compiler/lib/backends/common/linker.cpp @@ -750,12 +750,7 @@ amdcl::OCLLinker::link(llvm::Module* input, std::vector &libs) || chip == "Hawaii" || chip == "Carrizo" || chip == ""); - setISAVersion((chip == "Hawaii") ? 701 : - ((chip == "Iceland" || chip == "Tonga") ? 800 : - ((chip == "Carrizo") ? 801 : - ((chip == "Fiji" || chip == "Baffin" || chip == "Ellesmere") ? 804 : - ((chip == "Stoney") ? 810 : - ((chip == "") ? 900 : 700)))))); + setISAVersion(getIsaType(aclutGetTargetInfo(Elf()))); LLVMBinary()->getContext().setAMDLLVMContextHook(&hookup_); std::string clp_errmsg; diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp index 2418ed843e..2d497e0044 100644 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.cpp +++ b/rocclr/compiler/lib/utils/v0_8/libUtils.cpp @@ -511,47 +511,64 @@ unsigned getChipEnum(const aclTargetInfo *target) *the TargetMapping table for the specific target device id. */ const std::string &getIsaTypeName(const aclTargetInfo *target) +{ + switch (getIsaType(target)) { + default: return sgfx700; + case 700: return sgfx700; + case 701: return sgfx701; + case 800: return sgfx800; + case 801: return sgfx801; + case 804: return sgfx804; + case 810: return sgfx810; + case 900: return sgfx900; + } +} + +/*! Function that returns isa type (compute capability) from + *the TargetMapping table for the specific target device id. + */ +int getIsaType(const aclTargetInfo *target) { const TargetMapping& Mapping = getTargetMapping(*target); switch (Mapping.family_enum) { - default: return sgfx700; + default: return 700; case FAMILY_KV: switch (Mapping.chip_enum) { - default: return sgfx700; + default: return 700; case KV_SPECTRE_A0: case KV_SPOOKY_A0: case KB_KALINDI_A0: // ??? - case ML_GODAVARI_A0: return sgfx700; + case ML_GODAVARI_A0: return 700; } case FAMILY_CI: switch (Mapping.chip_enum) { - default: return sgfx700; + default: return 700; case CI_BONAIRE_M_A0: - case CI_BONAIRE_M_A1: return sgfx700; - case CI_HAWAII_P_A0: return sgfx701; + case CI_BONAIRE_M_A1: return 700; + case CI_HAWAII_P_A0: return 701; case CI_TIRAN_P_A0: - case CI_MAUI_P_A0: return sgfx700; + case CI_MAUI_P_A0: return 700; } case FAMILY_VI: switch (Mapping.chip_enum) { - default: return sgfx800; + default: return 800; case VI_ICELAND_M_A0: - case VI_TONGA_P_A0: return sgfx800; + case VI_TONGA_P_A0: return 800; case VI_ELLESMERE_P_A0: case VI_BAFFIN_M_A0: - case VI_FIJI_P_A0: return sgfx804; + case VI_FIJI_P_A0: return 804; } case FAMILY_CZ: switch (Mapping.chip_enum) { - default: return sgfx801; - case CARRIZO_A0: return sgfx801; - case STONEY_A0: return sgfx810; + default: return 801; + case CARRIZO_A0: return 801; + case STONEY_A0: return 810; } case FAMILY_AI: switch (Mapping.chip_enum) { - default: return sgfx900; - case AI_GREENLAND_P_A0: return sgfx900; + default: return 900; + case AI_GREENLAND_P_A0: return 900; } } } diff --git a/rocclr/compiler/lib/utils/v0_8/libUtils.h b/rocclr/compiler/lib/utils/v0_8/libUtils.h index 06ed8a6105..ef6b764aa8 100644 --- a/rocclr/compiler/lib/utils/v0_8/libUtils.h +++ b/rocclr/compiler/lib/utils/v0_8/libUtils.h @@ -55,6 +55,9 @@ unsigned getChipEnum(const aclTargetInfo *target); // get isa type name (compute capability) from the target information. const std::string &getIsaTypeName(const aclTargetInfo *target); +// get isa type (compute capability) from the target information. +int getIsaType(const aclTargetInfo *target); + // Create a copy of an ELF and duplicate all sections/symbols aclBinary* createELFCopy(aclBinary *src);