Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for roundingmoderte capability #563

Merged
merged 4 commits into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion external/SPIRV-LLVM-Translator
Submodule SPIRV-LLVM-Translator updated 76 files
+2 −1 .github/workflows/check-code-style.yml
+13 −2 CMakeLists.txt
+97 −16 lib/SPIRV/LLVMToSPIRVDbgTran.cpp
+7 −0 lib/SPIRV/LLVMToSPIRVDbgTran.h
+3 −1 lib/SPIRV/SPIRVLowerMemmove.cpp
+11 −4 lib/SPIRV/SPIRVReader.cpp
+152 −34 lib/SPIRV/SPIRVToLLVMDbgTran.cpp
+10 −2 lib/SPIRV/SPIRVToLLVMDbgTran.h
+4 −3 lib/SPIRV/SPIRVTypeScavenger.cpp
+8 −0 lib/SPIRV/SPIRVUtil.cpp
+29 −17 lib/SPIRV/SPIRVWriter.cpp
+86 −30 lib/SPIRV/libSPIRV/SPIRV.debug.h
+41 −3 lib/SPIRV/libSPIRV/SPIRVEntry.cpp
+4 −0 lib/SPIRV/libSPIRV/SPIRVEntry.h
+2 −0 lib/SPIRV/libSPIRV/SPIRVExtInst.h
+13 −1 lib/SPIRV/libSPIRV/SPIRVFunction.cpp
+73 −3 lib/SPIRV/libSPIRV/SPIRVModule.cpp
+10 −0 lib/SPIRV/libSPIRV/SPIRVModule.h
+12 −0 lib/SPIRV/libSPIRV/SPIRVStream.cpp
+3 −3 test/AtomicCompareExchange_cl20.ll
+2 −0 test/DebugInfo/DebugInfoProducer.ll
+61 −0 test/DebugInfo/DebugInfoTypeBasic.ll
+83 −0 test/DebugInfo/DebugInfoTypeInheritance.ll
+1 −1 test/DebugInfo/Generic/c-and-cpp-mixed.ll
+3 −5 test/DebugInfo/Generic/imported-name-inlined.ll
+11 −4 test/DebugInfo/Generic/inlined-locations.ll
+4 −0 test/DebugInfo/NonSemantic/DebugInfoProducer.ll
+37 −6 test/DebugInfo/NonSemantic/Shader200/DebugInfoStringType.ll
+26 −4 test/DebugInfo/NonSemantic/Shader200/DebugInfoSubrange.ll
+20 −1 test/DebugInfo/NonSemantic/Shader200/DebugInfoTargetFunction.ll
+89 −0 test/DebugInfo/NonSemantic/Shader200/DebugLinePriority.spt
+4 −1 test/DebugInfo/NonSemantic/Shader200/FortranArray.ll
+2 −2 test/DebugInfo/NonSemantic/Shader200/storagePath_dwo.ll
+80 −0 test/DebugInfo/NonSemantic/static_member_array.ll
+1 −1 test/DebugInfo/OpenCL100/DebugInfoSubrange.ll
+0 −4 test/DebugInfo/X86/lexical-block-file-inline.ll
+1 −1 test/DebugInfo/X86/split-dwarf-omit-empty.ll
+142 −0 test/DebugInfo/bitfields_packed.ll
+12 −14 test/complex-constexpr.ll
+3 −3 ...sions/INTEL/SPV_INTEL_arbitrary_precision_fixed_point/capability-arbitrary-precision-fixed-point-numbers.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_device_side_avc_motion_esimation/subgroup_avc_intel_generic.cl
+2 −2 test/extensions/INTEL/SPV_INTEL_device_side_avc_motion_esimation/subgroup_avc_intel_vme_image.cl
+22 −0 test/extensions/INTEL/SPV_INTEL_fpga_buffer_location/FPGABufferLocation.ll
+12 −7 test/extensions/INTEL/SPV_INTEL_fpga_memory_accesses/IntelFPGAMemoryAccesses.ll
+28 −20 test/extensions/INTEL/SPV_INTEL_fpga_memory_accesses/intel_fpga_lsu_optimized.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_fpga_memory_attributes/IntelFPGAMemoryAttributes.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_fpga_memory_attributes/IntelFPGAMemoryAttributesForStruct.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_fpga_reg/IntelFPGAReg.ll
+11 −8 test/extensions/INTEL/SPV_INTEL_function_pointers/bitcast.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_function_pointers/const-function-pointer.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_function_pointers/decor-func-ptr-arg-attr.ll
+3 −4 test/extensions/INTEL/SPV_INTEL_function_pointers/function-pointer-as-function-arg.ll
+3 −3 test/extensions/INTEL/SPV_INTEL_function_pointers/function-pointer.ll
+3 −3 test/extensions/INTEL/SPV_INTEL_function_pointers/global-function-pointer.ll
+3 −4 test/extensions/INTEL/SPV_INTEL_function_pointers/non-uniform-function-pointer.ll
+3 −3 test/extensions/INTEL/SPV_INTEL_function_pointers/referenced-indirectly.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_function_pointers/select.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_inline_assembly/inline_asm_clobbers.cl
+3 −3 test/extensions/INTEL/SPV_INTEL_usm_storage_classes/intel_usm_addrspaces.ll
+2 −2 test/extensions/INTEL/SPV_INTEL_variable_length_array/complex-cfg.ll
+45 −0 test/extensions/KHR/SPV_KHR_integer_dot_product/SPV_KHR_integer_dot_product-nonsat.ll
+45 −0 test/extensions/KHR/SPV_KHR_integer_dot_product/SPV_KHR_integer_dot_product-sat.ll
+23 −0 test/extensions/KHR/SPV_KHR_non_semantic_info/preserve-all-function-attributes-crash.ll
+6 −1 test/extensions/KHR/SPV_KHR_non_semantic_info/preserve-all-function-metadata.ll
+2 −2 test/image-unoptimized.cl
+9 −10 test/layout.ll
+12 −12 test/transcoding/AtomicCompareExchange_cl20.ll
+19 −25 test/transcoding/GenericCastToPtr.cl
+7 −7 test/transcoding/KernelArgTypeInOpString.ll
+3 −3 test/transcoding/OpImageSampleExplicitLod_arg.cl
+3 −3 test/transcoding/SampledImage.cl
+5 −5 test/transcoding/annotate_attribute.ll
+2 −2 test/transcoding/builtin_vars_gep.ll
+4 −4 test/transcoding/enqueue_marker.cl
+3 −3 test/transcoding/memory_access.ll
+8 −15 test/transcoding/spirv-private-array-initialization.ll
2 changes: 1 addition & 1 deletion external/SPIRV-Tools
Submodule SPIRV-Tools updated 90 files
+4 −0 .bazelrc
+5 −13 .github/workflows/bazel.yml
+2 −2 Android.mk
+12 −11 BUILD.bazel
+5 −3 CMakeLists.txt
+4 −4 DEPS
+2 −8 README.md
+13 −0 WORKSPACE
+1 −1 android_test/Android.mk
+1 −1 android_test/jni/Application.mk
+6 −6 build_defs.bzl
+10 −9 external/CMakeLists.txt
+5 −12 include/spirv-tools/instrument.hpp
+7 −0 include/spirv-tools/libspirv.h
+20 −10 include/spirv-tools/optimizer.hpp
+2 −1 kokoro/scripts/linux/build-docker.sh
+13 −4 kokoro/scripts/windows/build.bat
+9 −9 source/CMakeLists.txt
+3 −2 source/assembly_grammar.cpp
+5 −1 source/binary.cpp
+123 −31 source/diff/diff.cpp
+2 −0 source/opcode.cpp
+11 −0 source/operand.cpp
+106 −19 source/opt/const_folding_rules.cpp
+27 −0 source/opt/constants.cpp
+6 −0 source/opt/constants.h
+58 −15 source/opt/fold.cpp
+8 −0 source/opt/fold.h
+238 −463 source/opt/inst_bindless_check_pass.cpp
+11 −96 source/opt/inst_bindless_check_pass.h
+16 −48 source/opt/inst_buff_addr_check_pass.cpp
+0 −4 source/opt/inst_buff_addr_check_pass.h
+4 −2 source/opt/inst_debug_printf_pass.cpp
+25 −3 source/opt/instruction.cpp
+10 −0 source/opt/instruction.h
+92 −115 source/opt/instrument_pass.cpp
+5 −28 source/opt/instrument_pass.h
+16 −0 source/opt/ir_builder.h
+37 −40 source/opt/optimizer.cpp
+31 −0 source/opt/type_manager.cpp
+5 −6 source/opt/type_manager.h
+42 −0 source/opt/types.cpp
+35 −0 source/opt/types.h
+2 −1 source/text.cpp
+143 −10 source/val/validate_arithmetics.cpp
+20 −0 source/val/validate_composites.cpp
+2 −0 source/val/validate_constants.cpp
+16 −2 source/val/validate_conversion.cpp
+58 −23 source/val/validate_decorations.cpp
+10 −4 source/val/validate_id.cpp
+0 −1 source/val/validate_image.cpp
+25 −6 source/val/validate_interfaces.cpp
+128 −4 source/val/validate_memory.cpp
+20 −7 source/val/validate_type.cpp
+68 −7 source/val/validation_state.cpp
+5 −0 source/val/validation_state.h
+1 −1 source/wasm/build.sh
+2 −4 test/diff/diff_files/OpExtInst_in_src_only_autogen.cpp
+5 −5 test/diff/diff_files/basic_autogen.cpp
+2 −2 test/diff/diff_files/constant_array_size_autogen.cpp
+1 −0 test/diff/diff_files/diff_test_files_autogen.cmake
+17 −27 test/diff/diff_files/different_decorations_fragment_autogen.cpp
+32 −39 test/diff/diff_files/different_decorations_vertex_autogen.cpp
+16 −18 test/diff/diff_files/different_function_parameter_count_autogen.cpp
+34 −34 test/diff/diff_files/extra_if_block_autogen.cpp
+3 −3 test/diff/diff_files/int_vs_uint_constants_autogen.cpp
+148 −0 test/diff/diff_files/ray_query_types_autogen.cpp
+18 −0 test/diff/diff_files/ray_query_types_dst.spvasm
+16 −0 test/diff/diff_files/ray_query_types_src.spvasm
+2 −4 test/diff/diff_files/reordered_if_blocks_autogen.cpp
+2 −4 test/diff/diff_files/reordered_switch_blocks_autogen.cpp
+10 −10 test/diff/diff_files/spec_constant_array_size_autogen.cpp
+239 −21 test/opt/fold_test.cpp
+851 −1,257 test/opt/inst_bindless_check_test.cpp
+393 −140 test/opt/inst_buff_addr_check_test.cpp
+59 −50 test/opt/inst_debug_printf_test.cpp
+12 −0 test/opt/type_manager_test.cpp
+2 −2 test/tools/CMakeLists.txt
+2 −2 test/tools/opt/CMakeLists.txt
+144 −4 test/val/val_arithmetics_test.cpp
+82 −4 test/val/val_composites_test.cpp
+174 −2 test/val/val_conversion_test.cpp
+118 −0 test/val/val_decoration_test.cpp
+20 −1 test/val/val_id_test.cpp
+0 −2 test/val/val_image_test.cpp
+52 −0 test/val/val_interfaces_test.cpp
+191 −9 test/val/val_memory_test.cpp
+5 −5 tools/sva/package.json
+954 −1,258 tools/sva/yarn.lock
+1 −1 utils/generate_grammar_tables.py
32 changes: 32 additions & 0 deletions src/device.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,8 @@
// limitations under the License.

#include <fstream>
#include <iterator>
#include <sstream>

#include "config.hpp"
#include "device.hpp"
Expand Down Expand Up @@ -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
Expand All @@ -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

Expand Down Expand Up @@ -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<std::string> 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()) {
Expand Down Expand Up @@ -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);
Expand Down
1 change: 1 addition & 0 deletions src/device.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<const char*> m_vulkan_device_extensions;
Expand Down