From a618b8c5e249b0f20e6c0c95f9da1b5cbfdbf08b Mon Sep 17 00:00:00 2001 From: Yong He Date: Thu, 17 Oct 2024 20:14:22 -0700 Subject: Cleanup atomic intrinsics. (#5324) * Cleanup atomic intrinsics. * Fix. * Fix glsl. * Remove hacky intrinsic expansion logic for glsl image atomics. * Fix all tests. * Fix. * Add `InterlockedAddF16Emulated`. * Fix glsl intrinsic. * Fix. --- source/slang/slang-emit-cuda.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'source/slang/slang-emit-cuda.cpp') diff --git a/source/slang/slang-emit-cuda.cpp b/source/slang/slang-emit-cuda.cpp index 81bcafeb3..7d104ff1b 100644 --- a/source/slang/slang-emit-cuda.cpp +++ b/source/slang/slang-emit-cuda.cpp @@ -515,7 +515,17 @@ bool CUDASourceEmitter::tryEmitInstStmtImpl(IRInst* inst) { emitInstResultDecl(inst); m_writer->emit("atomicAdd("); + bool needCloseTypeCast = false; + if (inst->getDataType()->getOp() == kIROp_Int64Type) + { + m_writer->emit("(unsigned long long*)("); + needCloseTypeCast = true; + } emitOperand(inst->getOperand(0), getInfo(EmitOp::General)); + if (needCloseTypeCast) + { + m_writer->emit(")"); + } m_writer->emit(", "); emitOperand(inst->getOperand(1), getInfo(EmitOp::General)); m_writer->emit(");\n"); @@ -525,7 +535,17 @@ bool CUDASourceEmitter::tryEmitInstStmtImpl(IRInst* inst) { emitInstResultDecl(inst); m_writer->emit("atomicAdd("); + bool needCloseTypeCast = false; + if (inst->getDataType()->getOp() == kIROp_Int64Type) + { + m_writer->emit("(unsigned long long*)("); + needCloseTypeCast = true; + } emitOperand(inst->getOperand(0), getInfo(EmitOp::General)); + if (needCloseTypeCast) + { + m_writer->emit(")"); + } m_writer->emit(", -("); emitOperand(inst->getOperand(1), getInfo(EmitOp::General)); m_writer->emit("));\n"); -- cgit v1.2.3