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

[i]"fox.cl"[/i]
[code]
struct Tango {
float4 donut;
float4 snow;
};
[/code]

[i]"mykernel.cl"[/i]
[code]
#include "fox.cl"
__kernel void myKernel(__global struct *Tango)
{
// do some work on Tango structs
}
[/code]

Now if I were to change something in [i]fox.cl[/i], for example
[code]
struct Tango {
float4 donut;
float4 snow;
float4 wood;
};
[/code]

Quite often the change will not be recognized when I rebuild the program. Trying to access member [i]wood[/i] in the kernel function will return an error. However if I instead add something entirely new, like
[code]
struct Tango {
float4 donut;
float4 snow;
float4 wood;
};

struct Swing {
float4 bread;
float4 rain;
float4 brick;
};
[/code]

The new struct will be recognized with all the members (however [i]wood[/i] 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?

#1
Posted 01/16/2012 09:09 AM   
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

[i]"fox.cl"[/i]
[code]
struct Tango {
float4 donut;
float4 snow;
};
[/code]

[i]"mykernel.cl"[/i]
[code]
#include "fox.cl"
__kernel void myKernel(__global struct *Tango)
{
// do some work on Tango structs
}
[/code]

Now if I were to change something in [i]fox.cl[/i], for example
[code]
struct Tango {
float4 donut;
float4 snow;
float4 wood;
};
[/code]

Quite often the change will not be recognized when I rebuild the program. Trying to access member [i]wood[/i] in the kernel function will return an error. However if I instead add something entirely new, like
[code]
struct Tango {
float4 donut;
float4 snow;
float4 wood;
};

struct Swing {
float4 bread;
float4 rain;
float4 brick;
};
[/code]

The new struct will be recognized with all the members (however [i]wood[/i] 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?

#2
Posted 01/16/2012 09:09 AM   
Seems like a bug with your OpenCL implementation's source code / kernel caching. You may try calling [url="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clUnloadCompiler.html"]clUnloadCompiler[/url] 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.

#3
Posted 01/16/2012 11:25 AM   
Seems like a bug with your OpenCL implementation's source code / kernel caching. You may try calling [url="http://www.khronos.org/registry/cl/sdk/1.1/docs/man/xhtml/clUnloadCompiler.html"]clUnloadCompiler[/url] 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.

#4
Posted 01/16/2012 11:25 AM   
Thanks, I also found that deleting everything in the folder NVIDIA/ComputeCache/ forces it to recognize the changes.
Thanks, I also found that deleting everything in the folder NVIDIA/ComputeCache/ forces it to recognize the changes.

#5
Posted 01/19/2012 11:24 AM   
Scroll To Top