Source file updating Problem with C++ and multiple source files

I’ve asked about this in the Khronos OpenCL forums, but it does not seem like anyone knows what might be wrong.

The problem occurs when I’m using code with multiple source files, for example

“fox.cl”

struct Tango {

   float4 donut;

   float4 snow;

};

“mykernel.cl”

#include "fox.cl"

__kernel void myKernel(__global struct *Tango)

{

    // do some work on Tango structs

}

Now if I were to change something in fox.cl, for example

struct Tango {

   float4 donut;

   float4 snow;

   float4 wood;

};

Quite often the change will not be recognized when I rebuild the program. Trying to access member wood in the kernel function will return an error. However if I instead add something entirely new, like

struct Tango {

   float4 donut;

   float4 snow;

   float4 wood;

};

struct Swing {

   float4 bread;

   float4 rain;

   float4 brick;

};

The new struct will be recognized with all the members (however wood is typically still unacessible).

Now I haven’t found much info about how OpenCL caches the source in the documentations. I’m guessing it is platform dependent. I’m having trouble figuring out what is wrong since the problem does not occur consistently.

So, any help here as to what is going on?

I’ve asked about this in the Khronos OpenCL forums, but it does not seem like anyone knows what might be wrong.

The problem occurs when I’m using code with multiple source files, for example

“fox.cl”

struct Tango {

   float4 donut;

   float4 snow;

};

“mykernel.cl”

#include "fox.cl"

__kernel void myKernel(__global struct *Tango)

{

    // do some work on Tango structs

}

Now if I were to change something in fox.cl, for example

struct Tango {

   float4 donut;

   float4 snow;

   float4 wood;

};

Quite often the change will not be recognized when I rebuild the program. Trying to access member wood in the kernel function will return an error. However if I instead add something entirely new, like

struct Tango {

   float4 donut;

   float4 snow;

   float4 wood;

};

struct Swing {

   float4 bread;

   float4 rain;

   float4 brick;

};

The new struct will be recognized with all the members (however wood is typically still unacessible).

Now I haven’t found much info about how OpenCL caches the source in the documentations. I’m guessing it is platform dependent. I’m having trouble figuring out what is wrong since the problem does not occur consistently.

So, any help here as to what is going on?

Seems like a bug with your OpenCL implementation’s source code / kernel caching. You may try calling clUnloadCompiler before your call to clBuildProgram. But note that clUnloadCompiler is only a hint to the OpenCL implementation, so based on the implementation it may work or not.

Seems like a bug with your OpenCL implementation’s source code / kernel caching. You may try calling clUnloadCompiler before your call to clBuildProgram. But note that clUnloadCompiler is only a hint to the OpenCL implementation, so based on the implementation it may work or not.

Thanks, I also found that deleting everything in the folder NVIDIA/ComputeCache/ forces it to recognize the changes.