Returns the processing element (PE) number of the calling PE.
#include <shmem.h> int shmem_my_pe(void);
The _my_pe routine returns the processing element (PE) number of the calling PE. It takes no arguments. The result is an integer between 0 and (npes – 1), where npes is the total number of PEs executing in the current job.
#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