diff options
| author | Yong He <yonghe@outlook.com> | 2023-09-29 12:01:36 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2023-09-29 12:01:36 -0700 |
| commit | f20f4e2b39142dfab55be05eea064033719665ad (patch) | |
| tree | 27342e5649906cbbb719c5bd4fac57b0a452b86a /tests/cuda | |
| parent | af61737e7ba107e9e92164bf39ce6ab34e05ce82 (diff) | |
Add `requirePrelude()` intrinsic function. (#3250)
* Add `requirePrelude()` intrinsic function.
* Fix.
---------
Co-authored-by: Yong He <yhe@nvidia.com>
Diffstat (limited to 'tests/cuda')
| -rw-r--r-- | tests/cuda/require-prelude.slang | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/tests/cuda/require-prelude.slang b/tests/cuda/require-prelude.slang new file mode 100644 index 000000000..a5e7fb19b --- /dev/null +++ b/tests/cuda/require-prelude.slang @@ -0,0 +1,38 @@ + +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cuda -compute -output-using-type +//TEST(compute):COMPARE_COMPUTE(filecheck-buffer=CHECK):-cpu -compute -output-using-type + +int myIntrinsicFunc() +{ + __target_switch + { + case cpp: + case hlsl: + case cuda: + __requirePrelude(R"(#define MY_CUDA_INTRINSIC 100)"); + __intrinsic_asm "(MY_CUDA_INTRINSIC)"; + } +} + +int myIntrinsicFunc1() +{ + __target_switch + { + case cpp: + case hlsl: + case cuda: + __requirePrelude(R"(#define MY_CUDA_INTRINSIC 100)"); + __intrinsic_asm "(MY_CUDA_INTRINSIC + 1)"; + } +} + +//TEST_INPUT:ubuffer(data=[0 0 0 0], stride=4):out,name=outputBuffer +RWStructuredBuffer<uint> outputBuffer; + +[numthreads(1, 1, 1)] +void computeMain(uint3 dispatchThreadID : SV_DispatchThreadID) +{ + // CHECK: 201 + outputBuffer[0] = myIntrinsicFunc() + myIntrinsicFunc1(); +} |
