From b366a7c99261dd5b27ff261690af30df11dd8a5c Mon Sep 17 00:00:00 2001 From: kjayapra-amd Date: Fri, 15 Dec 2023 10:40:18 -0500 Subject: [PATCH] SWDEV-437832 - Adding device property to check if the device is accelerator. Change-Id: I8349e99c03422c268bbb60a8c143bd492d9cec09 --- hipamd/src/hip_device.cpp | 2 ++ rocclr/device/device.hpp | 2 ++ rocclr/device/rocm/rocdevice.cpp | 13 +++++++++++++ 3 files changed, 17 insertions(+) diff --git a/hipamd/src/hip_device.cpp b/hipamd/src/hip_device.cpp index 5657fd6371..2053461afe 100644 --- a/hipamd/src/hip_device.cpp +++ b/hipamd/src/hip_device.cpp @@ -463,6 +463,8 @@ hipError_t ihipGetDeviceProperties(hipDeviceProp_tR0600* props, int device) { deviceProps.timelineSemaphoreInteropSupported = 0; deviceProps.unifiedFunctionPointers = 0; + deviceProps.integrated = info.accelerator_; + *props = deviceProps; return hipSuccess; } diff --git a/rocclr/device/device.hpp b/rocclr/device/device.hpp index d00dfb4f6c..2dc7b09ee6 100644 --- a/rocclr/device/device.hpp +++ b/rocclr/device/device.hpp @@ -624,6 +624,8 @@ struct Info : public amd::EmbeddedObject { //! global CU mask which will be applied to all queues created on this device std::vector globalCUMask_; + bool accelerator_; //!< Accelerator or discrete graphics card. + //! AQL Barrier Value Packet support bool aqlBarrierValue_; diff --git a/rocclr/device/rocm/rocdevice.cpp b/rocclr/device/rocm/rocdevice.cpp index 3b6b4d4d54..8758c62913 100644 --- a/rocclr/device/rocm/rocdevice.cpp +++ b/rocclr/device/rocm/rocdevice.cpp @@ -1836,6 +1836,19 @@ bool Device::populateOCLDeviceConstants() { std::numeric_limits::max(); // gfx10+ does not share SGPRs between waves } + uint8_t memory_properties[8]; + // Get the memory property from ROCr. + if (HSA_STATUS_SUCCESS != hsa_agent_get_info(bkendDevice_, + (hsa_agent_info_t) HSA_AMD_AGENT_INFO_MEMORY_PROPERTIES, + memory_properties)) { + LogError("HSA_AGENT_INFO_AMD_MEMORY_PROPERTIES query failed"); + } + + // Check if the device is APU + if (hsa_flag_isset64(memory_properties, HSA_AMD_MEMORY_PROPERTY_AGENT_IS_APU)) { + info_.accelerator_ = 1; + } + return true; }