summaryrefslogtreecommitdiff
path: root/tests/cuda/cuda-array-layout.slang
diff options
context:
space:
mode:
authorjsmall-nvidia <jsmall@nvidia.com>2021-06-10 14:57:09 -0400
committerGitHub <noreply@github.com>2021-06-10 11:57:09 -0700
commit37e8917d10626b519470f2e34625f0efe741352f (patch)
tree4e8e51bd63ebc03fcdf0c893b675906cf507d73c /tests/cuda/cuda-array-layout.slang
parent0d9bd79e8fd4d57e1a723ca6b6a45efec2b42872 (diff)
CUDA layout corner cases/testing (#1881)
* #include an absolute path didn't work - because paths were taken to always be relative. * Add support for sizeOf/alignOf/offsetOf to stdlib. Add $G intrinsic expansion that works of the generic parameters not the param type * Test cuda layout. * Fix CUDA layout issues. Fix reflection to handle other built in types. Fix __offsetOf * Tests of reflection and layout as reported directly from CUDA. * Comment about use of aligned size as size. * Fix warning from VS. * Check alignment is pow2. * Small improvements to alignment calcs. * Tab to spaces. * Fix alignment pointer sizes on 32 bit OS for CUDA. * Fix CUDA reflection on 32 bit.
Diffstat (limited to 'tests/cuda/cuda-array-layout.slang')
-rw-r--r--tests/cuda/cuda-array-layout.slang32
1 files changed, 32 insertions, 0 deletions
diff --git a/tests/cuda/cuda-array-layout.slang b/tests/cuda/cuda-array-layout.slang
new file mode 100644
index 000000000..7fee3b192
--- /dev/null
+++ b/tests/cuda/cuda-array-layout.slang
@@ -0,0 +1,32 @@
+//TEST(compute):COMPARE_COMPUTE_EX:-cuda -compute -output-using-type -shaderobj
+
+//TEST_INPUT:ubuffer(data=[0 0 0 0 0 0 0 0], stride=4):out,name=outputBuffer
+RWStructuredBuffer<int> outputBuffer : register(u0);
+
+struct PadLadenStruct
+{
+ double a;
+ uint8_t b;
+};
+
+// This is to check if the last half can be inserted 'inside' the spare padding of a. It should not be
+struct StructWithArray
+{
+ PadLadenStruct a[1];
+ uint8_t b;
+
+ matrix<half, 3, 3> c;
+ uint8_t d;
+};
+
+[numthreads(1, 1, 1)]
+void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID)
+{
+ StructWithArray s;
+ outputBuffer[0] = __sizeOf(s);
+
+ outputBuffer[1] = __offsetOf(s, s.a);
+ outputBuffer[2] = __offsetOf(s, s.b);
+ outputBuffer[3] = __offsetOf(s, s.c);
+ outputBuffer[4] = __offsetOf(s, s.d);
+}