diff options
| author | Yong He <yonghe@outlook.com> | 2024-10-17 20:14:22 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2024-10-17 20:14:22 -0700 |
| commit | a618b8c5e249b0f20e6c0c95f9da1b5cbfdbf08b (patch) | |
| tree | d583c373d574a265fefe7f288a96c4b382e259b8 /source/slang/slang-emit-cuda.cpp | |
| parent | 11e1ecafa09396a3559fe245d729b40ce4f25d52 (diff) | |
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.
Diffstat (limited to 'source/slang/slang-emit-cuda.cpp')
| -rw-r--r-- | source/slang/slang-emit-cuda.cpp | 20 |
1 files changed, 20 insertions, 0 deletions
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"); |
