Called at the beginning of a SHMEM program to identify the number of processes desired.
#include <shmem.h> void start_pes(int npes);
The start_pes routine identifies the number of processes for a program. This statement must be the first statement in a program that uses IBM SHMEM communication routines.
The value of npes must be less than or equal to the value specified by MP_PROCS environment variable.
For current implementation, any npes value other than 0 is ignored. Users can only do the initialization once by invoking either shmem_init or start_pes in the beginning of their programs
#include <shmem.h> #include <stdio.h> int main (int argc, char* argv[]) { int total_tasks = -1; int my_task = -1; start_pes(0); total_tasks = _num_pes(); if (total_tasks <= 0) { printf("FAILED\n"); return 0; } else { printf("number of pes is %d\n", total_tasks); } my_task = _my_pe(); if (my_task < 0){ printf("FAILED\n"); return 0; } else { printf("my pe id is %d\n", my_task); } printf("PASSED\n"); return 0; }
Subroutines: num_pes, my_pe