CUBLAS with MPI - which gpu?

Hi,
I’m using CUBLAS 2.0 beta with the fortran wrapper. There are two geforce 280s installed in the node. I’m using MPI so I would run two processes and assign each to one of the 280.

what is the best way to determine which GPU a process has been assigned? I’d like to make sure each process has its own GPU and are not using the same one. I’m sure someone has done CUBLAS with MPI so a link would also be helpful.

Thanks.

You could use the rank in the communicator and call cudaSetDevice(rank) when the MPI process start.

Yes, I tried calling cudaSetDevice(rank) immediately followed by cudaGetDevice to check if it was set correctly. unfortunately, i get either 0 or some large negative number for both processes.

Since I’m coding in fortran90, I wrote in the wrappers for cudaSet/GetDevice in fortran.c.

int CUDA_GETDEVICE(void)

{

int dev;

cudaGetDevice(&dev);

return (int)dev;

}

int CUDA_SETDEVICE(const int *dev)

{

int retVal;

cudaSetDevice(dev);

return retVal;

}

why are you passing a pointer to cudaSetDevice?

ok i think i’ve cleaned up the code now.

int CUDA_GETDEVICE(void)
{
int dev;

cudaGetDevice(&dev);

return (int)dev;
}

int CUDA_SETDEVICE(int dev)
{

return (int)cudaSetDevice(dev);

}

I’m not familiar with C (thats why I’m using the fortran wrapper) so I tried to follow the other functions in the wrapper but probably made a language mistake somewhere?