void Model::init_ranks (int comm) { _count++; _ready = false; //WS send_event (TO_IFACE, new M_ifc_retune (_fbase, _itemp)); for (int g = 0; g < _ngroup; g++) { Group* G = _group + g; for (int i = 0; i < G->_nifelm; i++) proc_rank (g, i, comm); } _ready = true; }
int initParallelEnv(){ omp_set_num_threads(THREADS); /* Setup MPI programming environment */ MPI_Init_thread(NULL, NULL, MPI_THREAD_MULTIPLE, &threadSupport); comm = MPI_COMM_WORLD; MPI_Comm_size(comm, &numMPIprocs); MPI_Comm_rank(comm, &myMPIRank); /*Find the number of bytes for an int */ sizeInteger = sizeof(int); /* Find the processor name of each MPI process */ MPI_Get_processor_name(myProcName, &procNameLen); /* Use processor name to create a communicator * across node boundaries. */ setupCommunicators(); /* setup OpenMP programming environment */ #pragma omp parallel shared(numThreads,globalIDarray,myMPIRank) { numThreads = omp_get_num_threads(); myThreadID = omp_get_thread_num(); /* Allocate space for globalIDarray */ #pragma omp single { globalIDarray = (int *)malloc(numThreads * sizeof(int)); } /*calculate the globalID for each thread */ globalIDarray[myThreadID] = (myMPIRank * numThreads) + myThreadID; } MPI_Barrier(comm); gaspi_config_t config; GASPI(config_get(&config)); config.qp_count = THREADS; GASPI(config_set(config)); /* GASPI setup */ GASPI(proc_init(GASPI_BLOCK)); gaspi_rank_t totalRanks; GASPI(proc_num(&totalRanks)); gaspi_rank_t rank; GASPI(proc_rank(&rank)); gaspi_number_t q_num; GASPI(queue_num(&q_num)); assert (q_num == THREADS); GASPI(barrier (GASPI_GROUP_ALL, GASPI_BLOCK)); // ok, we will continue to use the MPI ranks, just make sure GASPI and MPI ranks are identical // this is not guaranteed, so depending on the setup this may fail. assert (totalRanks == numMPIprocs); assert (rank == myMPIRank); /* set parallel info in benchmark report type */ setParallelInfo(numMPIprocs,threadSupport,numThreads); return 0; }