From 52b91231cdadc048f93b224f5035759cf1a96eaa Mon Sep 17 00:00:00 2001 From: Sai Praveen Bangaru <31557731+saipraveenb25@users.noreply.github.com> Date: Tue, 30 Apr 2024 16:05:33 -0400 Subject: Added diagnostics & built-in type lowering for `[CUDAKernel]` functions (#4042) * Added diagnostics & built-in type lowering for `[CUDAKernel]` functions This PR adds - Diagnostics for non-void return from a cuda kernel entry point - Diagnostics for using differentiable types in a differentiable cuda kernel entry point - Logic for converting built-in types (float3, float3x3, etc..) to portable struct types and unpacks the parameter back into a built-in type on the CUDA side. This is because built-in types have different implementations in CUDA & CPP targets, which causes signature mis-match when linking. * Fix error codes * Add ability to lower structs and arrays that contain built-in types. + Added tests + Fix issue where the host-side was not marshalling data to lowered types. * Update slang-ir-pytorch-cpp-binding.cpp --------- Co-authored-by: Yong He --- .../cuda-kernel-differentiable-params.slang | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 tests/diagnostics/cuda-kernel-differentiable-params.slang (limited to 'tests/diagnostics/cuda-kernel-differentiable-params.slang') diff --git a/tests/diagnostics/cuda-kernel-differentiable-params.slang b/tests/diagnostics/cuda-kernel-differentiable-params.slang new file mode 100644 index 000000000..0e7604b3d --- /dev/null +++ b/tests/diagnostics/cuda-kernel-differentiable-params.slang @@ -0,0 +1,18 @@ +//DIAGNOSTIC_TEST:SIMPLE(filecheck=CHECK): + +// Simple check to see if the compiler throws an error if a CUDA kernel is declared with non-void return type. + +[CudaKernel] +[Differentiable] +void myBadKernel(float x, TensorView t1, TensorView t2) +{ + // CHECK: tests/diagnostics/cuda-kernel-differentiable-params.slang([[@LINE-2]]): error 31214: differentiable kernel entry point cannot have differentiable parameters. Consider using DiffTensorView to pass differentiable data, or marking this parameter with 'no_diff' + // CHECK-NEXT: void myBadKernel(float x, TensorView t1, TensorView t2) + // CHECK-NEXT: ^ +} + +[CudaKernel] +void myGoodKernel(float x, TensorView t1, TensorView t2) +{ + +} \ No newline at end of file -- cgit v1.2.3