diff --git a/external/SPIRV-Headers b/external/SPIRV-Headers index 69155b22..3469b164 160000 --- a/external/SPIRV-Headers +++ b/external/SPIRV-Headers @@ -1 +1 @@ -Subproject commit 69155b22b3b1f2d0cfed48f59167d9792de1fd79 +Subproject commit 3469b164e25cee24435029a569933cb42578db5d diff --git a/external/SPIRV-LLVM-Translator b/external/SPIRV-LLVM-Translator index 8cbf7263..34487407 160000 --- a/external/SPIRV-LLVM-Translator +++ b/external/SPIRV-LLVM-Translator @@ -1 +1 @@ -Subproject commit 8cbf72634d507560f968ed830da16250d96fe46e +Subproject commit 34487407835afc1a8b7ad277935bf950c5adecde diff --git a/external/SPIRV-Tools b/external/SPIRV-Tools index 1021ec30..f83f50d2 160000 --- a/external/SPIRV-Tools +++ b/external/SPIRV-Tools @@ -1 +1 @@ -Subproject commit 1021ec302f568cd83fee9f4eaa763dadb66e40b0 +Subproject commit f83f50d23ad576ffe3b89d4713601703950a7b7e diff --git a/external/clspv b/external/clspv index 161d2ff2..3cb074a5 160000 --- a/external/clspv +++ b/external/clspv @@ -1 +1 @@ -Subproject commit 161d2ff281429c33341dfd301b04d273d87e85a8 +Subproject commit 3cb074a5420695495f9d22fdc64c764ad2e153ae diff --git a/src/device.cpp b/src/device.cpp index 7c5121ae..04b412e1 100644 --- a/src/device.cpp +++ b/src/device.cpp @@ -13,6 +13,8 @@ // limitations under the License. #include +#include +#include #include "config.hpp" #include "device.hpp" @@ -47,6 +49,8 @@ void cvk_device::init_vulkan_properties(VkInstance instance) { VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_PCI_BUS_INFO_PROPERTIES_EXT; m_subgroup_properties.sType = VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_SUBGROUP_PROPERTIES; + m_float_controls_properties.sType = + VK_STRUCTURE_TYPE_PHYSICAL_DEVICE_FLOAT_CONTROLS_PROPERTIES; //--- Get maxMemoryAllocationSize for figuring out the max single buffer // allocation size and default init when the extension is not supported @@ -71,6 +75,8 @@ void cvk_device::init_vulkan_properties(VkInstance instance) { m_subgroup_properties), VER_EXT_PROP(VK_MAKE_VERSION(1, 1, 0), nullptr, m_maintenance3_properties), + VER_EXT_PROP(VK_MAKE_VERSION(1, 2, 0), nullptr, + m_float_controls_properties), }; #undef VER_EXT_PROP @@ -426,6 +432,28 @@ void cvk_device::init_compiler_options() { if (device_16bit_storage_features().storagePushConstant16 == VK_FALSE) { m_device_compiler_options += " -no-16bit-storage=pushconstant "; } + std::vector roundingModeRTE; + if (m_float_controls_properties.shaderRoundingModeRTEFloat16 && + supports_fp16()) { + roundingModeRTE.push_back("16"); + } + if (m_float_controls_properties.shaderRoundingModeRTEFloat32) { + roundingModeRTE.push_back("32"); + } + if (m_float_controls_properties.shaderRoundingModeRTEFloat64 && + supports_fp64()) { + roundingModeRTE.push_back("64"); + } + if (roundingModeRTE.size() > 0) { + m_device_compiler_options += " -rounding-mode-rte="; + for (unsigned i = 0; i < roundingModeRTE.size(); i++) { + if (i != 0) { + m_device_compiler_options += ","; + } + m_device_compiler_options += roundingModeRTE[i]; + } + m_device_compiler_options += " "; + } // Types support if (!supports_fp16()) { @@ -1038,6 +1066,10 @@ bool cvk_device::supports_capability(spv::Capability capability) const { return supports_non_uniform_decoration(); case spv::CapabilityPhysicalStorageBufferAddresses: return m_features_buffer_device_address.bufferDeviceAddress; + case spv::CapabilityRoundingModeRTE: + return m_float_controls_properties.shaderRoundingModeRTEFloat32 || + m_float_controls_properties.shaderRoundingModeRTEFloat16 || + m_float_controls_properties.shaderRoundingModeRTEFloat64; // Capabilities that have not yet been mapped to Vulkan features: default: cvk_warn_fn("Capability %d not yet mapped to a feature.", capability); diff --git a/src/device.hpp b/src/device.hpp index cb3c1971..2ef07b16 100644 --- a/src/device.hpp +++ b/src/device.hpp @@ -585,6 +585,7 @@ struct cvk_device : public _cl_device_id, m_features_vulkan_memory_model{}; VkPhysicalDeviceBufferDeviceAddressFeaturesKHR m_features_buffer_device_address{}; + VkPhysicalDeviceFloatControlsProperties m_float_controls_properties{}; VkDevice m_dev; std::vector m_vulkan_device_extensions;