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.
Configuration:
Redhat linux 5.5
CL_DRIVER_VERSION: 295.59
CL_DEVICE_VERSION: OpenCL 1.1 CUDA 4.2.1
C2050 device.