cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

diapolo
Adept I

Basic question on pointers to vectors

I read the sample Kernels in the current ATI Stream SDK, but I can´t seem to figure out how to access vector elements (like .x and so on) if I pass a pointer to a vector to a function defined in a kernel.

Let´s say the function receives a pointer as uint4 *pVec and got it passed via &Vec. How can I access the elements in the sub-function? *pVec->x throws an error.

Thanks for your help,

Dia

0 Likes
4 Replies
nou
Exemplar

try pVec[0].x or maybe this *pVec.x

pVec->x is valid only if pVec is structure.

0 Likes

Originally posted by: nou try pVec[0].x or maybe this *pVec.x

 

pVec->x is valid only if pVec is structure.

 

Thanks nou,

pVec[0].x works, but I'm unsure if that's a supported way of working with pointers to vectors. Any official statement?

 

Dia

0 Likes

well OpenCL use C for kernels with some restrictions.

0 Likes

diapolo,
since pVec is a pointer, you need to use array indexing to access the vector that you want, and then the way to access a vector in OpenCL is specified in section 6.4 of the spec.
0 Likes