From fbb90f4504e59efc66012283e7b875db5a4e010e Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 8 Sep 2016 13:36:56 -0400
Subject: [PATCH] P4 to Git Change 1312342 by rili@rili-opencl-pal-stg on
2016/09/08 13:27:45
SWDEV-101790 - Cherry-pick CL#1293292 from 16.20.1010
Support DriverStore in OCL
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/device.hpp#278 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#554 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp#173 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gslbe/src/rt/backend.h#14 edit
---
rocclr/runtime/device/device.hpp | 2 +
rocclr/runtime/device/gpu/gpudevice.cpp | 67 +++++++++++++++----
.../device/gpu/gslbe/src/rt/GSLDevice.cpp | 3 +
.../runtime/device/gpu/gslbe/src/rt/backend.h | 2 +
4 files changed, 60 insertions(+), 14 deletions(-)
diff --git a/rocclr/runtime/device/device.hpp b/rocclr/runtime/device/device.hpp
index ee751be32d..4f322f3479 100644
--- a/rocclr/runtime/device/device.hpp
+++ b/rocclr/runtime/device/device.hpp
@@ -571,6 +571,8 @@ struct Info : public amd::EmbeddedObject
//! The maximum size of global scope variables
size_t maxGlobalVariableSize_;
size_t globalVariablePreferredTotalSize_;
+ //! Driver store location
+ char driverStore_[200];
};
//! Device settings
diff --git a/rocclr/runtime/device/gpu/gpudevice.cpp b/rocclr/runtime/device/gpu/gpudevice.cpp
index 5d72bcf6e6..99d71b1a08 100644
--- a/rocclr/runtime/device/gpu/gpudevice.cpp
+++ b/rocclr/runtime/device/gpu/gpudevice.cpp
@@ -178,6 +178,31 @@ NullDevice::create(CALtarget target)
// Fill the device info structure
fillDeviceInfo(calAttr, memInfo, 4096, 1, 0);
+ if (NULL == compiler_) {
+#if !defined(ATI_OS_LINUX)
+ char CompilerLibrary[220] = "";
+ strcpy_s(CompilerLibrary, calAttr.driverStore);
+ strcat_s(CompilerLibrary, "amdocl12cl" LP64_SWITCH("", "64") ".dll");
+#endif
+ const char *library = getenv("COMPILER_LIBRARY");
+ aclCompilerOptions opts = {
+ sizeof(aclCompilerOptions_0_8),
+#if defined(ATI_OS_LINUX)
+ library ? library : LINUX_ONLY("lib") "amdocl12cl" \
+ LP64_SWITCH(LINUX_SWITCH("32",""),"64") LINUX_SWITCH(".so",".dll"),
+#else
+ library ? library : CompilerLibrary,
+#endif
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ AMD_OCL_SC_LIB
+ };
+ compiler_ = aclCompilerInit(&opts, NULL);
+ }
+
if (settings().hsail_ || (settings().oclVersion_ == OpenCL20)) {
// Runtime doesn't know what local size could be on the real board
info_.maxGlobalVariableSize_ = static_cast(512 * Mi);
@@ -510,6 +535,7 @@ NullDevice::fillDeviceInfo(
info_.deviceTopology_.pcie.function = (calAttr.pciTopologyInformation&0x07);
::strncpy(info_.boardName_, calAttr.boardName, sizeof(info_.boardName_));
+ ::strncpy(info_.driverStore_, calAttr.driverStore, sizeof(info_.driverStore_));
// OpenCL1.2 device info fields
info_.builtInKernels_ = "";
@@ -936,6 +962,32 @@ Device::create(CALuint ordinal, CALuint numOfDevices)
static_cast(getMaxTextureSize()),
engines().numComputeRings(), engines().numComputeRingsRT());
+ if (NULL == compiler_) {
+#if !defined(ATI_OS_LINUX)
+ char CompilerLibrary[220] = "";
+ strcpy_s(CompilerLibrary, getAttribs().driverStore);
+ strcat_s(CompilerLibrary, "amdocl12cl" LP64_SWITCH("", "64") ".dll");
+#endif
+
+ const char *library = getenv("COMPILER_LIBRARY");
+ aclCompilerOptions opts = {
+ sizeof(aclCompilerOptions_0_8),
+#if defined(ATI_OS_LINUX)
+ library ? library : LINUX_ONLY("lib") "amdocl12cl" \
+ LP64_SWITCH(LINUX_SWITCH("32",""),"64") LINUX_SWITCH(".so",".dll"),
+#else
+ library ? library : CompilerLibrary,
+#endif
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ NULL,
+ AMD_OCL_SC_LIB
+ };
+ compiler_ = aclCompilerInit(&opts, NULL);
+ }
+
if (settings().hsail_ || (settings().oclVersion_ == OpenCL20)) {
if (NULL == hsaCompiler_) {
const char* library = getenv("HSA_COMPILER_LIBRARY");
@@ -1195,21 +1247,8 @@ Device::init()
bool useDeviceList = false;
requestedDevices_t requestedDevices;
- const char *library = getenv("COMPILER_LIBRARY");
- aclCompilerOptions opts = {
- sizeof(aclCompilerOptions_0_8),
- library ? library : LINUX_ONLY("lib") "amdocl12cl" \
- LP64_SWITCH(LINUX_SWITCH("32",""),"64") LINUX_SWITCH(".so",".dll"),
- NULL,
- NULL,
- NULL,
- NULL,
- NULL,
- AMD_OCL_SC_LIB
- };
-
hsaCompiler_ = NULL;
- compiler_ = aclCompilerInit(&opts, NULL);
+ compiler_ = NULL;
#if defined(_WIN32) && !defined(_WIN64)
// @toto: FIXME: remove this when CAL is fixed!!!
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
index 68994f1492..529a75fc9d 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/GSLDevice.cpp
@@ -108,6 +108,9 @@ CALGSLDevice::getAttribs_int(gsl::gsCtx* cs)
const uint8* boardName = cs->getString(GSL_GS_RENDERER);
::strncpy(m_attribs.boardName, (char*)boardName, CAL_ASIC_INFO_MAX_LEN * sizeof(char));
+ const uint8* driverStore = cs->getString(GSL_GS_DRIVER_STORE_PATH);
+ ::strncpy(m_attribs.driverStore, (char*)driverStore, CAL_DRIVER_STORE_MAX_LEN * sizeof(char));
+
m_attribs.counterFreq = cs->getCounterFreq();
m_attribs.nanoSecondsPerTick = 1000000000.0 / cs->getCounterFreq();
m_attribs.longIdleDetect = cs->getLongIdleDetect();
diff --git a/rocclr/runtime/device/gpu/gslbe/src/rt/backend.h b/rocclr/runtime/device/gpu/gslbe/src/rt/backend.h
index 84c9cfe3ca..183d7ae85b 100644
--- a/rocclr/runtime/device/gpu/gslbe/src/rt/backend.h
+++ b/rocclr/runtime/device/gpu/gslbe/src/rt/backend.h
@@ -47,6 +47,7 @@ typedef enum CALbooleanEnum {
typedef struct CALimageRec* CALimage;
#define CAL_ASIC_INFO_MAX_LEN 128
+#define CAL_DRIVER_STORE_MAX_LEN 200
/** CAL device attributes */
typedef struct CALdeviceattribsRec {
@@ -86,6 +87,7 @@ typedef struct CALdeviceattribsRec {
bool isWDDM2Enabled; /**< check if WDDM2 is enabled */
CALuint maxRTCUs; /**< The maximum number of RT CUs for RT queues */
CALuint asicRevision; /**< The ASIC revision ID */
+ CALchar driverStore[CAL_DRIVER_STORE_MAX_LEN];/**< Driver store location. */
} CALdeviceattribs;