## _my_pe

#### Purpose

Returns the processing element (PE) number of the calling PE.

#### C syntax

    #include <shmem.h>

    int _my_pe(void);

#### Description

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.

#### 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: num_pes, my_pe

OpenSHMEM API Index