summaryrefslogtreecommitdiff
path: root/tests/language-feature/higher-order-functions
diff options
context:
space:
mode:
authorEllie Hermaszewska <ellieh@nvidia.com>2023-05-13 06:33:26 +0800
committerGitHub <noreply@github.com>2023-05-12 15:33:26 -0700
commit65103bc9a0c72117d3c9410e361947cdd568ae55 (patch)
tree9dcb3dea5082d12366e078b3c7b62faa89ef5c73 /tests/language-feature/higher-order-functions
parent332f60c19336252d907b83882aa70665ca93a9d2 (diff)
Fusion pass for saturated_cooperation (#2874)
* Fusion pass for saturated_cooperation * simplify assert * regenerate vs projects * missing test output files * rename shadowing variable to appease msvc * Fuse calls to sat_coop with differing inputs * formatting * add cpu test for hof simple * Make higher-order functions into compute comparison tests * comment tests * remove redundant test * Add test to confirm inlining in sat_coop fuse * Add clarifying comment for sat coop fusing * Add KnownBuiltin decoration * s/CanUseFuncSignature/TypesFullyResolved for higher order function checking * Add TODO * spelling * Correct detection of sat_coop calls * Disable tests which are unsupported on testing infra
Diffstat (limited to 'tests/language-feature/higher-order-functions')
-rw-r--r--tests/language-feature/higher-order-functions/generic.slang19
-rw-r--r--tests/language-feature/higher-order-functions/generic.slang.expected.txt1
-rw-r--r--tests/language-feature/higher-order-functions/inference.slang31
-rw-r--r--tests/language-feature/higher-order-functions/inference.slang.expected.txt1
-rw-r--r--tests/language-feature/higher-order-functions/simple.slang1
5 files changed, 40 insertions, 13 deletions
diff --git a/tests/language-feature/higher-order-functions/generic.slang b/tests/language-feature/higher-order-functions/generic.slang
index e7d63eb27..af538bee1 100644
--- a/tests/language-feature/higher-order-functions/generic.slang
+++ b/tests/language-feature/higher-order-functions/generic.slang
@@ -1,14 +1,25 @@
-//TEST:SIMPLE:
+//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
-func foo(f : functype (float) -> int) -> int{
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+[numthreads(1, 1, 1)]
+void computeMain(uint tig : SV_GroupIndex)
+{
+ outputBuffer[tig] = zap();
+}
+
+func foo(f : functype (float) -> int) -> int
+{
return f(0);
}
-int bap<T>(float) {
+int bap<T>(float)
+{
return 1;
}
-int zap() {
+int zap()
+{
// We should be able to specify which foo we want
return foo(bap<bool>);
}
diff --git a/tests/language-feature/higher-order-functions/generic.slang.expected.txt b/tests/language-feature/higher-order-functions/generic.slang.expected.txt
new file mode 100644
index 000000000..d00491fd7
--- /dev/null
+++ b/tests/language-feature/higher-order-functions/generic.slang.expected.txt
@@ -0,0 +1 @@
+1
diff --git a/tests/language-feature/higher-order-functions/inference.slang b/tests/language-feature/higher-order-functions/inference.slang
index c01f5b19e..3468395d7 100644
--- a/tests/language-feature/higher-order-functions/inference.slang
+++ b/tests/language-feature/higher-order-functions/inference.slang
@@ -1,21 +1,34 @@
-//TEST:SIMPLE:
+//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer;
+[numthreads(1, 1, 1)]
+void computeMain(uint tig : SV_GroupIndex)
+{
+ // Test that we infer the type parameters to X from the type of f
+ x(f);
+ // Testthat we infer the type paramters to from a specialized generic (g)
+ y(g<int>);
+ outputBuffer[tig] = p;
+}
+
+static int p = 0;
func x<A, B>(f : functype (A) -> B)
-{ }
+{
+ ++p;
+}
float f(int)
{
- return 0;
+ return 1;
}
func y<A, B, C>(g : functype (A, B) -> C)
-{ }
+{
+ p += 2;
+}
void g<A>(A, bool)
{ }
-void main()
-{
- x(f);
- y(g<int>);
-}
diff --git a/tests/language-feature/higher-order-functions/inference.slang.expected.txt b/tests/language-feature/higher-order-functions/inference.slang.expected.txt
new file mode 100644
index 000000000..00750edc0
--- /dev/null
+++ b/tests/language-feature/higher-order-functions/inference.slang.expected.txt
@@ -0,0 +1 @@
+3
diff --git a/tests/language-feature/higher-order-functions/simple.slang b/tests/language-feature/higher-order-functions/simple.slang
index 7c6bf5a26..1443bd60d 100644
--- a/tests/language-feature/higher-order-functions/simple.slang
+++ b/tests/language-feature/higher-order-functions/simple.slang
@@ -1,5 +1,6 @@
//TEST(compute, vulkan):COMPARE_COMPUTE_EX():-vk -compute -shaderobj -output-using-type
//TEST(compute):COMPARE_COMPUTE_EX():-slang -compute -shaderobj -output-using-type
+//TEST(compute):COMPARE_COMPUTE:-cpu -shaderobj -output-using-type
//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer
RWStructuredBuffer<uint> outputBuffer;