문제

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