cancel
Showing results for 
Search instead for 
Did you mean: 

Archives Discussions

Raistmer
Adept II

Typecast between __global float* and float*

how?

In kernel declaration I have ...(__global float* A, ....)
inside kernel I need pinters on different areas of A buffer.
I try:
float* A_ptr=(float*)A+offset;

it works for NV compiler but fails for ATI one.
How can I do such conversion in "ATI" OpenCL ?
0 Likes
7 Replies
Illusio
Journeyman III

You can't. It's an error to cast a global pointer to a local one. Those are separate memory spaces in OpenCL. If nVidia allows it, it's either because all their memory is implemented as global, and they just decided that it wasn't worth checking for because of that, or because of a bug in the compiler.

What you want to do is declare A_ptr as:

global float* A_ptr = A+offset;

 

0 Likes
Raistmer
Adept II

Thanks.
And I hope A_ptr itself will be placed in register ?
0 Likes

Originally posted by: Raistmer Thanks. And I hope A_ptr itself will be placed in register ?


Hmm, this is a good question...in theory it would be a logical and smart thing to store pointers declared inside a kernel in registers, given the fact that you can't have pointers of pointers as kernel arguments and so ambiguities aren't possible, but only AMD staff can answer precisely to this question...

0 Likes

I don't think that's entirely correct. From the spec, page 150:

Examples:
// declares a pointer p in the __private address space that
// points to an int object in address space __global
__global int *p;

 

0 Likes

Originally posted by: Illusio I don't think that's entirely correct. From the spec, page 150:

 

Examples: // declares a pointer p in the __private address space that // points to an int object in address space __global __global int *p;



That's what I've said...

0 Likes

Originally posted by: Fr4nz

 

That's what I've said...

 

 

Ahh ok, sorry then. Guess I must have misunderstood what you wrote before the edit.

0 Likes
Raistmer
Adept II

thanks both, you completely answered my question.
0 Likes