From 5fc5595516fa84baef2873373f1fa5b438521299 Mon Sep 17 00:00:00 2001 From: foreman Date: Mon, 20 Aug 2018 18:48:00 -0400 Subject: [PATCH] P4 to Git Change 1596023 by skudchad@skudchad_test2_win_opencl on 2018/08/20 18:40:38 SWDEV-145570 - [HIP] Fixes to HIP env var logic ReviewBoardURL = http://ocltc.amd.com/reviews/r/15653/diff/ Affected files ... ... //depot/stg/opencl/drivers/opencl/api/hip/hip_device.cpp#16 edit ... //depot/stg/opencl/drivers/opencl/api/hip/hip_internal.hpp#15 edit ... //depot/stg/opencl/drivers/opencl/api/hip/hip_platform.cpp#18 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.cpp#225 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#311 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#105 edit ... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#96 edit [ROCm/clr commit: 26954707a4d01ec0a45587a2b763e2c1dfec26b4] --- projects/clr/rocclr/runtime/device/device.cpp | 2 -- projects/clr/rocclr/runtime/device/device.hpp | 8 ----- .../rocclr/runtime/device/pal/paldevice.cpp | 32 ++++++------------- .../rocclr/runtime/device/rocm/rocdevice.cpp | 22 +++++-------- 4 files changed, 18 insertions(+), 46 deletions(-) diff --git a/projects/clr/rocclr/runtime/device/device.cpp b/projects/clr/rocclr/runtime/device/device.cpp index bfb7e23bda..a40cd8c94d 100644 --- a/projects/clr/rocclr/runtime/device/device.cpp +++ b/projects/clr/rocclr/runtime/device/device.cpp @@ -224,8 +224,6 @@ Device::~Device() { } } -bool amd::Device::validOrdinal_ = true; - bool Device::create() { vaCacheAccess_ = new amd::Monitor("VA Cache Ops Lock", true); if (NULL == vaCacheAccess_) { diff --git a/projects/clr/rocclr/runtime/device/device.hpp b/projects/clr/rocclr/runtime/device/device.hpp index 58ffdc4b5f..3c1c8813b4 100644 --- a/projects/clr/rocclr/runtime/device/device.hpp +++ b/projects/clr/rocclr/runtime/device/device.hpp @@ -1591,13 +1591,6 @@ class Device : public RuntimeObject { // P2P devices that are accessible from the current device std::vector p2pDevices_; - //! Check for invalid ordinal passed via environment var - bool isOrdinalValid() { return validOrdinal_; } - - //! Write to validOrdinal_ - static void setvalidOrdinal(bool val) { validOrdinal_ = val; } - - protected: //! Enable the specified extension char* getExtensionString(); @@ -1608,7 +1601,6 @@ class Device : public RuntimeObject { BlitProgram* blitProgram_; //!< Blit program info static AppProfile appProfile_; //!< application profile HwDebugManager* hwDebugMgr_; //!< Hardware Debug manager - static bool validOrdinal_; //!< Valid Ordinal private: bool IsTypeMatching(cl_device_type type, bool offlineDevices); diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp index 1f050f8fdb..a60e1fabd5 100644 --- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp +++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp @@ -1092,13 +1092,9 @@ device::Program* Device::createProgram(amd::option::Options* options) { typedef std::unordered_map requestedDevices_t; //! Parses the requested list of devices to be exposed to the user. -static void parseRequestedDeviceList(requestedDevices_t& requestedDevices, +static void parseRequestedDeviceList(const char* requestedDeviceList, + requestedDevices_t& requestedDevices, uint32_t numDevices) { - int requestedDeviceCount = 0; - - const char* requestedDeviceList = IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ? - HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES) - : GPU_DEVICE_ORDINAL; char* pch = strtok(const_cast(requestedDeviceList), ","); while (pch != nullptr) { @@ -1118,18 +1114,12 @@ static void parseRequestedDeviceList(requestedDevices_t& requestedDevices, // Get next token. pch = strtok(nullptr, ","); - // FIXME Allow atleast one valid deviceId so compilation etc doesnt break - // but set validOrdinal_ flag - if (!deviceIdValid && (requestedDevices.size() != 0)) { + if (!deviceIdValid) { // Exit the loop as anything to the right of invalid deviceId - // has to be discarded unless its the first one + // has to be discarded break; } - if (!deviceIdValid && (requestedDevices.size() == 0)) { - Device::setvalidOrdinal(false); - } - // Requested device is valid. requestedDevices[currentDeviceIndex] = deviceIdValid; } @@ -1196,16 +1186,14 @@ bool Device::init() { uint ordinal = 0; const char* selectDeviceByName = nullptr; + const char* requestedDeviceList = IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ? + HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES) + : GPU_DEVICE_ORDINAL; - if (IS_HIP) { - if (HIP_VISIBLE_DEVICES[0] != '\0' || CUDA_VISIBLE_DEVICES[0] != '\0') { - useDeviceList = true; - parseRequestedDeviceList(requestedDevices, numDevices); - } - } else if (GPU_DEVICE_ORDINAL[0] != '\0') { + if (requestedDeviceList[0] != '\0') { useDeviceList = true; - parseRequestedDeviceList(requestedDevices, numDevices); - } else if (!flagIsDefault(GPU_DEVICE_NAME)) { + parseRequestedDeviceList(requestedDeviceList, requestedDevices, numDevices); + } else if (GPU_DEVICE_NAME[0] != '\0') { selectDeviceByName = GPU_DEVICE_NAME; } diff --git a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp index 9530aba59c..b578171c04 100644 --- a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp +++ b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp @@ -406,12 +406,11 @@ bool Device::init() { std::unordered_map selectedDevices; bool useDeviceList = false; - if ((GPU_DEVICE_ORDINAL != '\0') || (HIP_VISIBLE_DEVICES[0] != '\0') - || (CUDA_VISIBLE_DEVICES != '\0')) { + std::string ordinals = IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ? + HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES) + : GPU_DEVICE_ORDINAL; + if (ordinals[0] != '\0') { useDeviceList = true; - std::string ordinals = IS_HIP ? ((HIP_VISIBLE_DEVICES[0] != '\0') ? - HIP_VISIBLE_DEVICES : CUDA_VISIBLE_DEVICES) - : GPU_DEVICE_ORDINAL; size_t end, pos = 0; do { @@ -421,16 +420,11 @@ bool Device::init() { if (index < 0 || static_cast(index) >= gpu_agents_.size()) { deviceIdValid = false; } - // FIXME Allow atleast one valid deviceId so compilation etc doesnt break - // but set validOrdinal_ flag - if (!deviceIdValid && (selectedDevices.size() != 0)) { - // Exit the loop as anything to the right of invalid deviceId - // has to be discarded unless its the first one - break; - } - if (!deviceIdValid && (selectedDevices.size() == 0)) { - Device::setvalidOrdinal(false); + if (!deviceIdValid) { + // Exit the loop as anything to the right of invalid deviceId + // has to be discarded + break; } selectedDevices[index] = deviceIdValid;