summaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2020-08-14 10:04:32 -0700
committerGitHub <noreply@github.com>2020-08-14 10:04:32 -0700
commitb37a7770d9781515f70047665d12680a5838406d (patch)
tree19b322499f920c23a868bd0db2e54a628d76a41d /tests
parent99366e7c37e8b537b4eac8f3104db7296ceba586 (diff)
Lower existential types. (#1497)
Co-authored-by: Tim Foley <tfoleyNV@users.noreply.github.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/compute/dynamic-dispatch-8.slang40
-rw-r--r--tests/compute/dynamic-dispatch-8.slang.expected.txt4
2 files changed, 44 insertions, 0 deletions
diff --git a/tests/compute/dynamic-dispatch-8.slang b/tests/compute/dynamic-dispatch-8.slang
new file mode 100644
index 000000000..df8ecc41f
--- /dev/null
+++ b/tests/compute/dynamic-dispatch-8.slang
@@ -0,0 +1,40 @@
+//TEST(compute):COMPARE_COMPUTE:-cpu -xslang -allow-dynamic-code
+//DISABLE_TEST(compute):COMPARE_COMPUTE:-cuda -xslang -allow-dynamic-code
+
+// Test dynamic dispatch code gen for extential type parameters.
+
+[anyValueSize(16)]
+interface IInterface
+{
+ int Compute(int inVal);
+};
+
+int GenericCompute(IInterface obj, int inVal)
+{
+ return obj.Compute(inVal);
+}
+
+struct Impl : IInterface
+{
+ int base;
+ int Compute(int inVal) { return base + inVal * inVal; }
+};
+
+int test(int inVal)
+{
+ Impl obj;
+ obj.base = 1;
+ return GenericCompute(obj, inVal);
+}
+
+//TEST_INPUT:ubuffer(data=[0 1 2 3], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+[numthreads(4, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ uint tid = dispatchThreadID.x;
+ int inVal = outputBuffer[tid];
+ int outVal = test(inVal);
+ outputBuffer[tid] = outVal;
+}
diff --git a/tests/compute/dynamic-dispatch-8.slang.expected.txt b/tests/compute/dynamic-dispatch-8.slang.expected.txt
new file mode 100644
index 000000000..146ab3c8c
--- /dev/null
+++ b/tests/compute/dynamic-dispatch-8.slang.expected.txt
@@ -0,0 +1,4 @@
+1
+2
+5
+A