yum-mirror/slang

Making it easier to work with shaders

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

Sai Praveen BangaruAdded diagnostics & built-in type lowering for `[CUDAKernel]` functions (#4042)52b91231c

master
729 B21 linesraw
1//TEST:SIMPLE(filecheck=CUDA): -target cuda -line-directive-mode none
2//TEST:SIMPLE(filecheck=TORCH): -target torch -line-directive-mode none
3
4[AutoPyBindCUDA]
5[CUDAKernel]
6void plain_copy(float3 input, TensorView<float> output)
7{
8    // CUDA: __global__ void __kernel__plain_copy(_VectorStorage_float3_0 input_0, TensorView output_0)
9    // TORCH: void __kernel__plain_copy(_VectorStorage_float3_0 _0, TensorView _1);
10
11    // Get the 'global' index of this thread.
12    uint3 dispatchIdx = cudaThreadIdx() + cudaBlockIdx() * cudaBlockDim();
13
14    // If the thread index is beyond the input size, exit early.
15    if (dispatchIdx.x >= 1)
16        return;
17
18    output[0] = input.x;
19    output[1] = input.y;
20    output[2] = input.z;
21}