From 4394baef5bd5a34efdda3016aa2be531870df7bb Mon Sep 17 00:00:00 2001 From: foreman Date: Tue, 5 Sep 2017 18:22:55 -0400 Subject: [PATCH] P4 to Git Change 1455464 by asalmanp@asalmanp-ocl-stg on 2017/09/05 18:07:43 SWDEV-79278 - [OCL][PAL] refactoring PAL Null device create function to account for creating all the gfx9+ subtarget devices such as gfx901/gfx902/etc ReviewboardURL = http://ocltc.amd.com/reviews/r/13378/ Affected files ... ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldefs.hpp#21 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#53 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.hpp#18 edit [ROCm/clr commit: 9772217dcb6a1c64cf68bab7b940027af7e249c7] --- .../clr/rocclr/runtime/device/pal/paldefs.hpp | 28 ++-- .../rocclr/runtime/device/pal/paldevice.cpp | 120 +++++++++++++----- .../rocclr/runtime/device/pal/paldevice.hpp | 5 +- 3 files changed, 99 insertions(+), 54 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/pal/paldefs.hpp b/projects/clr/rocclr/runtime/device/pal/paldefs.hpp index 7f8f092594..b8804986e2 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldefs.hpp +++ b/projects/clr/rocclr/runtime/device/pal/paldefs.hpp @@ -147,33 +147,21 @@ static const AMDDeviceInfo DeviceInfo[] = { /* Baffin */ {"Baffin", "baffin", 4, 16, 1, 256, 64 * Ki, 32, 804}, }; -// The GfxIpDeviceInfo table must match with GfxIpLevel enum -// (located in //depot/stg/pal/inc/core/palDevice.h). -static const AMDDeviceInfo GfxIpDeviceInfo[] = { - /* Unknown */ {"unknown", "unknown", 4, 16, 1, 256, 64 * Ki, 32, 000}, - /* GFX600 */ {"gfx600", "gfx600", 4, 16, 1, 256, 64 * Ki, 32, 600}, - /* GFX700 */ {"gfx700", "gfx700", 4, 16, 1, 256, 64 * Ki, 32, 700}, - /* GFX800 */ {"gfx800", "gfx800", 4, 16, 1, 256, 64 * Ki, 32, 800}, - /* GFX810 */ {"gfx810", "gfx810", 4, 16, 1, 256, 64 * Ki, 32, 810}, - /* GFX900 */ {"gfx900", "gfx900", 4, 16, 1, 256, 64 * Ki, 32, 900}, - /* GFX1000 */ {"gfx1000", "gfx1000", 4, 16, 1, 256, 64 * Ki, 32, 1000 }, -}; - // Ordering as per AsicRevision# in //depot/stg/pal/inc/core/palDevice.h and // http://confluence.amd.com/pages/viewpage.action?spaceKey=ASLC&title=AMDGPU+Target+Names static const AMDDeviceInfo Gfx9PlusSubDeviceInfo[] = { /* Vega10 */{"gfx900", "gfx900", 4, 16, 1, 256, 64 * Ki, 32, 900}, /* Vega10 XNACK */{"gfx901", "gfx901", 4, 16, 1, 256, 64 * Ki, 32, 901}, - /* Vega12 */{"gfx904", "gfx904", 4, 16, 1, 256, 64 * Ki, 32, 904}, - /* Vega12 XNACK */{"gfx905", "gfx905", 4, 16, 1, 256, 64 * Ki, 32, 905}, - /* Vega20 */{"gfx906", "gfx906", 4, 16, 1, 256, 64 * Ki, 32, 906}, - /* Vega20 XNACK */{"gfx907", "gfx907", 4, 16, 1, 256, 64 * Ki, 32, 907}, + /* Vega12 */{ "", "", 4, 16, 1, 256, 64 * Ki, 32, 904}, + /* Vega12 XNACK */{ "", "", 4, 16, 1, 256, 64 * Ki, 32, 905}, + /* Vega20 */{ "", "", 4, 16, 1, 256, 64 * Ki, 32, 906}, + /* Vega20 XNACK */{ "", "", 4, 16, 1, 256, 64 * Ki, 32, 907}, /* Raven */{"gfx902", "gfx902", 4, 16, 1, 256, 64 * Ki, 32, 902}, /* Raven XNACK */{"gfx903", "gfx903", 4, 16, 1, 256, 64 * Ki, 32, 903}, - /* Raven2 */{0}, - /* Raven2 XNACK */{0}, - /* Navi10 */{"gfx1000", "gfx1000", 4, 16, 1, 256, 64 * Ki, 32, 1000}, - /* Navi10 XNACK */{"gfx1001", "gfx1001", 4, 16, 1, 256, 64 * Ki, 32, 1001}, + /* Raven2 */{"" , "" , 0, 0 , 0, 0 , 0 , 0 , 0}, + /* Raven2 XNACK */{"" , "" , 0, 0 , 0, 0 , 0 , 0 , 0}, + /* Navi10 */{ "", "", 4, 16, 1, 256, 64 * Ki, 32, 1000}, + /* Navi10 XNACK */{ "", "", 4, 16, 1, 256, 64 * Ki, 32, 1001}, }; enum gfx_handle { diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp index 92833852b0..2b9c087534 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp +++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp @@ -62,6 +62,7 @@ NullDevice::NullDevice() bool NullDevice::init() { std::vector devices; + std::string driverVersion; devices = getDevices(CL_DEVICE_TYPE_GPU, false); @@ -74,11 +75,14 @@ bool NullDevice::init() { continue; } - // Loop through all active devices and see if we match one + // Loop through all active PAL devices and see if we match one for (uint i = 0; i < devices.size(); ++i) { - if (static_cast(devices[i])->asicRevision() == revision) { - foundActive = true; - break; + driverVersion = static_cast(devices[i])->info().driverVersion_; + if (driverVersion.find("PAL") != std::string::npos) { + if (static_cast(devices[i])->asicRevision() == revision) { + foundActive = true; + break; + } } } @@ -98,42 +102,89 @@ bool NullDevice::init() { } // Loop through all supported devices and create each of them - for (uint id = static_cast(Pal::GfxIpLevel::GfxIp7); - id <= static_cast(Pal::GfxIpLevel::GfxIp10); ++id) { - bool foundActive = false; - Pal::GfxIpLevel ipLevel = static_cast(id); + for (uint id = 0; + id < sizeof(Gfx9PlusSubDeviceInfo)/sizeof(AMDDeviceInfo); ++id) { + bool foundActive = false; + uint gfxipVersion = pal::Gfx9PlusSubDeviceInfo[id].gfxipVersion_; - if (pal::GfxIpDeviceInfo[id].targetName_[0] == '\0') { - continue; - } - - // Loop through all active devices and see if we match one - for (uint i = 0; i < devices.size(); ++i) { - if (static_cast(devices[i])->ipLevel() == ipLevel) { - foundActive = true; - break; + if (pal::Gfx9PlusSubDeviceInfo[id].targetName_[0] == '\0') { + continue; } - } - // Don't report an offline device if it's active - if (foundActive) { - continue; - } - - NullDevice* dev = new NullDevice(); - if (nullptr != dev) { - if (!dev->create(Pal::AsicRevision::Unknown, ipLevel)) { - delete dev; - } else { - dev->registerDevice(); + // Loop through all active PAL devices and see if we match one + for (uint i = 0; i < devices.size(); ++i) { + driverVersion = static_cast(devices[i])->info().driverVersion_; + if (driverVersion.find("PAL") != std::string::npos) { + if (static_cast(devices[i])->hwInfo()->gfxipVersion_ == + gfxipVersion) { + foundActive = true; + break; + } + } + } + + // Don't report an offline device if it's active + if (foundActive) { + continue; + } + + Pal::GfxIpLevel ipLevel = Pal::GfxIpLevel::_None; + uint ipLevelMajor = round(pal::Gfx9PlusSubDeviceInfo[id].gfxipVersion_ / 100); + switch (ipLevelMajor) { + case 9: + ipLevel = Pal::GfxIpLevel::GfxIp9; + break; + case 10: + ipLevel = Pal::GfxIpLevel::GfxIp10; + break; + } + + Pal::AsicRevision revision = Pal::AsicRevision::Unknown; + uint xNACKSupported = 0; + switch (pal::Gfx9PlusSubDeviceInfo[id].gfxipVersion_) { + case 901: + xNACKSupported = 1; + case 900: + revision = Pal::AsicRevision::Vega10; + break; + case 903: + xNACKSupported = 1; + case 902: + revision = Pal::AsicRevision::Raven; + break; + case 905: + xNACKSupported = 1; + case 904: + revision = Pal::AsicRevision::Vega12; + break; + case 907: + xNACKSupported = 1; + case 906: + revision = Pal::AsicRevision::Vega20; + break; + case 1001: + xNACKSupported = 1; + case 1000: + revision = Pal::AsicRevision::Navi10; + break; + } + + NullDevice* dev = new NullDevice(); + if (nullptr != dev) { + if (!dev->create(revision, ipLevel, xNACKSupported)) { + delete dev; + } + else { + dev->registerDevice(); + } } - } } return true; } -bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel) { +bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel, + uint xNACKSupported) { online_ = false; Pal::DeviceProperties properties = {}; @@ -142,12 +193,17 @@ bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel) ipLevel_ = ipLevel; properties.revision = asicRevision; properties.gfxLevel = ipLevel; + uint subtarget = 0; // Update HW info for the device if ((GPU_ENABLE_PAL == 1) && (ipLevel == Pal::GfxIpLevel::_None)) { hwInfo_ = &DeviceInfo[static_cast(asicRevision)]; } else if (ipLevel >= Pal::GfxIpLevel::GfxIp9) { - hwInfo_ = &GfxIpDeviceInfo[static_cast(ipLevel)]; + subtarget = (static_cast(asicRevision_) % + static_cast(Pal::AsicRevision::Vega10)) + << 1 | xNACKSupported; + hwInfo_ = &Gfx9PlusSubDeviceInfo[subtarget]; + } else { return false; } diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.hpp b/projects/clr/rocclr/runtime/device/pal/paldevice.hpp index 4e39628616..667bd01840 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldevice.hpp +++ b/projects/clr/rocclr/runtime/device/pal/paldevice.hpp @@ -44,8 +44,9 @@ class NullDevice : public amd::Device { //! Creates an offline device with the specified target bool create(Pal::AsicRevision asicRevision, //!< GPU ASIC revision - Pal::GfxIpLevel ipLevel //!< GPU ip level - ); + Pal::GfxIpLevel ipLevel, //!< GPU ip level + uint xNACKSupported = 0 //!< GPU xNACKSupported + ); virtual cl_int createSubDevices(device::CreateSubDevicesInfo& create_info, cl_uint num_entries, cl_device_id* devices, cl_uint* num_devices) {