Walltime linker option not working as documented in ptxjit sample.

The sample program 6_Advanced/ptxjit code doesn’t capture the wall time for a link. Partial code is

CUjit_option options[6];
  void *optionVals[6];
  float walltime = 0;    /* I added this initial value myself */
  char error_log[8192], info_log[8192];
  unsigned int logSize = 8192;
  void *cuOut;
  size_t outSize;
  int myErr = 0;
  std::string module_path, ptx_source;

  // Setup linker options
  // Return walltime from JIT compilation
  options[0] = CU_JIT_WALL_TIME;
  optionVals[0] = (void *)&walltime;
  checkCudaErrors(cuLinkComplete(*lState, &cuOut, &outSize));
  printf("CUDA Link Completed in %fms. Linker Output:\n%s\n", walltime,

After executing this code, the value of walltime is unchanged.

What actually happens…
I looked at the optionVals[0] with a debugger.
Each of the three Link calls (create, add, complete) stores a floating point value in optionVals[0] lower 32 bits, not affected by its value before that call. I also added several more AddFile calls for dummy PTX files, and each of these produced an optionVals[0] value slightly greater than the previous time.
The documentation for CU_JIT_WALL_TIME is wrong. It should note that the time is written separately for each cuLink call, and only the low 32 bits are overwritten (the high 32 bits on a 64-bit host are ignored). It should also state (and I don’t know the answer here) whether the times are for the individual steps or cumulative for the entire link. If it is cumulative, then state that it does not include any time spent between steps, only the steps themselves.
The sample code is wrong. Line 3 and line 14 are irrelevant. Line 17 ‘walltime’ should read something like ‘* reinterpret_cast< float * > (&optionVals[0]’.

Thanks for pointing this out. I would encourage you to file a bug using the instructions in the sticky post at the top of this sub-forum.

Actually, I got some of this wrong.
The cuLink functions add their time to the current option value and write the total into the option value.
cuModuleLoadDataEx () behavior is actually undocumented, as the meaning of each CUjit_option value is documented as applying to compiler and/or linker. There’s no mention about loading. What I’ve observed is that it writes 0 into the CU_JIT_WALL_TIME, CU_JIT_INFO_LOG_BUFFER_SIZE_BYTES, and CU_JIT_ERROR_LOG_BUFFER_SIZE_BYTES option values, and an empty string into *CU_JIT_INFO_LOG_BUFFER and CU_JIT_ERROR_LOG_BUFFER. I haven’t tried any of the other options to see if they have any effect.
I assume this is a bug, as there presumably was a purpose in providing options to this function.