diff --git a/offload/plugins-nextgen/amdgpu/src/rtl.cpp b/offload/plugins-nextgen/amdgpu/src/rtl.cpp index 00650b801b420..1962620ee888f 100644 --- a/offload/plugins-nextgen/amdgpu/src/rtl.cpp +++ b/offload/plugins-nextgen/amdgpu/src/rtl.cpp @@ -2809,7 +2809,22 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { /// Detect if current architecture is an APU. Error checkIfAPU() { - // TODO: replace with ROCr API once it becomes available. +#if (HSA_AMD_INTERFACE_VERSION_MAJOR >= 1 && \ + HSA_AMD_INTERFACE_VERSION_MINOR >= 5) + + uint8_t MemoryProperties[8]; + + hsa_status_t Stat = hsa_agent_get_info( + getAgent(), (hsa_agent_info_t)HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES, + MemoryProperties); + + if (auto Err = Plugin::check(Stat, "Error: Unable to fetch the memory " + "properties of the GPU. (%s)\n")) + return Err; + + IsAPU = hsa_flag_isset64(MemoryProperties, + HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU); +#else llvm::StringRef StrGfxName(ComputeUnitKind); IsAPU = llvm::StringSwitch(StrGfxName) .Case("gfx940", true) @@ -2832,6 +2847,7 @@ struct AMDGPUDeviceTy : public GenericDeviceTy, AMDGenericDeviceTy { IsAPU = true; return Plugin::success(); } +#endif return Plugin::success(); }