From 8170a3f00375029ef0d949f6503364ff0915d00a Mon Sep 17 00:00:00 2001
From: foreman
Date: Thu, 19 Oct 2017 03:34:06 -0400
Subject: [PATCH] P4 to Git Change 1472384 by lmoriche@lmoriche_opencl_dev2 on
2017/10/19 03:29:10
SWDEV-126884 - OCL 2.1 Platform APIs
- Fix OCL/ROCm OpenCL C version
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpucompiler.cpp#157 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpudevice.cpp#578 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/gpu/gpuresource.cpp#240 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/paldevice.cpp#65 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#70 edit
... //depot/stg/opencl/drivers/opencl/runtime/runtimedefs#46 edit
[ROCm/clr commit: 46dcd95add09fc84b859dcfc0c4197f7c435ed55]
---
projects/clr/rocclr/runtime/device/gpu/gpucompiler.cpp | 1 +
projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp | 8 ++++----
projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp | 4 ++--
projects/clr/rocclr/runtime/device/pal/paldevice.cpp | 4 ++--
projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp | 5 +++--
5 files changed, 12 insertions(+), 10 deletions(-)
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpucompiler.cpp b/projects/clr/rocclr/runtime/device/gpu/gpucompiler.cpp
index 34276ee460..8485c2918c 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpucompiler.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpucompiler.cpp
@@ -138,6 +138,7 @@ bool NullProgram::compileImpl(const std::string& src,
opts << " -cl-std=CL1.1";
break;
case OpenCL20:
+ case OpenCL21:
default:
case OpenCL12:
opts << " -cl-std=CL1.2";
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp b/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp
index 0f33f541c2..627af8b70b 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpudevice.cpp
@@ -216,7 +216,7 @@ bool NullDevice::create(CALtarget target) {
compiler_ = aclCompilerInit(&opts, NULL);
}
- if (settings().hsail_ || (settings().oclVersion_ == OpenCL20)) {
+ 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);
@@ -487,7 +487,7 @@ void NullDevice::fillDeviceInfo(const CALdeviceattribs& calAttr, const gslMemInf
::snprintf(info_.driverVersion_, sizeof(info_.driverVersion_) - 1, AMD_BUILD_STRING);
info_.profile_ = "FULL_PROFILE";
- if (settings().oclVersion_ == OpenCL20) {
+ if (settings().oclVersion_ >= OpenCL20) {
info_.version_ = "OpenCL 2.0 " AMD_PLATFORM_INFO;
info_.oclcVersion_ = "OpenCL C 2.0 ";
info_.spirVersions_ = "1.2";
@@ -958,7 +958,7 @@ bool Device::create(CALuint ordinal, CALuint numOfDevices) {
compiler_ = aclCompilerInit(&opts, NULL);
}
- if (settings().hsail_ || (settings().oclVersion_ == OpenCL20)) {
+ if (settings().hsail_ || (settings().oclVersion_ >= OpenCL20)) {
if (NULL == hsaCompiler_) {
const char* library = getenv("HSA_COMPILER_LIBRARY");
aclCompilerOptions opts = {
@@ -1068,7 +1068,7 @@ bool Device::initializeHeapResources() {
if (settings().ciPlus_) {
const char* CL20extraBlits = NULL;
const char* ocl20 = NULL;
- if (settings().oclVersion_ == OpenCL20) {
+ if (settings().oclVersion_ >= OpenCL20) {
CL20extraBlits = SchedulerSourceCode;
ocl20 = "-cl-std=CL2.0";
}
diff --git a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp
index 21286f81ea..2111163edd 100644
--- a/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp
+++ b/projects/clr/rocclr/runtime/device/gpu/gpuresource.cpp
@@ -924,7 +924,7 @@ bool Resource::create(MemoryType memType, CreateParams* params) {
}
}
- if ((dev().settings().hsail_ || (dev().settings().oclVersion_ == OpenCL20)) && !cal()->buffer_) {
+ if ((dev().settings().hsail_ || (dev().settings().oclVersion_ >= OpenCL20)) && !cal()->buffer_) {
hwSrd_ = dev().srds().allocSrdSlot(reinterpret_cast(&hwState_));
if (0 == hwSrd_) {
return false;
@@ -1032,7 +1032,7 @@ void Resource::free() {
}
// Free SRD for images
- if ((dev().settings().hsail_ || (dev().settings().oclVersion_ == OpenCL20)) && !cal()->buffer_) {
+ if ((dev().settings().hsail_ || (dev().settings().oclVersion_ >= OpenCL20)) && !cal()->buffer_) {
dev().srds().freeSrdSlot(hwSrd_);
}
}
diff --git a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
index c31408cd15..179d0c5771 100644
--- a/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
+++ b/projects/clr/rocclr/runtime/device/pal/paldevice.cpp
@@ -439,7 +439,7 @@ void NullDevice::fillDeviceInfo(const Pal::DeviceProperties& palProp,
);
info_.profile_ = "FULL_PROFILE";
- if (settings().oclVersion_ == OpenCL20) {
+ if (settings().oclVersion_ >= OpenCL20) {
info_.version_ = "OpenCL 2.0 " AMD_PLATFORM_INFO;
info_.oclcVersion_ = "OpenCL C 2.0 ";
info_.spirVersions_ = "1.2";
@@ -2151,7 +2151,7 @@ bool Device::createBlitProgram() {
const char* ocl20 = nullptr;
#if !defined(WITH_LIGHTNING_COMPILER)
std::string sch = SchedulerSourceCode;
- if (settings().oclVersion_ == OpenCL20) {
+ if (settings().oclVersion_ >= OpenCL20) {
size_t loc = sch.find("%s");
sch.replace(loc, 2, iDev()->GetDispatchKernelSource());
scheduler = sch.c_str();
diff --git a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp
index e197ff959a..d5a3fcf538 100644
--- a/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp
+++ b/projects/clr/rocclr/runtime/device/rocm/rocdevice.cpp
@@ -37,6 +37,7 @@
#endif // WITHOUT_HSA_BACKEND
#define OPENCL_VERSION_STR XSTR(OPENCL_MAJOR) "." XSTR(OPENCL_MINOR)
+#define OPENCL_C_VERSION_STR XSTR(OPENCL_C_MAJOR) "." XSTR(OPENCL_C_MINOR)
#ifndef WITHOUT_HSA_BACKEND
namespace device {
@@ -111,7 +112,7 @@ bool NullDevice::create(const AMDDeviceInfo& deviceInfo) {
info_.extensions_ = getExtensionString();
info_.maxWorkGroupSize_ = hsaSettings->maxWorkGroupSize_;
::strcpy(info_.vendor_, "Advanced Micro Devices, Inc.");
- info_.oclcVersion_ = "OpenCL C " IF(IS_LIGHTNING, OPENCL_VERSION_STR, "1.2") " ";
+ info_.oclcVersion_ = "OpenCL C " IF(IS_LIGHTNING, OPENCL_C_VERSION_STR, "1.2") " ";
strcpy(info_.driverVersion_, "1.0 Provisional (hsa)");
info_.version_ = "OpenCL " OPENCL_VERSION_STR " ";
return true;
@@ -952,7 +953,7 @@ bool Device::populateOCLDeviceConstants() {
info_.addressBits_ = LP64_SWITCH(32, 64);
info_.maxSamplers_ = 16;
info_.bufferFromImageSupport_ = CL_FALSE;
- info_.oclcVersion_ = "OpenCL C " IF(IS_LIGHTNING, OPENCL_VERSION_STR, "1.2") " ";
+ info_.oclcVersion_ = "OpenCL C " IF(IS_LIGHTNING, OPENCL_C_VERSION_STR, "1.2") " ";
uint16_t major, minor;
if (hsa_agent_get_info(_bkendDevice, HSA_AGENT_INFO_VERSION_MAJOR, &major) !=