summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-04-23 11:32:07 -0400
committerGitHub <noreply@github.com>2021-04-23 11:32:07 -0400
commit79e722338cd59aab74b4c57600c5ac6bce3bcd25 (patch)
treeaf77066235c4038bd15c6297ef4f48d3e562171d /tests
parenta47e7751c2738543e872452debc7494369c9fb35 (diff)
Preliminary CUDA Half support (#1808)
* #include an absolute path didn't work - because paths were taken to always be relative. * WIP CUDA half support. * Working support for half on CUDA - requires cuda_fp16.h and associated files can be found. * Fix for win32 for unused funcs. * Fix for Clang. * Hack to disable unused local function warning.
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/half-opaque-convert.slang28
-rw-r--r--tests/compute/half-opaque-convert.slang.expected.txt4
2 files changed, 32 insertions, 0 deletions
diff --git a/tests/compute/half-opaque-convert.slang b/tests/compute/half-opaque-convert.slang
new file mode 100644
index 000000000..caf1f47e6
--- /dev/null
+++ b/tests/compute/half-opaque-convert.slang
@@ -0,0 +1,28 @@
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-dx12 -compute -use-dxil -profile cs_6_2 -render-features half -shaderobj
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-vk -compute -profile cs_6_2 -render-features half -shaderobj
+//TEST(compute):COMPARE_COMPUTE:-cuda -compute -render-features half -shaderobj
+
+//DISABLE_TEST(compute):SIMPLE:-target ptx -stage compute -entry computeMain
+
+// The following test shows if half can be processed as an opaque type. This means
+// it can be copied, and converted to and from float types, but nothing else.
+// No maths, no swizzling.
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<float> outputBuffer;
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+
+ float a = (1.0f / 2.0f) * tid.x;
+
+ // Convert into half
+ half ha = f32tof16_(a);
+ // Convert back to float
+ float fa = f16tof32(ha);
+
+ // Write it out
+ outputBuffer[tid] = fa;
+} \ No newline at end of file
diff --git a/tests/compute/half-opaque-convert.slang.expected.txt b/tests/compute/half-opaque-convert.slang.expected.txt
new file mode 100644
index 000000000..12bb9a952
--- /dev/null
+++ b/tests/compute/half-opaque-convert.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+3F000000
+3F800000
+3FC00000