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 --- source/slang/slang-emit-c-like.cpp | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'source/slang/slang-emit-c-like.cpp') diff --git a/source/slang/slang-emit-c-like.cpp b/source/slang/slang-emit-c-like.cpp index fa380e061..626c372e9 100644 --- a/source/slang/slang-emit-c-like.cpp +++ b/source/slang/slang-emit-c-like.cpp @@ -3518,14 +3518,13 @@ bool CLikeSourceEmitter::isTargetIntrinsic(IRInst* inst) return findTargetIntrinsicDefinition(inst, intrinsicDef); } -bool shouldWrappInExternCBlock(IRFunc* func) +bool shouldWrapInExternCBlock(IRFunc* func) { for (auto decor : func->getDecorations()) { switch (decor->getOp()) { case kIROp_ExternCDecoration: - case kIROp_CudaKernelDecoration: return true; } } @@ -3540,7 +3539,7 @@ void CLikeSourceEmitter::emitFunc(IRFunc* func) if (isTargetIntrinsic(func)) return; - bool shouldCloseExternCBlock = shouldWrappInExternCBlock(func); + bool shouldCloseExternCBlock = shouldWrapInExternCBlock(func); if (shouldCloseExternCBlock) { // If this is a C++ `extern "C"` function, then we need to emit -- cgit v1.2.3