Skip to content

Commit

Permalink
Add ADAPT module
Browse files Browse the repository at this point in the history
Add comments in the ADAPT module

Signed-off-by: Xi Luo <[email protected]>
Signed-off-by: George Bosilca <[email protected]>
  • Loading branch information
dycz0fx authored and jsquyres committed Aug 24, 2020
1 parent eefaadf commit fe73586
Show file tree
Hide file tree
Showing 19 changed files with 2,579 additions and 8 deletions.
4 changes: 3 additions & 1 deletion ompi/communicator/comm_init.c
Original file line number Diff line number Diff line change
Expand Up @@ -382,7 +382,9 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
comm->c_pml_comm = NULL;
comm->c_topo = NULL;
comm->c_coll = NULL;

comm->c_ibcast_tag = 0;
comm->c_ireduce_tag = 0;

/* A keyhash will be created if/when an attribute is cached on
this communicator */
comm->c_keyhash = NULL;
Expand Down
4 changes: 4 additions & 0 deletions ompi/communicator/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -187,6 +187,10 @@ struct ompi_communicator_t {

/* Collectives module interface and data */
mca_coll_base_comm_coll_t *c_coll;

/* Non-blocking collective tag */
_Atomic int32_t c_ibcast_tag;
_Atomic int32_t c_ireduce_tag;
};
typedef struct ompi_communicator_t ompi_communicator_t;

Expand Down
49 changes: 49 additions & 0 deletions ompi/mca/coll/adapt/Makefile.am
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
#
# Copyright (c) 2014 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# $COPYRIGHT$
#
# Additional copyrights may follow
#
# $HEADER$
#


sources = \
coll_adapt_component.c \
coll_adapt_module.c \
coll_adapt_bcast.c \
coll_adapt_ibcast.c \
coll_adapt_reduce.c \
coll_adapt_ireduce.c \
coll_adapt.h \
coll_adapt_algorithms.h \
coll_adapt_context.h \
coll_adapt_context.c \
coll_adapt_inbuf.c \
coll_adapt_inbuf.h \
coll_adapt_item.c \
coll_adapt_item.h

# Make the output library in this directory, and name it either
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
# (for static builds).

component_noinst =
component_install =
if MCA_BUILD_ompi_coll_adapt_DSO
component_install += mca_coll_adapt.la
else
component_noinst += libmca_coll_adapt.la
endif

mcacomponentdir = $(ompilibdir)
mcacomponent_LTLIBRARIES = $(component_install)
mca_coll_adapt_la_SOURCES = $(sources)
mca_coll_adapt_la_LDFLAGS = -module -avoid-version
mca_coll_adapt_la_LIBADD =

noinst_LTLIBRARIES = $(component_noinst)
libmca_coll_adapt_la_SOURCES =$(sources)
libmca_coll_adapt_la_LDFLAGS = -module -avoid-version
98 changes: 98 additions & 0 deletions ompi/mca/coll/adapt/coll_adapt.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,98 @@
/*
* Copyright (c) 2014-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/


#ifndef MCA_COLL_ADAPT_EXPORT_H
#define MCA_COLL_ADAPT_EXPORT_H

#include "ompi_config.h"

#include "mpi.h"
#include "opal/mca/mca.h"
#include "opal/datatype/opal_convertor.h"
#include "ompi/mca/coll/coll.h"
#include "ompi/mca/coll/base/coll_base_topo.h"

BEGIN_C_DECLS typedef struct mca_coll_adapt_module_t mca_coll_adapt_module_t;

/*
* Structure to hold the adapt coll component. First it holds the
* base coll component, and then holds a bunch of
* adapt-coll-component-specific stuff (e.g., current MCA param
* values).
*/
typedef struct mca_coll_adapt_component_t {
/* Base coll component */
mca_coll_base_component_2_0_0_t super;

/* MCA parameter: Priority of this component */
int adapt_priority;

/* MCA parameter: Output verbose level */
int adapt_output;

/* MCA parameter: Maximum number of segment in context free list */
int adapt_context_free_list_max;

/* MCA parameter: Minimum number of segment in context free list */
int adapt_context_free_list_min;

/* MCA parameter: Increasment number of segment in context free list */
int adapt_context_free_list_inc;

/* Bcast MCA parameter */
int adapt_ibcast_algorithm;
size_t adapt_ibcast_segment_size;
int adapt_ibcast_max_send_requests;
int adapt_ibcast_max_recv_requests;
/* Bcast free list */
opal_free_list_t *adapt_ibcast_context_free_list;
_Atomic int32_t adapt_ibcast_context_free_list_enabled;

/* Reduce MCA parameter */
int adapt_ireduce_algorithm;
size_t adapt_ireduce_segment_size;
int adapt_ireduce_max_send_requests;
int adapt_ireduce_max_recv_requests;
int adapt_inbuf_free_list_min;
int adapt_inbuf_free_list_max;
int adapt_inbuf_free_list_inc;

/* Reduce free list */
opal_free_list_t *adapt_ireduce_context_free_list;
_Atomic int32_t adapt_ireduce_context_free_list_enabled;

} mca_coll_adapt_component_t;

/* Coll adapt module per communicator*/
struct mca_coll_adapt_module_t {
/* Base module */
mca_coll_base_module_t super;

/* Whether this module has been lazily initialized or not yet */
bool enabled;
/* Pointer to mca_coll_adapt_component */
mca_coll_adapt_component_t *adapt_component;
};
OBJ_CLASS_DECLARATION(mca_coll_adapt_module_t);

/* Global component instance */
OMPI_MODULE_DECLSPEC extern mca_coll_adapt_component_t mca_coll_adapt_component;

/* ADAPT module functions */
int mca_coll_adapt_init_query(bool enable_progress_threads, bool enable_mpi_threads);

mca_coll_base_module_t *mca_coll_adapt_comm_query(struct ompi_communicator_t *comm, int *priority);

/* Free ADAPT quest */
int adapt_request_free(ompi_request_t ** request);

#endif /* MCA_COLL_ADAPT_EXPORT_H */
95 changes: 95 additions & 0 deletions ompi/mca/coll/adapt/coll_adapt_algorithms.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
/*
* Copyright (c) 2014-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "ompi/mca/coll/coll.h"
#include "ompi/mca/coll/base/coll_base_topo.h"
#include "ompi/mca/coll/base/coll_base_functions.h"
#include <math.h>

typedef struct mca_coll_adapt_algorithm_index_s {
int algorithm_index;
uintptr_t algorithm_fn_ptr;
} mca_coll_adapt_algorithm_index_t;

/* Bcast */
int mca_coll_adapt_ibcast_init(void);
int mca_coll_adapt_ibcast_fini(void);
int mca_coll_adapt_bcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, mca_coll_base_module_t * module);
int mca_coll_adapt_ibcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module);
int mca_coll_adapt_ibcast_generic(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, ompi_coll_tree_t * tree,
size_t seg_size, int ibcast_tag);
int mca_coll_adapt_ibcast_binomial(void *buff, int count, struct ompi_datatype_t *datatype,
int root, struct ompi_communicator_t *comm,
ompi_request_t ** request, mca_coll_base_module_t * module,
int ibcast_tag);
int mca_coll_adapt_ibcast_in_order_binomial(void *buff, int count, struct ompi_datatype_t *datatype,
int root, struct ompi_communicator_t *comm,
ompi_request_t ** request,
mca_coll_base_module_t * module, int ibcast_tag);
int mca_coll_adapt_ibcast_binary(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ibcast_tag);
int mca_coll_adapt_ibcast_pipeline(void *buff, int count, struct ompi_datatype_t *datatype,
int root, struct ompi_communicator_t *comm,
ompi_request_t ** request, mca_coll_base_module_t * module,
int ibcast_tag);
int mca_coll_adapt_ibcast_chain(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ibcast_tag);
int mca_coll_adapt_ibcast_linear(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ibcast_tag);


/* Reduce */
int mca_coll_adapt_ireduce_init(void);
int mca_coll_adapt_ireduce_fini(void);
int mca_coll_adapt_reduce(const void *sbuf, void *rbuf, int count, struct ompi_datatype_t *dtype,
struct ompi_op_t *op, int root, struct ompi_communicator_t *comm,
mca_coll_base_module_t * module);
int mca_coll_adapt_ireduce(const void *sbuf, void *rbuf, int count, struct ompi_datatype_t *dtype,
struct ompi_op_t *op, int root, struct ompi_communicator_t *comm,
ompi_request_t ** request, mca_coll_base_module_t * module);
int mca_coll_adapt_ireduce_generic(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, ompi_coll_tree_t * tree,
size_t seg_size, int ireduce_tag);
int mca_coll_adapt_ireduce_binomial(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ireduce_tag);
int mca_coll_adapt_ireduce_in_order_binomial(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op,
int root, struct ompi_communicator_t *comm,
ompi_request_t ** request,
mca_coll_base_module_t * module, int ireduce_tag);
int mca_coll_adapt_ireduce_binary(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ireduce_tag);
int mca_coll_adapt_ireduce_pipeline(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ireduce_tag);
int mca_coll_adapt_ireduce_chain(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ireduce_tag);
int mca_coll_adapt_ireduce_linear(const void *sbuf, void *rbuf, int count,
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
struct ompi_communicator_t *comm, ompi_request_t ** request,
mca_coll_base_module_t * module, int ireduce_tag);
26 changes: 26 additions & 0 deletions ompi/mca/coll/adapt/coll_adapt_bcast.c
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
/*
* Copyright (c) 2014-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/

#include "coll_adapt.h"
#include "coll_adapt_algorithms.h"

int mca_coll_adapt_bcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
struct ompi_communicator_t *comm, mca_coll_base_module_t * module)
{
if (count == 0) {
return MPI_SUCCESS;
} else {
ompi_request_t *request;
int err = mca_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
ompi_request_wait(&request, MPI_STATUS_IGNORE);
return err;
}
}
Loading

0 comments on commit fe73586

Please sign in to comment.