From 4ed3aafa20b667329f2f9dea94d7c65dc2e80db4 Mon Sep 17 00:00:00 2001 From: Yong He Date: Wed, 12 Jul 2023 14:07:10 -0700 Subject: Fix native string emit for CUDA/Cpp backend. (#2980) Co-authored-by: Yong He --- prelude/slang-cuda-prelude.h | 1 + prelude/slang-torch-prelude.h | 30 +++++++++++++++--------------- source/slang/slang-emit-cpp.cpp | 2 +- 3 files changed, 17 insertions(+), 16 deletions(-) diff --git a/prelude/slang-cuda-prelude.h b/prelude/slang-cuda-prelude.h index 0362a3a67..0b56b8a71 100644 --- a/prelude/slang-cuda-prelude.h +++ b/prelude/slang-cuda-prelude.h @@ -11,6 +11,7 @@ #else #include +#include #endif diff --git a/prelude/slang-torch-prelude.h b/prelude/slang-torch-prelude.h index 0a69b8305..0de06750c 100644 --- a/prelude/slang-torch-prelude.h +++ b/prelude/slang-torch-prelude.h @@ -7,20 +7,6 @@ #include #include -#ifndef SLANG_NO_THROW -# define SLANG_NO_THROW -#endif - -#ifndef SLANG_STDCALL -# define SLANG_STDCALL -#endif -#ifndef SLANG_MCALL -# define SLANG_MCALL SLANG_STDCALL -#endif -#ifndef SLANG_FORCE_INLINE -# define SLANG_FORCE_INLINE inline -#endif - #ifdef SLANG_LLVM #include "slang-llvm.h" #else // SLANG_LLVM @@ -38,6 +24,8 @@ # include #endif // SLANG_LLVM +#include "../source/core/slang-string.h" + #if defined(_MSC_VER) # define SLANG_PRELUDE_SHARED_LIB_EXPORT __declspec(dllexport) #else @@ -55,12 +43,24 @@ # define SLANG_PRELUDE_EXTERN_C_END #endif - #define SLANG_PRELUDE_NAMESPACE +#ifndef SLANG_NO_THROW +# define SLANG_NO_THROW +#endif +#ifndef SLANG_STDCALL +# define SLANG_STDCALL +#endif +#ifndef SLANG_MCALL +# define SLANG_MCALL SLANG_STDCALL +#endif +#ifndef SLANG_FORCE_INLINE +# define SLANG_FORCE_INLINE inline +#endif #include "slang-cpp-types-core.h" #include "slang-cpp-scalar-intrinsics.h" + static const int kSlangTorchTensorMaxDim = 5; struct TensorView diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index ef9b7f54e..83af4ad47 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -1574,7 +1574,7 @@ bool CPPSourceEmitter::tryEmitInstExprImpl(IRInst* inst, const EmitOpInfo& inOut if (m_hasString) { - m_writer->emit("toTerminatedSlice("); + m_writer->emit("Slang::toTerminatedSlice("); m_writer->emit(buf); m_writer->emit(")"); } -- cgit v1.2.3