Blame src/include/mpir_contextid.h

Packit Service c5cf8c
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil ; -*- */
Packit Service c5cf8c
/*
Packit Service c5cf8c
 *  (C) 2001 by Argonne National Laboratory.
Packit Service c5cf8c
 *      See COPYRIGHT in top-level directory.
Packit Service c5cf8c
 *
Packit Service c5cf8c
 */
Packit Service c5cf8c
Packit Service c5cf8c
#ifndef MPIR_CONTEXTID_H_INCLUDED
Packit Service c5cf8c
#define MPIR_CONTEXTID_H_INCLUDED
Packit Service c5cf8c
Packit Service c5cf8c
#define MPIR_CONTEXT_ID_T_DATATYPE MPI_UINT16_T
Packit Service c5cf8c
typedef uint16_t MPIR_Context_id_t;
Packit Service c5cf8c
#define MPIR_INVALID_CONTEXT_ID ((MPIR_Context_id_t)0xffff)
Packit Service c5cf8c
Packit Service c5cf8c
/* The following preprocessor macros provide bitfield access information for
Packit Service c5cf8c
 * context ID values.  They follow a uniform naming pattern:
Packit Service c5cf8c
 *
Packit Service c5cf8c
 * MPIR_CONTEXT_foo_WIDTH - the width in bits of the field
Packit Service c5cf8c
 * MPIR_CONTEXT_foo_MASK  - A valid bit mask for bit-wise AND and OR operations
Packit Service c5cf8c
 *                          with exactly all of the bits in the field set.
Packit Service c5cf8c
 * MPIR_CONTEXT_foo_SHIFT - The number of bits that the field should be shifted
Packit Service c5cf8c
 *                          rightwards to place it in the least significant bits
Packit Service c5cf8c
 *                          of the ID.  There may still be higher order bits
Packit Service c5cf8c
 *                          from other fields, so the _MASK should be used first
Packit Service c5cf8c
 *                          if you want to reliably retrieve the exact value of
Packit Service c5cf8c
 *                          the field.
Packit Service c5cf8c
 */
Packit Service c5cf8c
Packit Service c5cf8c
/* yields an rvalue that is the value of the field_name_ in the least significant bits */
Packit Service c5cf8c
#define MPIR_CONTEXT_READ_FIELD(field_name_,id_) \
Packit Service c5cf8c
    (((id_) & MPIR_CONTEXT_##field_name_##_MASK) >> MPIR_CONTEXT_##field_name_##_SHIFT)
Packit Service c5cf8c
/* yields an rvalue that is the old_id_ with field_name_ set to field_val_ */
Packit Service c5cf8c
#define MPIR_CONTEXT_SET_FIELD(field_name_,old_id_,field_val_) \
Packit Service c5cf8c
    ((old_id_ & ~MPIR_CONTEXT_##field_name_##_MASK) | ((field_val_) << MPIR_CONTEXT_##field_name_##_SHIFT))
Packit Service c5cf8c
Packit Service c5cf8c
/* Context suffixes for separating pt2pt and collective communication */
Packit Service c5cf8c
#define MPIR_CONTEXT_SUFFIX_WIDTH (1)
Packit Service c5cf8c
#define MPIR_CONTEXT_SUFFIX_SHIFT (0)
Packit Service c5cf8c
#define MPIR_CONTEXT_SUFFIX_MASK ((1 << MPIR_CONTEXT_SUFFIX_WIDTH) - 1)
Packit Service c5cf8c
#define MPIR_CONTEXT_INTRA_PT2PT (0)
Packit Service c5cf8c
#define MPIR_CONTEXT_INTRA_COLL  (1)
Packit Service c5cf8c
#define MPIR_CONTEXT_INTER_PT2PT (0)
Packit Service c5cf8c
#define MPIR_CONTEXT_INTER_COLL  (1)
Packit Service c5cf8c
Packit Service c5cf8c
/* Used to derive context IDs for sub-communicators from a parent communicator's
Packit Service c5cf8c
   context ID value.  This field comes after the one bit suffix.
Packit Service c5cf8c
   values are shifted left by 1. */
Packit Service c5cf8c
#define MPIR_CONTEXT_SUBCOMM_WIDTH (2)
Packit Service c5cf8c
#define MPIR_CONTEXT_SUBCOMM_SHIFT (MPIR_CONTEXT_SUFFIX_WIDTH + MPIR_CONTEXT_SUFFIX_SHIFT)
Packit Service c5cf8c
#define MPIR_CONTEXT_SUBCOMM_MASK      (((1 << MPIR_CONTEXT_SUBCOMM_WIDTH) - 1) << MPIR_CONTEXT_SUBCOMM_SHIFT)
Packit Service c5cf8c
Packit Service c5cf8c
/* these values may be added/subtracted directly to/from an existing context ID
Packit Service c5cf8c
 * in order to determine the context ID of the child/parent */
Packit Service c5cf8c
#define MPIR_CONTEXT_PARENT_OFFSET    (0 << MPIR_CONTEXT_SUBCOMM_SHIFT)
Packit Service c5cf8c
#define MPIR_CONTEXT_INTRANODE_OFFSET (1 << MPIR_CONTEXT_SUBCOMM_SHIFT)
Packit Service c5cf8c
#define MPIR_CONTEXT_INTERNODE_OFFSET (2 << MPIR_CONTEXT_SUBCOMM_SHIFT)
Packit Service c5cf8c
Packit Service c5cf8c
/* this field (IS_LOCALCOM) is used to derive a context ID for local
Packit Service c5cf8c
 * communicators of intercommunicators without communication */
Packit Service c5cf8c
#define MPIR_CONTEXT_IS_LOCALCOMM_WIDTH (1)
Packit Service c5cf8c
#define MPIR_CONTEXT_IS_LOCALCOMM_SHIFT (MPIR_CONTEXT_SUBCOMM_SHIFT + MPIR_CONTEXT_SUBCOMM_WIDTH)
Packit Service c5cf8c
#define MPIR_CONTEXT_IS_LOCALCOMM_MASK (((1 << MPIR_CONTEXT_IS_LOCALCOMM_WIDTH) - 1) << MPIR_CONTEXT_IS_LOCALCOMM_SHIFT)
Packit Service c5cf8c
Packit Service c5cf8c
/* MPIR_MAX_CONTEXT_MASK is the number of ints that make up the bit vector that
Packit Service c5cf8c
 * describes the context ID prefix space.
Packit Service c5cf8c
 *
Packit Service c5cf8c
 * The following must hold:
Packit Service c5cf8c
 * (num_bits_in_vector) <= (maximum_context_id_prefix)
Packit Service c5cf8c
 *   which is the following in concrete terms:
Packit Service c5cf8c
 * MPIR_MAX_CONTEXT_MASK*MPIR_CONTEXT_INT_BITS <= 2**(MPIR_CONTEXT_ID_BITS - (MPIR_CONTEXT_PREFIX_SHIFT + MPIR_CONTEXT_DYNAMIC_PROC_WIDTH))
Packit Service c5cf8c
 *
Packit Service c5cf8c
 * We currently always assume MPIR_CONTEXT_INT_BITS is 32, regardless of the
Packit Service c5cf8c
 * value of sizeof(int)*CHAR_BITS.  We also make the assumption that CHAR_BITS==8.
Packit Service c5cf8c
 *
Packit Service c5cf8c
 * For a 16-bit context id field and CHAR_BITS==8, this implies MPIR_MAX_CONTEXT_MASK <= 256
Packit Service c5cf8c
 */
Packit Service c5cf8c
Packit Service c5cf8c
/* number of bits to shift right by in order to obtain the context ID prefix */
Packit Service c5cf8c
#define MPIR_CONTEXT_PREFIX_SHIFT (MPIR_CONTEXT_IS_LOCALCOMM_SHIFT + MPIR_CONTEXT_IS_LOCALCOMM_WIDTH)
Packit Service c5cf8c
#define MPIR_CONTEXT_PREFIX_WIDTH (MPIR_CONTEXT_ID_BITS - (MPIR_CONTEXT_PREFIX_SHIFT + MPIR_CONTEXT_DYNAMIC_PROC_WIDTH))
Packit Service c5cf8c
#define MPIR_CONTEXT_PREFIX_MASK (((1 << MPIR_CONTEXT_PREFIX_WIDTH) - 1) << MPIR_CONTEXT_PREFIX_SHIFT)
Packit Service c5cf8c
Packit Service c5cf8c
#define MPIR_CONTEXT_DYNAMIC_PROC_WIDTH (1)     /* the upper half is reserved for dynamic procs */
Packit Service c5cf8c
#define MPIR_CONTEXT_DYNAMIC_PROC_SHIFT (MPIR_CONTEXT_ID_BITS - MPIR_CONTEXT_DYNAMIC_PROC_WIDTH)        /* the upper half is reserved for dynamic procs */
Packit Service c5cf8c
#define MPIR_CONTEXT_DYNAMIC_PROC_MASK (((1 << MPIR_CONTEXT_DYNAMIC_PROC_WIDTH) - 1) << MPIR_CONTEXT_DYNAMIC_PROC_SHIFT)
Packit Service c5cf8c
Packit Service c5cf8c
/* should probably be (sizeof(int)*CHAR_BITS) once we make the code CHAR_BITS-clean */
Packit Service c5cf8c
#define MPIR_CONTEXT_INT_BITS (32)
Packit Service c5cf8c
#define MPIR_CONTEXT_ID_BITS (sizeof(MPIR_Context_id_t)*8)      /* 8 --> CHAR_BITS eventually */
Packit Service c5cf8c
#define MPIR_MAX_CONTEXT_MASK \
Packit Service c5cf8c
    ((1 << (MPIR_CONTEXT_ID_BITS - (MPIR_CONTEXT_PREFIX_SHIFT + MPIR_CONTEXT_DYNAMIC_PROC_WIDTH))) / MPIR_CONTEXT_INT_BITS)
Packit Service c5cf8c
Packit Service c5cf8c
/* Utility routines.  Where possible, these are kept in the source directory
Packit Service c5cf8c
   with the other comm routines (src/mpi/comm, in mpicomm.h).  However,
Packit Service c5cf8c
   to create a new communicator after a spawn or connect-accept operation,
Packit Service c5cf8c
   the device may need to create a new contextid */
Packit Service c5cf8c
int MPIR_Get_contextid_sparse(MPIR_Comm * comm_ptr, MPIR_Context_id_t * context_id, int ignore_id);
Packit Service c5cf8c
int MPIR_Get_contextid_sparse_group(MPIR_Comm * comm_ptr, MPIR_Group * group_ptr, int tag,
Packit Service c5cf8c
                                    MPIR_Context_id_t * context_id, int ignore_id);
Packit Service c5cf8c
Packit Service c5cf8c
int MPIR_Get_contextid_nonblock(MPIR_Comm * comm_ptr, MPIR_Comm * newcommp, MPIR_Request ** req);
Packit Service c5cf8c
int MPIR_Get_intercomm_contextid_nonblock(MPIR_Comm * comm_ptr, MPIR_Comm * newcommp,
Packit Service c5cf8c
                                          MPIR_Request ** req);
Packit Service c5cf8c
Packit Service c5cf8c
void MPIR_Free_contextid(MPIR_Context_id_t);
Packit Service c5cf8c
Packit Service c5cf8c
#endif /* MPIR_CONTEXTID_H_INCLUDED */