I got this error:
{m_message=“Variable not found (Details: Function "_rtContextValidate"
caught exception: Variable "Unresolved reference to variable ExternalTrace from _Z11SceneLaunchv" not found in scope)” …} optix::Exception &
the computational details are:
Cuda compilation tools, release 7.0, V7.0.27 // Based on LLVM 3.4svn //
.version 4.2 .target sm_30 .address_size 64
I’m using optix 6.5 and cuda 7.0.
how to solve it?
is it possible that something wrong in the ptx definition written in bold ?
hm, the PTX file is basically empty, it only includes the header.
This isn’t output from the MDL SDK, is it?
Where is this file coming from and which variable are you trying to access, where the exception is happening?
these are only the first few lines from the ptx.
the ptx include more lines of course.
I also found the variable “_Z11SceneLaunchv” in the ptx in the next line :
// .globl _Z11SceneLaunchv
.visible .entry _Z11SceneLaunchv(
)
according to the error message, it relates to the callable program that I have "ExternalTrace ".
So your CUDA file containing the function SceneLaunch contains an “rtCallableProgram” line for “ExternalTrace”?
So the error message sounds like you didn’t assign an actual “Program” object to variable in your host code.
If you have a look at the “optixCallablePrograms” example in the OptiX SDK 6.5.0, you can find such an assignment of a callable program variable “shade_normal” in the “createScene()” function in optixCallablePrograms.cpp:
ptx = sutil::getPtxString( SAMPLE_NAME, "optixCallablePrograms.cu" );
Program closest_hit_prog = context->createProgramFromPTXString( ptx, "closest_hit_radiance" );
Program shade_prog = context->createProgramFromPTXString( ptx, "shade_from_normal" );
Material material = context->createMaterial();
material->setClosestHitProgram( 0, closest_hit_prog );
material[ "shade_normal" ]->set( shade_prog );
Did you check, whether you assigned a program to the variable “shade_normal” in your cpp code?
Because the error message implies, you didn’t assign it.
I have never worked with OptiX 3.*, but I would expect, that a lot has changed since then.
As Detlef already did, I would also recommend to have a look at OptiX 6.5 Programming Guide as well as the examples delivered with the SDK.
Please have a look at the optixCallablePrograms example of OptiX SDK 6.5.0 and try to find out, what the example does differently than you do.
In optixCallablePrograms.cu, the function to be used as callable program is declared as RT_CALLABLE_PROGRAM. With this, the function appears in the .ptx file with a mangled name as _Z17shade_from_normal6float3. Do you also use RT_CALLABLE_PROGRAM for your callable program?
If this doesn’t solve your problem, it might help, if you provided some more concrete source snippets, like the declaration of the function to be used as callable program and the declaration of the callable program variable (rtCallableProgram), as well as the code around assignment of the callable program variable in your .cpp part. Currently, I’m just guessing what could be the cause of the problem ;)
there is something that I missed with the definitions.
every callable program should be declared with :
" rtDeclareVariable(rtCallableProgram<bool (const float3& , const char )>, funcname); " ?
my callable program is :
No, you don’t declare the callable programs like that, but the callable program variables, which you want to call. I would also recommend using a different name (e.g. “func_var”) for the variable than for the function you want to assign to the variable. Don’t know, if this may cause problems, if the names clash.
The example uses const float3 without the reference, I don’t know, whether references are allowed. Maybe worth a try providing the vCoord by value instead, if everything else fails.
If you are already doing this and still getting the “Variable “Unresolved reference to variable ExternalTrace from _Z11SceneLaunchv” not found in scope” error, please show me the code, where you assign the callable program variable “ExternalTrace” which you declared with rtDeclareVariable.
I compile the solution, however the ptx does not include the callable functions in the *.cu file. I’m using cuda 9.2 with optix 6.5, sm 30.
Please note that since CUDA 8.0 there are more dead code elimination techniques inside the CUDA compiler which required changes to the NVCC command line options to keep OptiX callable programs inside the generated PTX code although there is no call to them in the same module.
when doing this change ( –relocatable-device-code=true) I got a compilation error : Error 2 error : Label expected for argument 0 of instruction ‘call’
what to do?
I would always recommend using the CUDA version which with a specific OptiX version was built.
For OptiX 6.5.0 that would be CUDA 10.1 according to the OptiX 6.5.0 Release Notes.
The CUDA toolkit in turn documents to which Microsoft Visual Studio versions it’s compatible.
Since even CUDA 10.2 lists all MSVS versions from 2012 to 2019, there shouldn’t be a problem.
Of course I cannot say if that helps in any way with the information you provided so far.