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