0
votes

I have a bit of a difficult problem to solve. I have two arrays, one is a fixed size for every kernel call and is a regular 3D grid mapped to a 1D array. lets call this array meshData the second array holds x,y,z coordinates and values of those points, which are not aligned with the meshData array. lets call this pointData.

now I need run over the meshData array using OpenCL and I pass both arrays to the kernel as well as the number of points stored in the pointData array. inside the kernel I have calculate the x,y,z coordinates of the current element in the meshData without any issues and then I use those coordinates to find all points in the pointData array by using a for loop. inside the for loop I have an if-statement saying that

for (l = 0; l < points; l++) {
    if(x1Cell <=pointdata[l*indexOffset] && x2Cell >= pointData[l*indexOffset && 
       y1Cell <=pointdata[l*indexOffset + 1] && y2Cell >=pointdata[l*indexOffset + 1] &&
       z1Cell <=pointdata[l*indexOffset + 2] && z2Cell >=pointdata[l*indexOffset + 2]){

    }
}

the problem is that if I hardcode values for x1Cell, x2Cell and so on then the code gets inside the if statement, but if I use calculated values for x1Cell etc then the condition never gets past y1Cell.

i have the entire code fully functional as non-OpenCL, so I know it works. Is there something in OpenCL that I have missed in the above?

1
You are missing a closing "]" in "pointData[l*indexOffset &&". - chippies
thanks for pointing that out. it wasn't actually the problem since I created the above for the post and it was untested. However, I found the problem to the problem, which is completely unrelated. The answer will follow below - airtruk

1 Answers

0
votes

The above described problem was not with the if-statement, but rater a section of code that calculated the x,y and z offset in the 1D array so I could relate it to the original 3D coordinates. it pays off to thoroughly check your variable calculation!

i had to calculate x,y and z from the get_global_id() using modulus and I simply stuffed up the conditions to check and got offsets that actually didn't exist and therefore the above mentioned long if-statement could never become true!