[petsc-dev] bad code that needs fixing
Barry Smith
bsmith at mcs.anl.gov
Sat Mar 16 20:41:22 CDT 2013
{
int size;
ierr = MPI_Comm_size(PETSC_COMM_WORLD,&size);CHKERRQ(ierr);
if (size>1) {
int devCount, device, rank;
ierr = cudaGetDeviceCount(&devCount);CHKERRQ(ierr);
ierr = MPI_Comm_rank(PETSC_COMM_WORLD,&rank);CHKERRQ(ierr);
device = rank % devCount;
ierr = cudaSetDevice(device);CHKERRQ(ierr);
} else {
int device;
/* the code below works for serial GPU simulations */
ierr = PetscOptionsGetInt(NULL,"-cuda_set_device", &device, &flg1);CHKERRQ(ierr);
if (flg1) {
ierr = cudaSetDevice(device);CHKERRQ(ierr);
}
}
}
size int should be PETScMPIInt and device int cannot be an int if it is passed to PetscOptionsGetInt which requires a PetscInt.
More information about the petsc-dev
mailing list