Optix compile error in PTXString

Hello. In my optix project, I have compiled the .cu file by nvrtc ,and I got the PTX string. But some error
occured when I get the programs by rtProgramCreateFromPTXString function.

The error log in optix::Exception show that :

Label expected for argument 0 of instruction ‘call’
Function ‘_rt_trace_mask_flags_64’ not declared in this scope
Call target not recongnized

I have view the PTX String and find that the ‘_rt_trace_mask_flags_64’ are compiled from the optix .cu function ‘rtTrace’.

I dont know why the nvrtc finish the compile work but error occured when get programs.

I will so happy if any one help me kill the error.


The compile options of nvrtc:

There is the RT_PROGRAM in my .cu file:

//ray type = 0 obj
RT_PROGRAM void closest_hit_cal_ao()
	float3 p_normal = geometric_normal;
	float3 hit_point = ray.origin + t_hit * ray.direction;
	prd_radiance.importance = t_hit;

	uint sample_importance = 5;
	optix::Onb onb(p_normal);
	const float inv_sqrt_samples = 1.0f / float(sample_importance);
	float all_importance = 0.0f;
	for (int i = 0; i < sample_importance; ++i)
		for (int j = 0; j < sample_importance; ++j)
			unsigned int seed = tea<4>(launch_dim.x*launch_index.y + launch_index.x, i * 27 + j * 88);
			float u1 = (float(i) + rnd(seed))*inv_sqrt_samples;
			float u2 = (float(j) + rnd(seed))*inv_sqrt_samples;

			float3 dir;
			optix::cosine_sample_hemisphere(u1, u2, dir);

			optix::Ray ray_ao = optix::make_Ray(hit_point, dir, 1, scene_epsilon, ao_length);

			PerRayData_occlusion prd;
			prd.occlusion = 0.0f;
			prd.normal = make_float3(1.0f, 1.0f, 1.0f);
			rtTrace(top_object, ray_ao, prd);

			float normal_check = dot(p_normal, dir);
			all_importance += 1.0f - prd.occlusion;
	all_importance /= float(sample_importance) * float(sample_importance);

	float3 ao_color = make_float3(all_importance);
	float3 normal_color = p_normal * 0.5f + 0.5f;
	prd_radiance.result = ao_color;

Did you post your complete compile options?
If that is all, it’s missing the include directories from CUDA and OptiX.

I’m using NVRTC as well from CUDA 8.0 or 9.0. I have not tried CUDA 10.0.
The below NVRTC options are what I’m using and this is currently running in an OptiX 6.0.0 based renderer which generates bindless callable programs at runtime that way. Though they do not call rtTrace.

// Build the include path commandline arguments. 
  const std::string cudaIncludes     = std::string("-I") + m_cudaIncludePath;
  const std::string optixIncludes    = std::string("-I") + m_optixIncludePath;
  const std::string rendererIncludes = std::string("-I") + m_rendererIncludePath;

  const char* options[] =
    "--gpu-architecture=compute_30",        // OptiX 4 supports only Kepler and newer. OptiX 6 only Maxwell and newer.
    "--use_fast_math",                      // Generate fast approximations. Requires CUDA 8.0 or newer nvrtc to work!
    "--device-as-default-execution-space",  // Force __device__ code.
    "--relocatable-device-code=true",       // Generate PTX code also for unreferenced functions. Needed since CUDA 8.0 to generate code for callable programs. --keep-device-functions is not supported by nvrtc.
    "--generate-line-info",                 // Generate line information to allow better profiling with Nsight.
    "-D__x86_64",                           // Generate 64-bit code only. Must be set or OptiX headers won't work.
    cudaIncludes.c_str(),                   // The CUDA toolkit includes.
    optixIncludes.c_str(),                  // The OptiX include path. Containing OptiX headers with the __CUDACC_RTC__ defines preventing host includes. 
    rendererIncludes.c_str()                // This renderer's headers for the shaders.

Please always provide information about your system configuration when asking about problems.
OS version, installed GPU(s), display driver version, OptiX version (major.minor.micro), CUDA toolkit version used to compile your CUDA code to PTX, host compiler version.

Thank you so much ,Detlef.
My compile options have included the include dir and I have tried options you provided, but it doesn’t work.
It is noticed that the NVRTC finished the compile, but error happend when I got the Programs.

OS : Win10 1083
GPU : GTX1060
Driver : 418.91
CUDA : 10.0
Host : VS2017 x64 Debug

I will try to use CUDA 9.0 deal with it.

Thanks again.

Did you try to use toolset v140 of VS2015 instead of v141 of VS2017?