summaryrefslogtreecommitdiff
path: root/tests/cooperative-matrix
diff options
context:
space:
mode:
author16-Bit-Dog <67922228+16-Bit-Dog@users.noreply.github.com>2025-10-10 13:09:24 -0400
committerGitHub <noreply@github.com>2025-10-10 17:09:24 +0000
commit1e0908bd7107dfbdac912b693c3ab9bd6e1dc8b3 (patch)
treecc39d2e18abc954fb76f9a54b11a8d492685c6e2 /tests/cooperative-matrix
parentb4023f715885ada9a2777ea3b0d6d9739860b39b (diff)
Addition of `Load`/`Store` coherent operations (#8395)
Fixes: https://github.com/shader-slang/slang/issues/7634 Duplicate of PR https://github.com/shader-slang/slang/pull/8052 Primary Changes: * Added `storeCoherent` and `loadCoherent` for coherent load/store via pointers. This is backed by `IRMemoryScopeAttr` which is an `IRAttr` attached to `IRLoad` and `IRStore` * Logic in `source\slang\slang-emit-spirv.cpp` for load/store emitting has been reworked to be less messy and more maintainable * Add to `hlsl.meta.slang` coop vector and coop matrix coherent load/store operations Secondary Changes: * Added a missing load/store test for coop matrix: `tests\cooperative-matrix\load-store-pointer.slang` --------- Co-authored-by: ArielG-NV <aglasroth@nvidia.com> Co-authored-by: ArielG-NV <159081215+ArielG-NV@users.noreply.github.com> Co-authored-by: slangbot <186143334+slangbot@users.noreply.github.com> Co-authored-by: Nathan V. Morrical <natemorrical@gmail.com>
Diffstat (limited to 'tests/cooperative-matrix')
-rw-r--r--tests/cooperative-matrix/coherent-load-store-pointer.slang34
-rw-r--r--tests/cooperative-matrix/load-store-pointer.slang35
2 files changed, 69 insertions, 0 deletions
diff --git a/tests/cooperative-matrix/coherent-load-store-pointer.slang b/tests/cooperative-matrix/coherent-load-store-pointer.slang
new file mode 100644
index 000000000..6057ab41f
--- /dev/null
+++ b/tests/cooperative-matrix/coherent-load-store-pointer.slang
@@ -0,0 +1,34 @@
+//TEST:SIMPLE(filecheck=SPIRV):-stage compute -entry computeMain -target spirv
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly
+
+// Ensure SPIRV emits coherent operations here
+// SPIRV: MakePointerVisible
+// SPIRV: MakePointerAvailable
+
+// CHECK: 1
+// CHECK-NEXT: 2
+// CHECK-NEXT: 3
+// CHECK-NEXT: 4
+// CHECK-NEXT: 5
+// CHECK-NEXT: 6
+// CHECK-NEXT: 7
+// CHECK-NEXT: 8
+
+//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8], stride=4, count=256):name=inputBuffer
+uniform int32_t* inputBuffer;
+
+//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer
+uniform int32_t* outputBuffer;
+
+using namespace linalg;
+
+[numthreads(32, 1, 1)]
+void computeMain()
+{
+ int32_t* ptrIn = inputBuffer;
+ int32_t* ptrOut = outputBuffer;
+
+ let stride = 16;
+ let mat = coopMatLoadCoherent<int32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse.MatrixAccumulator, CoopMatMatrixLayout.RowMajor>(ptrIn, 0, stride, MemoryScope::Device);
+ mat.StoreCoherent<CoopMatMatrixLayout.RowMajor>(ptrOut, 0, 16, MemoryScope::Device);
+} \ No newline at end of file
diff --git a/tests/cooperative-matrix/load-store-pointer.slang b/tests/cooperative-matrix/load-store-pointer.slang
new file mode 100644
index 000000000..2bbd8fef1
--- /dev/null
+++ b/tests/cooperative-matrix/load-store-pointer.slang
@@ -0,0 +1,35 @@
+//TEST:SIMPLE(filecheck=SPIRV):-stage compute -entry computeMain -target spirv
+//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-vk -output-using-type -emit-spirv-directly
+
+// Ensure SPIRV does not do coherent operations here
+// SPIRV-NOT: MakePointerAvailable
+// SPIRV-NOT: MakePointerVisible
+
+
+// CHECK: 1
+// CHECK-NEXT: 2
+// CHECK-NEXT: 3
+// CHECK-NEXT: 4
+// CHECK-NEXT: 5
+// CHECK-NEXT: 6
+// CHECK-NEXT: 7
+// CHECK-NEXT: 8
+
+//TEST_INPUT:ubuffer(data=[1 2 3 4 5 6 7 8], stride=4, count=256):name=inputBuffer
+uniform int32_t* inputBuffer;
+
+//TEST_INPUT:ubuffer(stride=4, count=256):out,name=outputBuffer
+uniform int32_t* outputBuffer;
+
+using namespace linalg;
+
+[numthreads(32, 1, 1)]
+void computeMain()
+{
+ int32_t* ptrIn = inputBuffer;
+ int32_t* ptrOut = outputBuffer;
+
+ let stride = 16;
+ let mat = coopMatLoad<int32_t, MemoryScope.Subgroup, 16, 16, CoopMatMatrixUse.MatrixAccumulator, CoopMatMatrixLayout.RowMajor>(ptrIn, 0, stride);
+ mat.Store<CoopMatMatrixLayout.RowMajor>(ptrOut, 0, 16);
+} \ No newline at end of file