OpenCL clBuildProgram caches source, and does not recompile if #include'd source changes

I have found that if the source code string passed to clBuildProgram() does not change between program runs, then the NVIDIA OpenCL implementation does not check for changes in other source code files that are included via #include statements. This occurs whether the original build was successful or failed. This occurs even after a log-off and login cycle. There must be a cache stored somewhere by the implementation.

I use #include statements to include other OpenCL source code files as this greatly simplifies the code organization and host code complexity. So, if I make a change to a #include’d file, I definitely want the OpenCL program to be recompiled. The observed caching behavior should be disabled or modified to occur after the complete preprocessing stage.

I’ve submitted this as a bug report, but adding it to the forums here as note for others who might be derailed by this confusing behavior.

My workaround has been to add a random number generator to insert a new innocuous comment into my source code every program run.

Redhat linux 5.5
C2050 device.

Did you find any solution to this problem? I also have the same problem after 3 years…

For Linux, you can set the environment variabe CUDA_CACHE_DISABLE to 1.

For GCC, putenv(“CUDA_CACHE_DISABLE=1”);

I’ve also deleted the contents of ~/.nv/ComputeCache to good effect.

See also :