summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2023-08-01 15:39:28 -0400
committerGitHub <noreply@github.com>2023-08-01 15:39:28 -0400
commit1653731718e75c297730dfb878e9f23895d1051d (patch)
tree76f05056594f9910e5baf464b05a41e48398fe18 /tests
parentedcc50cdcaf3743d4140b439375d0d40e3a941f7 (diff)
Fix literals needing cast (#3039)
* Cast integer literals. * Fix expected output. * For CUDA, search global instructions to see what types are used. Improve lookup for fp16 header in CUDA. * Fix issue with f16tof32 * Small improvement around finding used base types.
Diffstat (limited to 'tests')
-rw-r--r--tests/hlsl-intrinsic/asfloat16.slang25
-rw-r--r--tests/hlsl-intrinsic/asfloat16.slang.expected.txt9
2 files changed, 34 insertions, 0 deletions
diff --git a/tests/hlsl-intrinsic/asfloat16.slang b/tests/hlsl-intrinsic/asfloat16.slang
new file mode 100644
index 000000000..1c1e8a085
--- /dev/null
+++ b/tests/hlsl-intrinsic/asfloat16.slang
@@ -0,0 +1,25 @@
+// Float16 not supported on CPU currently
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-cpu -compute -output-using-type
+// Doesn't work on FXC
+//DISABLE_TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -output-using-type
+
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -dx12 -use-dxil -profile sm_6_2 -render-feature half -output-using-type
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -render-feature int16,half -output-using-type
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -render-features half -output-using-type
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(8, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ int idx = int(dispatchThreadID.x);
+
+ // 1
+ float16_t m = asfloat16(uint16_t(0x3c00));
+
+ float16_t v = asfloat16(uint16_t(0x3c00 + (idx << 8))) + m;
+ float f = v;
+
+ outputBuffer[idx] = f;
+} \ No newline at end of file
diff --git a/tests/hlsl-intrinsic/asfloat16.slang.expected.txt b/tests/hlsl-intrinsic/asfloat16.slang.expected.txt
new file mode 100644
index 000000000..a63c5c85a
--- /dev/null
+++ b/tests/hlsl-intrinsic/asfloat16.slang.expected.txt
@@ -0,0 +1,9 @@
+type: float
+2.000000
+2.250000
+2.500000
+2.750000
+3.000000
+3.500000
+4.000000
+4.500000