Question

I have two matrices I copy onto the device and I want to use one as the current state and the other as the next state and swap pointers between them. How can I create 2 pointers inside the device that point to those matrices in global memory inside the device? Thanks

Était-ce utile?

La solution

Just do it like in plain C. But remember, pointer are only valid within the scope of the kernel.

An example:

__kernel void mykernel(__global int *A, __global int *B, __global int *C)                                
{                   
     int id = get_global_id(0);
     __global int * p;
     if(A[id] > 10){
         p = A;
     }else{
         p = B;
     }
     C[id] = p[id];
}
Licencié sous: CC-BY-SA avec attribution
Non affilié à StackOverflow
scroll top