From 8bda935a7120e62b9c71acf377ef2aa8c0c4cd9c Mon Sep 17 00:00:00 2001 From: German Andryeyev Date: Wed, 1 Apr 2020 10:07:48 -0400 Subject: [PATCH] SWDEV-184709 - support hipLaunchCooperativeKernel() - Enable cooperative groups support, based on ROCr capability Change-Id: I975bcea0af7865009eaed24454ce71d897ea8fc4 [ROCm/clr commit: 481d526859662d648b228739787eb092530bc519] --- projects/clr/rocclr/device/rocm/rocdevice.cpp | 14 ++++++++++++-- projects/clr/rocclr/device/rocm/rocsettings.cpp | 6 +++--- projects/clr/rocclr/device/rocm/rocsettings.hpp | 2 +- 3 files changed, 16 insertions(+), 6 deletions(-) diff --git a/projects/clr/rocclr/device/rocm/rocdevice.cpp b/projects/clr/rocclr/device/rocm/rocdevice.cpp index edddf47316..8dc8a6e690 100755 --- a/projects/clr/rocclr/device/rocm/rocdevice.cpp +++ b/projects/clr/rocclr/device/rocm/rocdevice.cpp @@ -639,11 +639,20 @@ bool Device::create(bool sramEccEnabled) { return false; } + uint32_t coop_groups = 0; + // Check cooperative groups for HIP only + if (amd::IS_HIP && (HSA_STATUS_SUCCESS != + hsa_agent_get_info(_bkendDevice, + static_cast(HSA_AMD_AGENT_INFO_COOPERATIVE_QUEUES), &coop_groups))) { + return false; + } + // Create HSA settings settings_ = new Settings(); roc::Settings* hsaSettings = static_cast(settings_); if ((hsaSettings == nullptr) || - !hsaSettings->create((agent_profile_ == HSA_PROFILE_FULL), deviceInfo_.gfxipVersion_)) { + !hsaSettings->create((agent_profile_ == HSA_PROFILE_FULL), + deviceInfo_.gfxipVersion_, coop_groups)) { return false; } @@ -658,7 +667,8 @@ bool Device::create(bool sramEccEnabled) { uint32_t hsa_bdf_id = 0; if (HSA_STATUS_SUCCESS != - hsa_agent_get_info(_bkendDevice, (hsa_agent_info_t)HSA_AMD_AGENT_INFO_BDFID, &hsa_bdf_id)) { + hsa_agent_get_info(_bkendDevice, + static_cast(HSA_AMD_AGENT_INFO_BDFID), &hsa_bdf_id)) { return false; } diff --git a/projects/clr/rocclr/device/rocm/rocsettings.cpp b/projects/clr/rocclr/device/rocm/rocsettings.cpp index 7fc3ccfb48..bedb0b679c 100644 --- a/projects/clr/rocclr/device/rocm/rocsettings.cpp +++ b/projects/clr/rocclr/device/rocm/rocsettings.cpp @@ -89,7 +89,7 @@ Settings::Settings() { imageBufferWar_ = false; } -bool Settings::create(bool fullProfile, int gfxipVersion) { +bool Settings::create(bool fullProfile, int gfxipVersion, bool coop_groups) { customHostAllocator_ = false; if (fullProfile) { @@ -134,8 +134,8 @@ bool Settings::create(bool fullProfile, int gfxipVersion) { // enable subnormals for gfx900 and later if (gfxipVersion >= 900) { singleFpDenorm_ = true; - enableCoopGroups_ = true; - enableCoopMultiDeviceGroups_ = true; + enableCoopGroups_ = coop_groups; + enableCoopMultiDeviceGroups_ = coop_groups; } } else { // Also enable AMD double precision extension? diff --git a/projects/clr/rocclr/device/rocm/rocsettings.hpp b/projects/clr/rocclr/device/rocm/rocsettings.hpp index deda6351f0..343aeb2095 100644 --- a/projects/clr/rocclr/device/rocm/rocsettings.hpp +++ b/projects/clr/rocclr/device/rocm/rocsettings.hpp @@ -77,7 +77,7 @@ class Settings : public device::Settings { Settings(); //! Creates settings - bool create(bool fullProfile, int gfxipVersion); + bool create(bool fullProfile, int gfxipVersion, bool coop_groups = false); private: //! Disable copy constructor