Commit ed783689 by Aditya Atluri Committed by Tianqi Chen

added support for rocm gpu autodetect (#549)

* added support for rocm gpu autodetect

* changed type casting from old style to static_cast

* fixed code to generate gfx specific code object

* fixed namespaces
parent 87c929f5
Subproject commit a40a3e2fedee88d2f7b97ba4caf8a9d0eb25886f Subproject commit cb3c025d5b91ab994b063a85bc935fc364d8f491
...@@ -135,9 +135,21 @@ runtime::Module BuildAMDGPU(Array<LoweredFunc> funcs, std::string target) { ...@@ -135,9 +135,21 @@ runtime::Module BuildAMDGPU(Array<LoweredFunc> funcs, std::string target) {
CHECK(target.length( CHECK(target.length(
) >= 4 && ) >= 4 &&
target.substr(0, 4) == "rocm"); target.substr(0, 4) == "rocm");
TVMContext tvmCtx;
tvmCtx.device_type = kROCM;
tvmCtx.device_id = 0;
TVMRetValue val;
tvm::runtime::DeviceAPI::Get(tvmCtx)->GetAttr(tvmCtx, tvm::runtime::kExist, &val);
if (val.operator int() == 1) {
tvm::runtime::DeviceAPI::Get(tvmCtx)->GetAttr(tvmCtx, tvm::runtime::kComputeVersion, &val);
} else {
val = 803;
}
llvm::TargetMachine* tm = \ llvm::TargetMachine* tm = \
GetLLVMTargetMachine("-mtriple=amdgcn-amd-amdhsa-hcc -mcpu=gfx803" + \ GetLLVMTargetMachine("-mtriple=amdgcn-amd-amdhsa-hcc -mcpu=gfx" + \
target.substr(4, target.length() - 4)); std::to_string(val.operator int())+ target.substr(4, target.length() - 4));
std::unique_ptr<CodeGenAMDGPU> cg(new CodeGenAMDGPU()); std::unique_ptr<CodeGenAMDGPU> cg(new CodeGenAMDGPU());
std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext()); std::unique_ptr<llvm::LLVMContext> ctx(new llvm::LLVMContext());
......
...@@ -44,7 +44,11 @@ class ROCMDeviceAPI final : public DeviceAPI { ...@@ -44,7 +44,11 @@ class ROCMDeviceAPI final : public DeviceAPI {
value = 64; value = 64;
break; break;
} }
case kComputeVersion: return; case kComputeVersion:
hipDeviceProp_t prop;
ROCM_CALL(hipGetDeviceProperties(&prop, ctx.device_id));
*rv = prop.gcnArch;
return;
} }
*rv = value; *rv = value;
} }
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment