summaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorYong He <yonghe@outlook.com>2023-02-13 10:38:14 -0800
committerGitHub <noreply@github.com>2023-02-13 10:38:14 -0800
commit4dbc74a953ae1b34ce64a4eaef3aa7feb73663b9 (patch)
tree82b099c1074a0361b0db6a72e96f71d3b8e3b574 /tests
parent57af2c1c2fccb221fa54fd92415f424b1d7e5beb (diff)
Add Loop Unrolling Pass. (#2644)
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests')
-rw-r--r--tests/ir/loop-unroll-0.slang19
-rw-r--r--tests/ir/loop-unroll-0.slang.expected.txt4
-rw-r--r--tests/ir/loop-unroll-1.slang25
-rw-r--r--tests/ir/loop-unroll-1.slang.expected.txt1
-rw-r--r--tests/ir/string-literal.slang.expected2
-rw-r--r--tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl16
6 files changed, 54 insertions, 13 deletions
diff --git a/tests/ir/loop-unroll-0.slang b/tests/ir/loop-unroll-0.slang
new file mode 100644
index 000000000..d97acac0e
--- /dev/null
+++ b/tests/ir/loop-unroll-0.slang
@@ -0,0 +1,19 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ int i = 0;
+ [ForceUnroll]
+ while (i < 5 && dispatchThreadID.x == 0)
+ {
+ if (i >= 3)
+ break;
+ outputBuffer[i] = i;
+ i++;
+ }
+}
diff --git a/tests/ir/loop-unroll-0.slang.expected.txt b/tests/ir/loop-unroll-0.slang.expected.txt
new file mode 100644
index 000000000..d2a5eee71
--- /dev/null
+++ b/tests/ir/loop-unroll-0.slang.expected.txt
@@ -0,0 +1,4 @@
+0
+1
+2
+0
diff --git a/tests/ir/loop-unroll-1.slang b/tests/ir/loop-unroll-1.slang
new file mode 100644
index 000000000..562cd3713
--- /dev/null
+++ b/tests/ir/loop-unroll-1.slang
@@ -0,0 +1,25 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-slang -compute -shaderobj
+//TEST(compute, vulkan):COMPARE_COMPUTE_EX:-vk -compute -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<uint> outputBuffer;
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
+{
+ int i = 0;
+ int sum = 0;
+ [ForceUnroll]
+ while (i < 2)
+ {
+ int j = 1;
+ [ForceUnroll(2)]
+ while (j < 3)
+ {
+ sum += (i+j);
+ j++;
+ }
+ i++;
+ }
+ outputBuffer[0] = sum;
+}
diff --git a/tests/ir/loop-unroll-1.slang.expected.txt b/tests/ir/loop-unroll-1.slang.expected.txt
new file mode 100644
index 000000000..45a4fb75d
--- /dev/null
+++ b/tests/ir/loop-unroll-1.slang.expected.txt
@@ -0,0 +1 @@
+8
diff --git a/tests/ir/string-literal.slang.expected b/tests/ir/string-literal.slang.expected
index 48836cae6..6f414b0da 100644
--- a/tests/ir/string-literal.slang.expected
+++ b/tests/ir/string-literal.slang.expected
@@ -1,6 +1,7 @@
result code = 0
standard error = {
### LOWER-TO-IR:
+undefined
[entryPoint(6 : Int, "main", "string-literal")]
[numThreads(1 : Int, 1 : Int, 1 : Int)]
[export("_S3tu04mainp1puV")]
@@ -13,7 +14,6 @@ block %1(
return_val(void_constant)
}
global_hashed_string_literals("Hello \t\n\0x083 World")
-undefined
###
}
standard output = {
diff --git a/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl b/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl
index 04ef5a6fe..0364d2513 100644
--- a/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl
+++ b/tests/pipeline/ray-tracing/trace-ray-inline.slang.glsl
@@ -90,8 +90,6 @@ void main()
}
uint _S3 = (rayQueryGetIntersectionTypeEXT((query_0), false));
- MyProceduralHitAttrs_0 committedProceduralAttrs_1;
-
switch(_S3)
{
case 1U:
@@ -118,13 +116,13 @@ void main()
{
}
- committedProceduralAttrs_1 = _S6;
+ committedProceduralAttrs_0 = _S6;
}
else
{
- committedProceduralAttrs_1 = committedProceduralAttrs_0;
+ committedProceduralAttrs_0 = committedProceduralAttrs_0;
}
@@ -132,7 +130,7 @@ void main()
else
{
- committedProceduralAttrs_1 = committedProceduralAttrs_0;
+ committedProceduralAttrs_0 = committedProceduralAttrs_0;
}
@@ -157,21 +155,15 @@ void main()
else
{
}
-
- committedProceduralAttrs_1 = committedProceduralAttrs_0;
-
break;
}
default:
{
-
- committedProceduralAttrs_1 = committedProceduralAttrs_0;
-
break;
}
}
- committedProceduralAttrs_0 = committedProceduralAttrs_1;
+ committedProceduralAttrs_0 = committedProceduralAttrs_0;
}