philips

Porting from CUDA to OpenCL: Pointer problem

Discussion created by philips on Jun 9, 2010
Latest reply on Jun 14, 2010 by MicahVillmow
program terminates with unhandled exception

Hi.

I'm porting a program from CUDA to OpenCL. They store some data in a tree structure and from a given node in the tree, they want to access some of the information in that node.

 


the CUDA version works as it should.

the OpenCL version (running on the same data) terminates with an unhandled exception.

If I manually set colorBlock as a random unsigned long it works and does not terminate with the exception. It seems that somehow somewhere in those first seven lines something goes wrong and unsigned long colorBlock is not assigned a valid unsigned long.

 

 

New information:

 

The program now runs on a Nvidia GPU. I did not change the function at all.

 

On the CPU (with the Ati platform) there's still the same error.

 

 

 



 

 

 


I really hope someone knows what's wrong here, because I have no clue.

Thanks for reading.

 

//CUDA VERSION _device_ void lookupInfo(int* node) { int* pageHeader = (int*)( (int) node & -PageBytes ); //PageBytes is a constant int value int* blockInfo = pageHeader + *pageHeader; int* blockStart = blockInfo + blockInfo[ BlockInfo_BlockPtr ]; //BlockInfo_BlockPtr is a constant int value //the following three lines are similar to the ones above, so I ll leave the details out int* attachInfos = ... int* attachInfo = ... int* attachData = ... unsigned long long* dxtBlock = (unsigned long long*) ( attachData + ( (node - blockStart) >> 2) * 6); U64 colorBlock = dxtBlock[0]; // after that the function uses the variable colorBlock ... } //OPENCL VERSION void lookupInfo(__global int* node) { __global int* pageHeader = (__global int*)( (int) node & -PageBytes ); //PageBytes is a constant int value __global int* blockInfo = pageHeader + *pageHeader; __global int* blockStart = blockInfo + blockInfo[ BlockInfo_BlockPtr ]; //BlockInfo_BlockPtr is a constant int value //the following three lines are similar to the ones above, so I ll leave the details out __global int* attachInfos = ... __global int* attachInfo = ... __global int* attachData = ... __global unsigned long* dxtBlock = (__global unsigned long*) ( attachData + ( (node - blockStart) >> 2) * 6); unsigned long colorBlock = dxtBlock[0]; // after that the function uses the variable colorBlock ... }

Outcomes