Template metaprogramming in Optix

Seems like we are not able to use template metaprogramming in kernel code? NVRTC complains about the following:

template <int K>
__device__ void foo() {
  int array[K];
  // something else;

There are a number of template device functions inside the OptiX SDK include folder and SDK examples.

  • Maybe start by describing your system environment:
    OS version, installed GPU(s), VRAM amount, display driver version, OptiX (major.minor.micro) version, CUDA toolkit version (major.minor) used to generate the input PTX, host compiler version.
  • then all the options you provided to the nvrtcCompileProgram() call,
  • the exact error message you got and
  • a complete and minimal reproducer code.