From c7e04f3222c1884dedad47f90be8f5af3e656e9d Mon Sep 17 00:00:00 2001
From: foreman
Date: Wed, 12 Apr 2017 19:14:23 -0500
Subject: [PATCH] P4 to Git Change 1397729 by kzhuravl@kzhuravl-fiji-ocllc on
2017/04/12 20:05:08
SWDEV-116535 - Report CL_FP_DENORM for single fp config for gfx9 for LC for rocm/pal and force denorms on based on AMD_GPU_FORCE_SINGLE_FP_DENORM for rocm.
Affected files ...
... //depot/stg/opencl/drivers/opencl/runtime/device/pal/palsettings.cpp#23 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocdevice.cpp#47 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocprogram.cpp#62 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.cpp#16 edit
... //depot/stg/opencl/drivers/opencl/runtime/device/rocm/rocsettings.hpp#7 edit
---
rocclr/runtime/device/pal/palsettings.cpp | 8 +++++++
rocclr/runtime/device/rocm/rocdevice.cpp | 9 ++++++--
rocclr/runtime/device/rocm/rocprogram.cpp | 3 ++-
rocclr/runtime/device/rocm/rocsettings.cpp | 26 +++++++++++++++++++++-
rocclr/runtime/device/rocm/rocsettings.hpp | 5 +++--
5 files changed, 45 insertions(+), 6 deletions(-)
diff --git a/rocclr/runtime/device/pal/palsettings.cpp b/rocclr/runtime/device/pal/palsettings.cpp
index 43e11aac09..bc6cbd06ad 100644
--- a/rocclr/runtime/device/pal/palsettings.cpp
+++ b/rocclr/runtime/device/pal/palsettings.cpp
@@ -414,6 +414,14 @@ Settings::create(
resourceCacheSize_ = std::min(resourceCacheSize_, 512 * Mi);
#endif
+#if defined(WITH_LIGHTNING_COMPILER)
+ switch (palProp.gfxLevel) {
+ case Pal::GfxIpLevel::GfxIp9:
+ singleFpDenorm_ = true;
+ break;
+ }
+#endif // WITH_LIGHTNING_COMPILER
+
// Override current device settings
override();
diff --git a/rocclr/runtime/device/rocm/rocdevice.cpp b/rocclr/runtime/device/rocm/rocdevice.cpp
index 27d7016f69..a1bad09ec9 100644
--- a/rocclr/runtime/device/rocm/rocdevice.cpp
+++ b/rocclr/runtime/device/rocm/rocdevice.cpp
@@ -99,7 +99,7 @@ bool NullDevice::create(const AMDDeviceInfo& deviceInfo) {
settings_ = new Settings();
roc::Settings* hsaSettings = static_cast(settings_);
- if ((hsaSettings == nullptr) || !hsaSettings->create(false)) {
+ if ((hsaSettings == nullptr) || !hsaSettings->create(false, deviceInfo_.gfxipVersion_)) {
LogError("Error creating settings for nullptr HSA device");
return false;
}
@@ -618,7 +618,7 @@ Device::mapHSADeviceToOpenCLDevice(hsa_agent_t dev)
settings_ = new Settings();
roc::Settings* hsaSettings = static_cast(settings_);
if ((hsaSettings == nullptr) ||
- !hsaSettings->create((agent_profile_ == HSA_PROFILE_FULL))) {
+ !hsaSettings->create((agent_profile_ == HSA_PROFILE_FULL), deviceInfo_.gfxipVersion_)) {
return false;
}
@@ -978,6 +978,11 @@ Device::populateOCLDeviceConstants()
info_.doubleFPConfig_ = info_.singleFPConfig_ | CL_FP_DENORM;
info_.singleFPConfig_ |= CL_FP_CORRECTLY_ROUNDED_DIVIDE_SQRT;
}
+
+ if (hsa_settings->singleFpDenorm_) {
+ info_.singleFPConfig_ |= CL_FP_DENORM;
+ }
+
info_.preferredPlatformAtomicAlignment_ = 0;
info_.preferredGlobalAtomicAlignment_ = 0;
info_.preferredLocalAtomicAlignment_ = 0;
diff --git a/rocclr/runtime/device/rocm/rocprogram.cpp b/rocclr/runtime/device/rocm/rocprogram.cpp
index ea6c1d0319..48e49c4cea 100644
--- a/rocclr/runtime/device/rocm/rocprogram.cpp
+++ b/rocclr/runtime/device/rocm/rocprogram.cpp
@@ -1397,7 +1397,8 @@ HSAILProgram::codegenOptions(amd::option::Options* options)
std::string optionsStr;
#if !defined(WITH_LIGHTNING_COMPILER)
- if (dev().deviceInfo().gfxipVersion_ < 900) {
+ if (dev().deviceInfo().gfxipVersion_ < 900 ||
+ !dev().settings().singleFpDenorm_) {
optionsStr.append(" -cl-denorms-are-zero");
}
#endif // !defined(WITH_LIGHTNING_COMPILER)
diff --git a/rocclr/runtime/device/rocm/rocsettings.cpp b/rocclr/runtime/device/rocm/rocsettings.cpp
index 98e585ce5e..07d36ca733 100644
--- a/rocclr/runtime/device/rocm/rocsettings.cpp
+++ b/rocclr/runtime/device/rocm/rocsettings.cpp
@@ -68,10 +68,13 @@ Settings::Settings()
const static size_t MaxPinnedXferSize = 32;
pinnedXferSize_ = std::min(GPU_PINNED_XFER_SIZE, MaxPinnedXferSize) * Mi;
pinnedMinXferSize_ = std::min(GPU_PINNED_MIN_XFER_SIZE * Ki, pinnedXferSize_);
+
+ // Don't support Denormals for single precision by default
+ singleFpDenorm_ = false;
}
bool
-Settings::create(bool fullProfile)
+Settings::create(bool fullProfile, int gfxipVersion)
{
customHostAllocator_ = false;
@@ -111,6 +114,14 @@ Settings::create(bool fullProfile)
enableExtension(ClKhrDepthImages);
supportDepthsRGB_ = true;
+#if defined(WITH_LIGHTNING_COMPILER)
+ switch (gfxipVersion) {
+ case 900:
+ singleFpDenorm_ = true;
+ break;
+ }
+#endif // WITH_LIGHTNING_COMPILER
+
// Override current device settings
override();
@@ -140,6 +151,19 @@ Settings::override()
if (!flagIsDefault(GPU_PINNED_MIN_XFER_SIZE)) {
pinnedMinXferSize_ = std::min(GPU_PINNED_MIN_XFER_SIZE * Ki, pinnedXferSize_);
}
+
+ if (!flagIsDefault(AMD_GPU_FORCE_SINGLE_FP_DENORM)) {
+ switch (AMD_GPU_FORCE_SINGLE_FP_DENORM) {
+ case 0:
+ singleFpDenorm_ = false;
+ break;
+ case 1:
+ singleFpDenorm_ = true;
+ break;
+ default:
+ break;
+ }
+ }
}
} // namespace roc
diff --git a/rocclr/runtime/device/rocm/rocsettings.hpp b/rocclr/runtime/device/rocm/rocsettings.hpp
index 4e1f9400f8..40f0e75dfa 100644
--- a/rocclr/runtime/device/rocm/rocsettings.hpp
+++ b/rocclr/runtime/device/rocm/rocsettings.hpp
@@ -29,7 +29,8 @@ public:
uint imageDMA_: 1; //!< Enable direct image DMA transfers
uint stagedXferRead_: 1; //!< Uses a staged buffer read
uint stagedXferWrite_: 1; //!< Uses a staged buffer write
- uint reserved_: 22;
+ uint singleFpDenorm_: 1; //!< Support Single FP Denorm
+ uint reserved_: 21;
};
uint value_;
};
@@ -58,7 +59,7 @@ public:
Settings();
//! Creates settings
- bool create(bool fullProfile);
+ bool create(bool fullProfile, int gfxipVersion);
private:
//! Disable copy constructor