how to run two __global__ funtions simultaneously in two CUDA devices

Hi,all.
i’m new in CUDA programming. As i have two GTX560 cards, i want to know how to run two global funtions simultaneously in two desktop GeForce CUDA-suppoted cards respectively,
or can i run these global functions sequentially in one card ?

thanks,
best regards

Hi,

You may try something like that

// Select the device 0 as the curent device

cudaSetDevice(0);

Kernel1<<<gridSize,blockSize>>>();

/* Other action on device 0 */

// Select the device 1 as the curent device

cudaSetDevice(1);

Kernel2<<<gridSize,blockSize>>>();

/* Other action on device 1 */

And don’t forget to check all return values of cuda functions call

thanks a lot~

and by the way do you know how to copy data from one array to another within a device and global function(it’s not like those copying jobs between host and device)?

You can use memcpy like in a “normal” C program if you program in C. If you use another langage use the same function that if you were not in Cuda.