summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2024-05-08 23:06:46 -0700
committerGitHub <noreply@github.com>2024-05-08 23:06:46 -0700
commitbf088c3f12cb47d204fdd3df1bb8a2415d46ba7b (patch)
tree82145968864a816ceba4c46619c3841b9a0befd4 /tests
parent526430a0e7053b04eeb9b0c6514065a850042aaf (diff)
Metal: propagate and specialize address space. (#4137)
Diffstat (limited to 'tests')
-rw-r--r--tests/metal/out-param.slang44
1 files changed, 44 insertions, 0 deletions
diff --git a/tests/metal/out-param.slang b/tests/metal/out-param.slang
new file mode 100644
index 000000000..f9e89165a
--- /dev/null
+++ b/tests/metal/out-param.slang
@@ -0,0 +1,44 @@
+//TEST:SIMPLE(filecheck=CHECK): -target metal
+//TEST:SIMPLE(filecheck=METALLIB): -target metallib
+
+// Test that we can specailize mutable parameters based on the argument
+// address space when generating code for Metal.
+
+//TEST_INPUT: ubuffer(data=[0 0 0 0], stride=4):out,name outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+
+// CHECK: void Test_out_param{{.*}}(int thread* value{{.*}})
+// CHECK: void Test_out_param{{.*}}(int device* value{{.*}})
+// CHECK: void Test_out_param{{.*}}(int threadgroup* value{{.*}})
+
+// CHECK: void Test_out_param_wrapper{{.*}}(int thread* value{{.*}})
+// CHECK: void Test_out_param_wrapper{{.*}}(int device* value{{.*}})
+// CHECK: void Test_out_param_wrapper{{.*}}(int threadgroup* value{{.*}})
+
+void Test_out_param(out int value)
+{
+ value = 1;
+}
+
+void Test_out_param_wrapper(out int value)
+{
+ Test_out_param(value);
+}
+
+[numthreads(1,1,1)]
+void computeMain()
+{
+ // METALLIB: define void @computeMain
+
+ int value = 0;
+ Test_out_param_wrapper(value);
+ outputBuffer[0] = value;
+
+ Test_out_param_wrapper(outputBuffer[1]);
+
+ static groupshared int sharedValue[2];
+ Test_out_param_wrapper(sharedValue[0]);
+ outputBuffer[2] = sharedValue[0];
+
+ outputBuffer[0]++;
+} \ No newline at end of file