Skip to content

Commit

Permalink
Added cl_khr_fp16 extension support for test_decorate from spirv_new (#…
Browse files Browse the repository at this point in the history
…1770)

* Added cl_khr_fp16 extension support for test_decorate from spirv_new, work in progres

* Complemented test_decorate saturation test to support cl_khr_fp16 extension (issue #142)

* Fixed clang format

* scope of modifications:

-changed naming convention of saturation .spvasm files related to
test_decorate of spirv_new
-restored float to char/uchar saturation tests
-few minor corrections

* fix ranges for half testing

* fix formating

* one more formatting fix

* remove unused function

* use isnan instead of std::isnan

isnan is currently implemented as a macro, not as a function, so
we can't use std::isnan.

* fix Clang warning about inexact conversion

---------

Co-authored-by: Ben Ashbaugh <ben.ashbaugh@intel.com>
  • Loading branch information
shajder and bashbaug authored Feb 13, 2024
1 parent e187746 commit a4b5a30
Show file tree
Hide file tree
Showing 26 changed files with 771 additions and 120 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 20
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rte_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTE
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%1 = OpFunction %void None %14
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%15 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0
%16 = OpCompositeExtract %uint %15 0
%17 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %16
%18 = OpLoad %half %17 Aligned 2
%6 = OpConvertFToS %ushort %18
%19 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %16
OpStore %19 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 23
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Int64
OpCapability Int16
OpCapability Float16
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rte_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTE
%ulong = OpTypeInt 64 0
%v3ulong = OpTypeVector %ulong 3
%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%ulong_32 = OpConstant %ulong 32
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input
%1 = OpFunction %void None %14
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %ulong %16 0
%18 = OpShiftLeftLogical %ulong %17 %ulong_32
%19 = OpShiftRightArithmetic %ulong %18 %ulong_32
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19
%21 = OpLoad %half %20 Aligned 2
%6 = OpConvertFToS %ushort %21
%22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19
OpStore %22 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 21
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rtn_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTN
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%15 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%1 = OpFunction %void None %15
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %uint %16 0
%18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %17
%19 = OpLoad %half %18 Aligned 2
%6 = OpConvertFToS %ushort %19
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %17
OpStore %20 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 23
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Int64
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rtn_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTN
%ulong = OpTypeInt 64 0
%v3ulong = OpTypeVector %ulong 3
%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%ulong_32 = OpConstant %ulong 32
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input
%1 = OpFunction %void None %14
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %ulong %16 0
%18 = OpShiftLeftLogical %ulong %17 %ulong_32
%19 = OpShiftRightArithmetic %ulong %18 %ulong_32
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19
%21 = OpLoad %half %20 Aligned 2
%6 = OpConvertFToS %ushort %21
%22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19
OpStore %22 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 21
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rtp_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTP
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%15 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%1 = OpFunction %void None %15
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %uint %16 0
%18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %17
%19 = OpLoad %half %18 Aligned 2
%6 = OpConvertFToS %ushort %19
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %17
OpStore %20 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 23
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Int64
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rtp_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTP
%ulong = OpTypeInt 64 0
%v3ulong = OpTypeVector %ulong 3
%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%ulong_32 = OpConstant %ulong 32
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input
%1 = OpFunction %void None %14
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %ulong %16 0
%18 = OpShiftLeftLogical %ulong %17 %ulong_32
%19 = OpShiftRightArithmetic %ulong %18 %ulong_32
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19
%21 = OpLoad %half %20 Aligned 2
%6 = OpConvertFToS %ushort %21
%22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19
OpStore %22 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 21
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rtz_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTZ
%uint = OpTypeInt 32 0
%v3uint = OpTypeVector %uint 3
%_ptr_Input_v3uint = OpTypePointer Input %v3uint
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%15 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3uint Input
%1 = OpFunction %void None %15
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3uint %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %uint %16 0
%18 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %17
%19 = OpLoad %half %18 Aligned 2
%6 = OpConvertFToS %ushort %19
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %17
OpStore %20 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
; SPIR-V
; Version: 1.0
; Generator: Khronos SPIR-V Tools Assembler; 0
; Bound: 23
; Schema: 0
OpCapability Addresses
OpCapability Linkage
OpCapability Kernel
OpCapability Int64
OpCapability Float16
OpCapability Int16
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "decorate_rounding_rtz_half_short" %gl_GlobalInvocationID
OpName %res "res"
OpName %in "in"
OpName %entry "entry"
OpDecorate %gl_GlobalInvocationID BuiltIn GlobalInvocationId
OpDecorate %gl_GlobalInvocationID Constant
OpDecorate %gl_GlobalInvocationID LinkageAttributes "__spirv_GlobalInvocationId" Import
OpDecorate %6 FPRoundingMode RTZ
%ulong = OpTypeInt 64 0
%v3ulong = OpTypeVector %ulong 3
%_ptr_Input_v3ulong = OpTypePointer Input %v3ulong
%void = OpTypeVoid
%ushort = OpTypeInt 16 0
%_ptr_CrossWorkgroup_ushort = OpTypePointer CrossWorkgroup %ushort
%half = OpTypeFloat 16
%_ptr_CrossWorkgroup_half = OpTypePointer CrossWorkgroup %half
%14 = OpTypeFunction %void %_ptr_CrossWorkgroup_ushort %_ptr_CrossWorkgroup_half
%ulong_32 = OpConstant %ulong 32
%gl_GlobalInvocationID = OpVariable %_ptr_Input_v3ulong Input
%1 = OpFunction %void None %14
%res = OpFunctionParameter %_ptr_CrossWorkgroup_ushort
%in = OpFunctionParameter %_ptr_CrossWorkgroup_half
%entry = OpLabel
%16 = OpLoad %v3ulong %gl_GlobalInvocationID Aligned 0
%17 = OpCompositeExtract %ulong %16 0
%18 = OpShiftLeftLogical %ulong %17 %ulong_32
%19 = OpShiftRightArithmetic %ulong %18 %ulong_32
%20 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_half %in %19
%21 = OpLoad %half %20 Aligned 2
%6 = OpConvertFToS %ushort %21
%22 = OpInBoundsPtrAccessChain %_ptr_CrossWorkgroup_ushort %res %19
OpStore %22 %6
OpReturn
OpFunctionEnd
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
OpCapability Kernel
OpCapability Float64
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %1 "decorate_saturated_conversion_int" %gl_GlobalInvocationID
OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_int" %gl_GlobalInvocationID
OpName %res "res"
OpName %lhs "lhs"
OpName %rhs "rhs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
OpCapability Int64
OpCapability Float64
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "decorate_saturated_conversion_uint" %gl_GlobalInvocationID
OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_int" %gl_GlobalInvocationID
OpName %res "res"
OpName %lhs "lhs"
OpName %rhs "rhs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
OpCapability Kernel
OpCapability Float64
OpMemoryModel Physical32 OpenCL
OpEntryPoint Kernel %1 "decorate_saturated_conversion_uint" %gl_GlobalInvocationID
OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_uint" %gl_GlobalInvocationID
OpName %res "res"
OpName %lhs "lhs"
OpName %rhs "rhs"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
OpCapability Int64
OpCapability Float64
OpMemoryModel Physical64 OpenCL
OpEntryPoint Kernel %1 "decorate_saturated_conversion_int" %gl_GlobalInvocationID
OpEntryPoint Kernel %1 "decorate_saturated_conversion_double_to_uint" %gl_GlobalInvocationID
OpName %res "res"
OpName %lhs "lhs"
OpName %rhs "rhs"
Expand Down
Loading

0 comments on commit a4b5a30

Please sign in to comment.