-:    0:Source:/home/MPI/testing/mpich2/mpich2/src/mpid/ch3/src/mpid_get_universe_size.c
        -:    0:Graph:mpid_get_universe_size.gcno
        -:    0:Data:mpid_get_universe_size.gcda
        -:    0:Runs:783
        -:    0:Programs:168
        -:    1:/* -*- Mode: C; c-basic-offset:4 ; -*- */
        -:    2:/*
        -:    3: *  (C) 2001 by Argonne National Laboratory.
        -:    4: *      See COPYRIGHT in top-level directory.
        -:    5: */
        -:    6:
        -:    7:#include "mpidimpl.h"
        -:    8:#ifdef USE_PMI2_API
        -:    9:#include "pmi2.h"
        -:   10:#else
        -:   11:#include "pmi.h"
        -:   12:#endif
        -:   13:
        -:   14:/*
        -:   15: * MPID_Get_universe_size - Get the universe size from the process manager
        -:   16: *
        -:   17: * Notes: The ch3 device requires that the PMI routines are used to 
        -:   18: * communicate with the process manager.  If a channel wishes to 
        -:   19: * bypass the standard PMI implementations, it is the responsibility of the
        -:   20: * channel to provide an implementation of the PMI routines.
        -:   21: */
        -:   22:#undef FUNCNAME
        -:   23:#define FUNCNAME MPID_Get_universe_size
        -:   24:#undef FCNAME
        -:   25:#define FCNAME MPIDI_QUOTE(FUNCNAME)
        -:   26:int MPID_Get_universe_size(int  * universe_size)
        5:   27:{
        5:   28:    int mpi_errno = MPI_SUCCESS;
        -:   29:#ifdef USE_PMI2_API
        -:   30:    char val[PMI2_MAX_VALLEN];
        -:   31:    int found = 0;
        -:   32:    char *endptr;
        -:   33:    
        -:   34:    mpi_errno = PMI2_Info_GetJobAttr("universeSize", val, sizeof(val), &found);
        -:   35:    if (mpi_errno) MPIU_ERR_POP(mpi_errno);
        -:   36:
        -:   37:    if (!found)
        -:   38:	*universe_size = MPIR_UNIVERSE_SIZE_NOT_AVAILABLE;
        -:   39:    else {
        -:   40:        *universe_size = strtol(val, &endptr, 0);
        -:   41:        MPIU_ERR_CHKINTERNAL(endptr - val != strlen(val), mpi_errno, "can't parse universe size");
        -:   42:    }
        -:   43:
        -:   44:#else
        5:   45:    int pmi_errno = PMI_SUCCESS;
        -:   46:
        5:   47:    pmi_errno = PMI_Get_universe_size(universe_size);
        5:   48:    if (pmi_errno != PMI_SUCCESS) {
    #####:   49:	MPIU_ERR_SETANDJUMP1(mpi_errno, MPI_ERR_OTHER, 
        -:   50:			     "**pmi_get_universe_size",
        -:   51:			     "**pmi_get_universe_size %d", pmi_errno);
        -:   52:    }
        5:   53:    if (*universe_size < 0)
        -:   54:    {
    #####:   55:	*universe_size = MPIR_UNIVERSE_SIZE_NOT_AVAILABLE;
        -:   56:    }
        -:   57:#endif
        -:   58:    
        5:   59:fn_exit:
        5:   60:    return mpi_errno;
        -:   61:
        -:   62:    /* --BEGIN ERROR HANDLING-- */
    #####:   63:fn_fail:
    #####:   64:    *universe_size = MPIR_UNIVERSE_SIZE_NOT_AVAILABLE;
    #####:   65:    goto fn_exit;
        -:   66:    /* --END ERROR HANDLING-- */
        -:   67:}