From 41d8610653cacfb763e3e1a1c538e17037703108 Mon Sep 17 00:00:00 2001 From: Tim Foley Date: Mon, 5 Oct 2020 11:10:53 -0700 Subject: Small fixes for CUDA code emit (#1564) * Small fixes for CUDA code emit * Add a CUDA translation to `GroupMemoryBarrierWithWaveSync()`. We map this to `__syncwarp()` for CUDA (with no mask, implying a full-warp sync). * Consistently use `SLANG_PRELUDE_ASSERT` for assertions introduced in code emit (rather than just using the bare `assert(...)` function, which is not included by our CUDA prelude by default) * Add a new `SLANG_CUDA_STRUCTURED_BUFFER_NO_COUNT` flag to the CUDA prelude that allows the `count` field to be omitted from `(RW)StructuredBuffer`. This is a bit of a hacky because the computed layouts will still assume the `count` field is present, but this feature is required by at least one client application for now. A better long-term fix will take more time to design and implement. * fixup: CUDA prelude code fix for pedantic compilers Co-authored-by: Tim Foley Co-authored-by: Yong He --- source/slang/slang-emit-cpp.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'source/slang/slang-emit-cpp.cpp') diff --git a/source/slang/slang-emit-cpp.cpp b/source/slang/slang-emit-cpp.cpp index 5359740b4..1e2482bb5 100644 --- a/source/slang/slang-emit-cpp.cpp +++ b/source/slang/slang-emit-cpp.cpp @@ -984,7 +984,7 @@ void CPPSourceEmitter::_emitGetAtDefinition(const UnownedStringSlice& funcName, { int vecSize = int(getIntVal(vectorType->getElementCount())); - writer->emit("assert(b >= 0 && b < "); + writer->emit("SLANG_PRELUDE_ASSERT(b >= 0 && b < "); writer->emit(vecSize); writer->emit(");\n"); if (lValue) @@ -997,7 +997,7 @@ void CPPSourceEmitter::_emitGetAtDefinition(const UnownedStringSlice& funcName, //int colCount = int(getIntVal(matrixType->getColumnCount())); int rowCount = int(getIntVal(matrixType->getRowCount())); - writer->emit("assert(b >= 0 && b < "); + writer->emit("SLANG_PRELUDE_ASSERT(b >= 0 && b < "); writer->emit(rowCount); writer->emit(");\n"); -- cgit v1.2.3