Page MenuHome

Cycles: Add support for adaptive kernel compilation to OptiX device
ClosedPublic

Authored by Patrick Mours (pmoursnv) on Fri, Feb 14, 5:07 PM.

Details

Summary

This modified the common CUDA implementation for adaptive kernel compilation slightly to support both CUBIN and PTX output (the latter which is then used in the OptiX device). I also fixed adaptive kernel compilation on Windows (it didn't work if any paths had spaces in them) and added the default CUDA 10.1 toolkit path to the search paths in CUEW.

Diff Detail

Repository
rB Blender

Event Timeline

I've been dragging my heels for years on that one, there's some additional fixes in D2019 for making it work properly on windows.

Nice! Hadn't thought of using call to resolve the command issue. That might be the simpler solution depending on whether putting the whole command in quotes works on Linux or not (I don't have the set up to test that right now).

The extra quotes make the compilation fail on Linux, if I remove them again this patch works.

We have this function used by OpenCL, which also solves issues with quotes and spaces. Perhaps make a system_call() variation of that which takes a program path as argument and use it here?

bool system_call_self(const vector<string> &args)
{
  /* Escape program and arguments in case they contain spaces. */
  string cmd = "\"" + Sysutil::this_program_path() + "\"";

  for (int i = 0; i < args.size(); i++) {
    cmd += " \"" + args[i] + "\"";
  }

#ifdef _WIN32
  /* Use cmd /S to avoid issues with spaces in arguments. */
  cmd = "cmd /S /C \"" + cmd + " > nul \"";
#else
  /* Quiet output. */
  cmd += " > /dev/null";
#endif

  return (system(cmd.c_str()) == 0);
}

The patch looks good to me otherwise.

I think we can then also not force WITH_CYCLES_CUDA_BINARIES ON for WITH_CYCLES_DEVICE_OPTIX. That's more convenient for development, now I'm turning this on/off often to keep build times fast.

if you just pillage this bit from D2019, we'd be in a pretty good shape

#ifdef _WIN32
    FILE *handle = popen("where nvcc", "r");
#else
    FILE *handle = popen("which nvcc", "r");
#endif

On Windows this still doesn't work without launching Blender from a Visual Studio command-line (because nvcc can't find the compiler otherwise). So not forcing WITH_CYCLES_CUDA_BINARIES on could be confusing without some extra documentation (then again it's on in the release build config, so only developers run into this anyway). Or maybe only force it on on Windows.

We decided this was a developer option, i was planning on leaving a note in the commit message that blender (or devenv) *HAS* to be started from the VS 2017/2019 x64 command prompt for it to work.

  • Picked remaining fixes from D2019 and fixed command execution on Linux
  • Disabled forced WITH_CYCLES_CUDA_BINARIES ON with WITH_CYCLES_DEVICE_OPTIX
This revision is now accepted and ready to land.Mon, Feb 17, 1:54 PM