From 188c4e9bd7a618ffe26cd4f93f32f566cdf71e5e 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
---
hipamd/api/hip/hip_device.cpp | 4 +---
hipamd/api/hip/hip_internal.hpp | 7 +++----
hipamd/api/hip/hip_platform.cpp | 3 +++
3 files changed, 7 insertions(+), 7 deletions(-)
diff --git a/hipamd/api/hip/hip_device.cpp b/hipamd/api/hip/hip_device.cpp
index 4da7e42f4c..30ad2f3af1 100644
--- a/hipamd/api/hip/hip_device.cpp
+++ b/hipamd/api/hip/hip_device.cpp
@@ -96,10 +96,8 @@ hipError_t ihipDeviceGetCount(int* count) {
return hipErrorInvalidValue;
}
- auto* deviceHandle = g_devices[0]->devices()[0];
-
// Get all available devices
- *count = deviceHandle->isOrdinalValid() ? g_devices.size() : 0;
+ *count = g_devices.size();
return hipSuccess;
}
diff --git a/hipamd/api/hip/hip_internal.hpp b/hipamd/api/hip/hip_internal.hpp
index 472051a379..325f0b7cd3 100644
--- a/hipamd/api/hip/hip_internal.hpp
+++ b/hipamd/api/hip/hip_internal.hpp
@@ -29,10 +29,9 @@ THE SOFTWARE.
#include
#define HIP_INIT() \
- std::call_once(hip::g_ihipInitialized, hip::init); \
- assert(g_devices.size() > 0); \
- if (hip::g_context == nullptr) { \
- hip::g_context = g_devices[0]; \
+ std::call_once(hip::g_ihipInitialized, hip::init); \
+ if (hip::g_context == nullptr && g_devices.size() > 0) { \
+ hip::g_context = g_devices[0]; \
}
// This macro should be called at the beginning of every HIP API.
diff --git a/hipamd/api/hip/hip_platform.cpp b/hipamd/api/hip/hip_platform.cpp
index 2adf74f7ce..ba0d50865d 100644
--- a/hipamd/api/hip/hip_platform.cpp
+++ b/hipamd/api/hip/hip_platform.cpp
@@ -59,6 +59,9 @@ extern "C" hipModule_t __hipRegisterFatBinary(const void* data)
{
HIP_INIT();
+ if(g_devices.empty()) {
+ return nullptr;
+ }
const __CudaFatBinaryWrapper* fbwrapper = reinterpret_cast(data);
if (fbwrapper->magic != __hipFatMAGIC2 || fbwrapper->version != 1) {
return nullptr;