yum-mirror/slang

Making it easier to work with shaders

git clone https://git.yummers.dev/yum-mirror/slang

ArielG-NV[CBP] Pointer frontend changes + groupshared pointer support (#7848)7758625d3

master
869 B32 linesraw
1//TEST:COMPARE_COMPUTE(filecheck-buffer=CHECK): -cuda -output-using-type
2
3// This test just ensures that we compile and run the code.
4// It does not check the correctness of the autodiff.
5
6//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out, name outputBuffer
7RWStructuredBuffer<float> outputBuffer;
8
9struct MyDiffPtr
10{
11    float data1;
12    float data2;
13};
14
15[Differentiable]
16float function(Ptr<MyDiffPtr, Access::ReadWrite, AddressSpace::GroupShared> i)
17{
18    return i[0].data1 + i[1].data2;
19}
20
21groupshared MyDiffPtr s[2];
22[numthreads(1, 1, 1), shader("compute")]
23void computeMain(uint3 dispatchThreadID: SV_DispatchThreadID)
24{
25    s = { { 0, 2 }, { 1, 3 } };
26    float result = 1.0f;
27    let pair = __fwd_diff(function)(__getAddress(s[0]));
28    outputBuffer[0] = pair.getPrimal();
29    outputBuffer[1] = pair.getDifferential();
30    // CHECK: 3.0
31    // CHECK-NEXT: 0.0
32}