Setting based on MPI rank
This commit is contained in:
parent
4e7c8fda99
commit
9b618db185
@ -11,7 +11,7 @@
|
||||
#define ScalLBL_H
|
||||
#include "common/Domain.h"
|
||||
|
||||
extern "C" int ScaLBL_SetDevice();
|
||||
extern "C" int ScaLBL_SetDevice(int rank);
|
||||
|
||||
extern "C" void ScaLBL_AllocateDeviceMemory(void** address, size_t size);
|
||||
|
||||
|
@ -2,11 +2,12 @@
|
||||
#include <cuda.h>
|
||||
#include <stdio.h>
|
||||
|
||||
extern "C" int ScaLBL_SetDevice(){
|
||||
extern "C" int ScaLBL_SetDevice(int rank){
|
||||
int n_devices;
|
||||
int local_rank = atoi(getenv("MV2_COMM_WORLD_LOCAL_RANK"));
|
||||
//int local_rank = atoi(getenv("MV2_COMM_WORLD_LOCAL_RANK"));
|
||||
cudaGetDeviceCount(&n_devices);
|
||||
int device = local_rank % n_devices;
|
||||
//int device = local_rank % n_devices;
|
||||
int device = rank % n_devices;
|
||||
cudaSetDevice(device);
|
||||
return device;
|
||||
}
|
||||
|
@ -27,9 +27,6 @@ using namespace std;
|
||||
|
||||
int main(int argc, char **argv)
|
||||
{
|
||||
// Initialize compute device
|
||||
int device=ScaLBL_SetDevice();
|
||||
|
||||
// Initialize MPI
|
||||
int provided_thread_support = -1;
|
||||
MPI_Init_thread(&argc,&argv,MPI_THREAD_MULTIPLE,&provided_thread_support);
|
||||
@ -39,6 +36,9 @@ int main(int argc, char **argv)
|
||||
int nprocs = comm_size(comm);
|
||||
{ // Limit scope so variables that contain communicators will free before MPI_Finialize
|
||||
|
||||
// Initialize compute device
|
||||
int device=ScaLBL_SetDevice(rank);
|
||||
|
||||
// parallel domain size (# of sub-domains)
|
||||
int nprocx,nprocy,nprocz;
|
||||
int iproc,jproc,kproc;
|
||||
|
Loading…
Reference in New Issue
Block a user