質問

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

役に立ちましたか?

解決

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];
}
ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top