num_pes

Purpose

Returns the number of processing elements (PEs) running in the job.

C syntax

#include <shmem.h>
 
int num_pes(void);
 

Description

The num_pes function returns the number of PEs running in an application.

IBM NOTES

For current implementation, this value is equal to the MP_PROCS environment variable.

C examples

#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;
}

Related information

Subroutines: shmem_init, start_pes, my_pe


OpenSHMEM API Index