1
1
openmpi/ompi/mca/coll/base/coll_base_util.h
Xi Luo e65fa4ff5c Bring ADAPT collective to 4.1
This is a meta commit, that encapsulate all the ADAPT commits in the master
into a single PR for 4.1. The master commits included here are:
fe73586, a4be3bb, d712645, c2970a3, e59bde9, ee592f3 and c98e387.

Here is a detailed list of added capabilities:
* coll/adapt: Fix naming conventions and C11 atomic use
* coll/adapt: Remove unused component field in module
* Consistent handling of zero counts in the MPI API.
* Correctly handle non-blocking collectives tags
  * As it is possible to have multiple outstanding non-blocking collectives
    provided by different collective modules, we need a consistent
    mechanism to allow them to select unique tags for each instance of a
    collective.
* Add support for fallback to previous coll module on non-commutative operations (#30)
* Replace mutexes by atomic operations.
* Use the correct nbc request type (for both ibcast and ireduce)
  * coll/base: document type casts in ompi_coll_base_retain_*
* add module-wide topology cache
* use standard instead of synchronous send and add mca parameter to control mode of initial send in ireduce/ibcast
* reduce number of memory allocations
* call the default request completion.
  * Remove the requests from the Fortran lookup conversion tables before completing
    and free it.
* piggybacking Bull functionalities

Signed-off-by: Xi Luo <xluo12@vols.utk.edu>
Signed-off-by: George Bosilca <bosilca@icl.utk.edu>
Signed-off-by: Marc Sergent <marc.sergent@atos.net>
Co-authored-by: Joseph Schuchart <schuchart@hlrs.de>
Co-authored-by: Lemarinier, Pierre <pierre.lemarinier@atos.net>
Co-authored-by: pierrele <31764860+pierrele@users.noreply.github.com>
2020-09-23 11:45:45 -04:00

169 строки
5.9 KiB
C

/*
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2015 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2007 High Performance Computing Center Stuttgart,
* University of Stuttgart. All rights reserved.
* Copyright (c) 2004-2005 The Regents of the University of California.
* All rights reserved.
* Copyright (c) 2014-2019 Research Organization for Information Science
* and Technology (RIST). All rights reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
#ifndef MCA_COLL_BASE_UTIL_EXPORT_H
#define MCA_COLL_BASE_UTIL_EXPORT_H
#include "ompi_config.h"
#include "mpi.h"
#include "ompi/mca/mca.h"
#include "ompi/datatype/ompi_datatype.h"
#include "ompi/request/request.h"
#include "ompi/communicator/communicator.h"
#include "ompi/mca/coll/base/coll_tags.h"
#include "ompi/op/op.h"
#include "ompi/mca/pml/pml.h"
BEGIN_C_DECLS
/**
* Request structure to be returned by non-blocking
* collective operations.
*/
struct ompi_coll_base_nbc_request_t {
ompi_request_t super;
union {
ompi_request_complete_fn_t req_complete_cb;
ompi_request_free_fn_t req_free;
} cb;
void *req_complete_cb_data;
union {
struct {
ompi_op_t *op;
ompi_datatype_t *datatype;
} op;
struct {
ompi_datatype_t *stype;
ompi_datatype_t *rtype;
} types;
struct {
opal_object_t *objs[2];
} objs;
struct {
ompi_datatype_t **stypes;
ompi_datatype_t **rtypes;
} vecs;
} data;
};
OMPI_DECLSPEC OBJ_CLASS_DECLARATION(ompi_coll_base_nbc_request_t);
static inline int32_t
ompi_coll_base_nbc_reserve_tags(ompi_communicator_t* comm, int32_t reserve)
{
int32_t tag, old_tag;
assert( reserve > 0 );
reread_tag: /* In case we fail to atomically update the tag */
tag = old_tag = comm->c_nbc_tag;
if ((tag - reserve) < MCA_COLL_BASE_TAG_NONBLOCKING_END) {
tag = MCA_COLL_BASE_TAG_NONBLOCKING_BASE;
}
if( !OPAL_ATOMIC_COMPARE_EXCHANGE_STRONG_32(&comm->c_nbc_tag, &old_tag, tag - reserve) ) {
goto reread_tag;
}
return tag;
}
typedef struct ompi_coll_base_nbc_request_t ompi_coll_base_nbc_request_t;
/**
* A MPI_like function doing a send and a receive simultaneously.
* If one of the communications results in a zero-byte message the
* communication is ignored, and no message will cross to the peer.
*/
int ompi_coll_base_sendrecv_actual( const void* sendbuf, size_t scount,
ompi_datatype_t* sdatatype,
int dest, int stag,
void* recvbuf, size_t rcount,
ompi_datatype_t* rdatatype,
int source, int rtag,
struct ompi_communicator_t* comm,
ompi_status_public_t* status );
/**
* Similar to the function above this implementation of send-receive
* do not generate communications for zero-bytes messages. Thus, it is
* improper to use in the context of some algorithms for collective
* communications.
*/
static inline int
ompi_coll_base_sendrecv( void* sendbuf, size_t scount, ompi_datatype_t* sdatatype,
int dest, int stag,
void* recvbuf, size_t rcount, ompi_datatype_t* rdatatype,
int source, int rtag,
struct ompi_communicator_t* comm,
ompi_status_public_t* status, int myid )
{
if ((dest == source) && (source == myid)) {
return (int) ompi_datatype_sndrcv(sendbuf, (int32_t) scount, sdatatype,
recvbuf, (int32_t) rcount, rdatatype);
}
return ompi_coll_base_sendrecv_actual (sendbuf, scount, sdatatype,
dest, stag,
recvbuf, rcount, rdatatype,
source, rtag, comm, status);
}
/**
* ompi_mirror_perm: Returns mirror permutation of nbits low-order bits
* of x [*].
* [*] Warren Jr., Henry S. Hacker's Delight (2ed). 2013.
* Chapter 7. Rearranging Bits and Bytes.
*/
unsigned int ompi_mirror_perm(unsigned int x, int nbits);
/*
* ompi_rounddown: Rounds a number down to nearest multiple.
* rounddown(10,4) = 8, rounddown(6,3) = 6, rounddown(14,3) = 12
*/
int ompi_rounddown(int num, int factor);
/**
* If necessary, retain op and store it in the
* request object, which should be of type ompi_coll_base_nbc_request_t
* (will be cast internally).
*/
int ompi_coll_base_retain_op( ompi_request_t *request,
ompi_op_t *op,
ompi_datatype_t *type);
/**
* If necessary, retain the datatypes and store them in the
* request object, which should be of type ompi_coll_base_nbc_request_t
* (will be cast internally).
*/
int ompi_coll_base_retain_datatypes( ompi_request_t *request,
ompi_datatype_t *stype,
ompi_datatype_t *rtype);
/**
* If necessary, retain the datatypes and store them in the
* request object, which should be of type ompi_coll_base_nbc_request_t
* (will be cast internally).
*/
int ompi_coll_base_retain_datatypes_w( ompi_request_t *request,
ompi_datatype_t *stypes[],
ompi_datatype_t *rtypes[]);
END_C_DECLS
#endif /* MCA_COLL_BASE_UTIL_EXPORT_H */