From 3351b9c99324ca401fcdeb3f971ba1bfaf49318a Mon Sep 17 00:00:00 2001 From: Jason Tang Date: Fri, 13 Nov 2020 13:15:38 -0500 Subject: [PATCH] SWDEV-260632 - [PAL] Simplify NullDevice::init() Change-Id: I9d44162f38806e3742c18da48e382baafeb7060f --- rocclr/device/pal/paldefs.hpp | 5 -- rocclr/device/pal/paldevice.cpp | 97 ++++++--------------------------- rocclr/device/pal/paldevice.hpp | 5 +- 3 files changed, 20 insertions(+), 87 deletions(-) diff --git a/rocclr/device/pal/paldefs.hpp b/rocclr/device/pal/paldefs.hpp index c865b45252..9f3cbfda19 100644 --- a/rocclr/device/pal/paldefs.hpp +++ b/rocclr/device/pal/paldefs.hpp @@ -176,8 +176,6 @@ static constexpr AMDDeviceInfo DeviceInfo[] = { /* Lexa */ {"gfx804", "gfx803", 16, 256, 32, 803, 804, false}, }; -// Ordering as per AsicRevision# in palDevice.h & AMDGPU Target Names - static constexpr AMDDeviceInfo Gfx9PlusSubDeviceInfo[] = { /* Vega10 */ {"gfx900", "gfx900", 16, 256, 32, 900, 900, false, Pal::AsicRevision::Vega10}, /* Vega10 XNACK */ {"gfx901", "gfx900", 16, 256, 32, 900, 901, true, Pal::AsicRevision::Vega10}, @@ -198,11 +196,8 @@ static constexpr AMDDeviceInfo Gfx9PlusSubDeviceInfo[] = { /* Navi14 */ {"gfx1012", "gfx1012", 32, 256, 32, 1012, 1012, false, Pal::AsicRevision::Navi14}, /* Navi14 XNACK */ {"gfx1012", "gfx1012", 32, 256, 32, 1012, 1012, true, Pal::AsicRevision::Navi14}, /* Navi21 */ {"gfx1030", "gfx1030", 32, 256, 32, 1030, 1030, false, Pal::AsicRevision::Navi21}, - /* Navi21 XNACK */ UnknownDevice, /* Navi22 */ {"gfx1031", "gfx1031", 32, 256, 32, 1031, 1031, false, Pal::AsicRevision::Navi22}, - /* Navi22 XNACK */ UnknownDevice, /* Navi23 */ {"gfx1032", "gfx1032", 32, 256, 32, 1032, 1032, false, Pal::AsicRevision::Navi23}, - /* Navi23 XNACK */ UnknownDevice, }; // Supported OpenCL versions diff --git a/rocclr/device/pal/paldevice.cpp b/rocclr/device/pal/paldevice.cpp index d238f00d52..76b7ce7525 100644 --- a/rocclr/device/pal/paldevice.cpp +++ b/rocclr/device/pal/paldevice.cpp @@ -117,7 +117,7 @@ bool NullDevice::init() { NullDevice* dev = new NullDevice(); if (nullptr != dev) { - if (!dev->create(revision, Pal::GfxIpLevel::_None)) { + if (!dev->create(id, Pal::GfxIpLevel::_None)) { delete dev; } else { dev->registerDevice(); @@ -166,8 +166,10 @@ bool NullDevice::init() { if (pal::Gfx9PlusSubDeviceInfo[j].machineTarget_[0] == '\0') { continue; } - if (strcmp(pal::Gfx9PlusSubDeviceInfo[j].machineTarget_, - pal::Gfx9PlusSubDeviceInfo[id].machineTarget_) == 0) { + if ((strcmp(pal::Gfx9PlusSubDeviceInfo[j].machineTarget_, + pal::Gfx9PlusSubDeviceInfo[id].machineTarget_) == 0) && + (pal::Gfx9PlusSubDeviceInfo[j].xnackEnabled_ == + pal::Gfx9PlusSubDeviceInfo[id].xnackEnabled_)) { foundDuplicate = true; break; } @@ -222,67 +224,9 @@ bool NullDevice::init() { break; } - Pal::AsicRevision revision = Pal::AsicRevision::Unknown; - uint xNACKSupported = pal::Gfx9PlusSubDeviceInfo[id].xnackEnabled_ ? 1 : 0; - - switch (gfxipVersion) { - case 901: - case 900: - revision = Pal::AsicRevision::Vega10; - break; - case 903: - case 902: - revision = Pal::AsicRevision::Raven; - break; - case 905: - case 904: - revision = Pal::AsicRevision::Vega12; - break; - case 907: - case 906: - revision = Pal::AsicRevision::Vega20; - break; - case 1000: - ShouldNotReachHere(); - break; - case 1010: - revision = Pal::AsicRevision::Navi10; - break; - case 1011: - revision = Pal::AsicRevision::Navi12; - break; - case 1012: - revision = Pal::AsicRevision::Navi14; - break; - case 1020: - ShouldNotReachHere(); - break; - case 1030: - revision = Pal::AsicRevision::Navi21; - break; - case 1031: - revision = Pal::AsicRevision::Navi22; - break; - case 1032: - revision = Pal::AsicRevision::Navi23; - break; - case 1033: - ShouldNotReachHere(); - break; - case 1034: - ShouldNotReachHere(); - break; - case 1040: - ShouldNotReachHere(); - break; - case 1100: - ShouldNotReachHere(); - break; - } - NullDevice* dev = new NullDevice(); if (nullptr != dev) { - if (!dev->create(revision, ipLevel, xNACKSupported)) { + if (!dev->create(id, ipLevel)) { delete dev; } else { dev->registerDevice(); @@ -294,8 +238,18 @@ bool NullDevice::init() { } -bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel, - bool xNACKSupported) { +bool NullDevice::create(uint id, Pal::GfxIpLevel ipLevel) { + // Update HW info for the device + if ((GPU_ENABLE_PAL == 1) && (ipLevel == Pal::GfxIpLevel::_None)) { + hwInfo_ = &DeviceInfo[id]; + } else if (ipLevel >= Pal::GfxIpLevel::GfxIp9) { + hwInfo_ = &Gfx9PlusSubDeviceInfo[id]; + } else { + return false; + } + + Pal::AsicRevision asicRevision = hwInfo_->asicRevision_; + if (amd::IS_HIP && IS_MAINLINE && (asicRevision != Pal::AsicRevision::Vega20)) { return false; @@ -311,21 +265,6 @@ bool NullDevice::create(Pal::AsicRevision asicRevision, Pal::GfxIpLevel ipLevel, 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) { - for (uint id = 0; id < sizeof(Gfx9PlusSubDeviceInfo) / sizeof(AMDDeviceInfo); ++id) { - if ((Gfx9PlusSubDeviceInfo[id].asicRevision_ == asicRevision_) && - (Gfx9PlusSubDeviceInfo[id].xnackEnabled_ == xNACKSupported)) { - hwInfo_ = &Gfx9PlusSubDeviceInfo[id]; - break; - } - } - } else { - return false; - } - settings_ = new pal::Settings(); pal::Settings* palSettings = reinterpret_cast(settings_); diff --git a/rocclr/device/pal/paldevice.hpp b/rocclr/device/pal/paldevice.hpp index a602467b94..915250e5ef 100644 --- a/rocclr/device/pal/paldevice.hpp +++ b/rocclr/device/pal/paldevice.hpp @@ -64,9 +64,8 @@ class NullDevice : public amd::Device { NullDevice(); //! Creates an offline device with the specified target - bool create(Pal::AsicRevision asicRevision, //!< GPU ASIC revision - Pal::GfxIpLevel ipLevel, //!< GPU ip level - bool xNACKSupported = false //!< GPU xNACKSupported + bool create(uint id, //!< index in the AMDDeviceInfo[] + Pal::GfxIpLevel ipLevel //!< GPU ip level ); //! Instantiate a new virtual device