cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

firemars
Journeyman III

The order of parameters in kernel function

Hi all, I got a problem when I run my application on Intel i7 CPU.

First all, the code works fine on my AMD GPU.

But when I run it on CPU, I got segment fault when I access the memory object in the kernel function. The problem is very weird.

if my kernel function is like this: kernel(int variable, __global buffer), I got segment fault when I access buffer.

But if I exchange the order of parameters: kernel(__global buffer, int variable), it works fine.

In addition, if I add one more int variable before buffer: kernel(int var, int var, __global buffer), it also works.

So I am wondering whether some alignement problem is incurred when I run the code on CPU. By the way, my CPU is 64bit.

0 Likes
3 Replies
Bdot
Adept III

I had a similarly odd behavior once. I had copied a few bytes more for the buffer than I actually allocated ... this worked on some devices, on others it crashed.

Also, what type is your buffer?  "__global buffer" is certainly not the full declaration. Do the definitions match to what the host writes to the buffer?

Alignment is certainly not an issue as the CPU can access odd addresses (it just takes longer) - the GPU does not like it. But you wrote it works on GPU but not on CPU ...

0 Likes
scharupa
Staff

your declaration is wrong:

should be like:

kernal(__global <datatype> buffer)

or kernal(__global int buffer)

or kernal(__global int *buffer)

0 Likes

__global int b is invalid too. global local and constant must be pointers.

0 Likes