You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
While working on PR #7286 it was noticed that the emission of Coopvec has some issues. Here's the problem. Generate cuda output for the tests/cuda/optix-coopvec.slang test and you will see this:
But it should be: OptixCoopVec<float, 4> _S8 = optixCoopVecTanh((_S6));
What I observe is that inside void CLikeSourceEmitter::emitInstResultDecl(IRInst* inst), I see that
for auto type = inst->getDataType();, type is returned as kIROp_VoidType. So this function terminates earlier because of this check:
if (as<IRVoidType>(type))
return;
When creating the inst for tanh, I see:
slang.dll!Slang::IRBuilder::_createInst(unsigned __int64 minSizeInBytes, Slang::IRType * type, Slang::IROp op, __int64 fixedArgCount, Slang::IRInst * const * fixedArgs, __int64 varArgListCount, const __int64 * listArgCounts, Slang::IRInst * const * const * listArgs) Line 1866 C++
slang.dll!Slang::createInstImpl<Slang::IRCall>(Slang::IRBuilder * builder, Slang::IROp op, Slang::IRType * type, __int64 fixedArgCount, Slang::IRInst * const * fixedArgs, __int64 varArgListCount, const __int64 * listArgCounts, Slang::IRInst * const * const * listArgs) Line 1931 C++
slang.dll!Slang::createInstImpl<Slang::IRCall>(Slang::IRBuilder * builder, Slang::IROp op, Slang::IRType * type, __int64 fixedArgCount, Slang::IRInst * const * fixedArgs, __int64 varArgCount, Slang::IRInst * const * varArgs) Line 1952 C++
slang.dll!Slang::createInstWithTrailingArgs<Slang::IRCall>(Slang::IRBuilder * builder, Slang::IROp op, Slang::IRType * type, __int64 fixedArgCount, Slang::IRInst * const * fixedArgs, __int64 varArgCount, Slang::IRInst * const * varArgs) Line 2028 C++
slang.dll!Slang::IRBuilder::emitCallInst(Slang::IRType * type, Slang::IRInst * pFunc, unsigned __int64 argCount, Slang::IRInst * const * args) Line 3897 C++
slang.dll!Slang::IRBuilder::emitCallInst(Slang::IRType * type, Slang::IRInst * func, const Slang::List<Slang::IRInst *,Slang::StandardAllocator> & args) Line 4149 C++
> slang.dll!Slang::makeFuncReturnViaOutParam(Slang::IRBuilder & builder, Slang::IRFunc * func) Line 75 C++
slang.dll!Slang::legalizeArrayReturnType(Slang::IRModule * module) Line 94 C++
slang.dll!Slang::linkAndOptimizeIR(Slang::CodeGenContext * codeGenContext, const Slang::LinkingAndOptimizationOptions & options, Slang::LinkedIR & outLinkedIR) Line 1695 C++
slang.dll!Slang::CodeGenContext::emitEntryPointsSourceFromIR(Slang::ComPtr<Slang::IArtifact> & outArtifact) Line 1995 C++
slang.dll!Slang::CodeGenContext::emitEntryPointsSource(Slang::ComPtr<Slang::IArtifact> & outArtifact) Line 794 C++
slang.dll!Slang::CodeGenContext::emitEntryPoints(Slang::ComPtr<Slang::IArtifact> & outArtifact) Line 1993 C++
slang.dll!Slang::TargetProgram::_createWholeProgramResult(Slang::DiagnosticSink * sink, Slang::EndToEndCompileRequest * endToEndReq) Line 2134 C++
slang.dll!Slang::EndToEndCompileRequest::generateOutput(Slang::TargetProgram * targetProgram) Line 2217 C++
slang.dll!Slang::EndToEndCompileRequest::generateOutput(Slang::ComponentType * program) Line 2586 C++
slang.dll!Slang::EndToEndCompileRequest::generateOutput() Line 2598 C++
slang.dll!Slang::EndToEndCompileRequest::executeActionsInner() Line 3940 C++
slang.dll!Slang::EndToEndCompileRequest::executeActions() Line 3949 C++
slang.dll!Slang::EndToEndCompileRequest::compile() Line 7510 C++
slang.dll!spCompile(slang::ICompileRequest * request) Line 720 C++
slangc.exe!_compile(slang::ICompileRequest * compileRequest, int argc, const char * const * argv) Line 54 C++
slangc.exe!innerMain(Slang::StdWriters * stdWriters, slang::IGlobalSession * sharedSession, int argc, const char * const * argv) Line 119 C++
slangc.exe!slangc_main(int argc, char * * argv) Line 129 C++
slangc.exe!wmain(int argc, wchar_t * * argv) Line 154 C++
In this callstack, we do makeFuncReturnViaOutParam(), so this ends up setting the type of tanh inst as void. Since this is void, inside void CLikeSourceEmitter::emitInstResultDecl(IRInst* inst)(), do an early return.
Steps to reproduce:
Generate the target cuda code like so: ./build/Debug/bin/slangc.exe .\tests\cuda\optix-coopvec.slang -target cuda -o out.cu -Xnvrtc -I"C:/ProgramData/NVIDIA Corporation/OptiX SDK 9.0.0/include" -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/include" -capability optix_coopvec
Observe that the generated code is as described in the issue here.
The text was updated successfully, but these errors were encountered:
The coopvec intrinsics emitted won't really compile correctly without this issue fixed correctly. However this work is currently not prioritized. Will be taking this up at a later point.
Uh oh!
There was an error while loading. Please reload this page.
While working on PR #7286 it was noticed that the emission of Coopvec has some issues. Here's the problem. Generate
cuda
output for thetests/cuda/optix-coopvec.slang
test and you will see this:and then:
But it should be:
OptixCoopVec<float, 4> _S8 = optixCoopVecTanh((_S6));
What I observe is that inside
void CLikeSourceEmitter::emitInstResultDecl(IRInst* inst)
, I see thatfor
auto type = inst->getDataType();
, type is returned askIROp_VoidType
. So this function terminates earlier because of this check:When creating the inst for
tanh
, I see:In this callstack, we do
makeFuncReturnViaOutParam()
, so this ends up setting the type of tanh inst as void. Since this is void, inside void CLikeSourceEmitter::emitInstResultDecl(IRInst* inst)(), do an early return.Steps to reproduce:
Generate the target cuda code like so:
./build/Debug/bin/slangc.exe .\tests\cuda\optix-coopvec.slang -target cuda -o out.cu -Xnvrtc -I"C:/ProgramData/NVIDIA Corporation/OptiX SDK 9.0.0/include" -I"C:/Program Files/NVIDIA GPU Computing Toolkit/CUDA/v12.8/include" -capability optix_coopvec
Observe that the generated code is as described in the issue here.
The text was updated successfully, but these errors were encountered: