Skip to content

Commit

Permalink
Fix the atomic management of the bcast and reduce freelist
Browse files Browse the repository at this point in the history
API consistent with other collective modules
Add comments
Other minor cleanups.

Signed-off-by: George Bosilca <[email protected]>
  • Loading branch information
bosilca authored and jsquyres committed Aug 24, 2020
1 parent a4be3bb commit d712645
Show file tree
Hide file tree
Showing 16 changed files with 185 additions and 329 deletions.
14 changes: 9 additions & 5 deletions ompi/communicator/communicator.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
* University Research and Technology
* Corporation. All rights reserved.
* Copyright (c) 2004-2017 The University of Tennessee and The University
* Copyright (c) 2004-2020 The University of Tennessee and The University
* of Tennessee Research Foundation. All rights
* reserved.
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
Expand Down Expand Up @@ -187,10 +187,14 @@ 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;

/* Non-blocking collective tag. These are added here as they should be
* shared between all non-blocking collective modules (to avoid message
* collisions between them in the case where multiple outstanding
* non-blocking collective coexists using multiple backends).
*/
opal_atomic_int32_t c_ibcast_tag;
opal_atomic_int32_t c_ireduce_tag;
};
typedef struct ompi_communicator_t ompi_communicator_t;

Expand Down
6 changes: 3 additions & 3 deletions ompi/mca/coll/adapt/Makefile.am
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
#
# Copyright (c) 2014 The University of Tennessee and The University
# Copyright (c) 2014-2020 The University of Tennessee and The University
# of Tennessee Research Foundation. All rights
# reserved.
# $COPYRIGHT$
Expand All @@ -13,11 +13,11 @@
sources = \
coll_adapt_component.c \
coll_adapt_module.c \
coll_adapt_bcast.c \
coll_adapt_bcast.c \
coll_adapt_ibcast.c \
coll_adapt_reduce.c \
coll_adapt_ireduce.c \
coll_adapt.h \
coll_adapt.h \
coll_adapt_algorithms.h \
coll_adapt_context.h \
coll_adapt_context.c \
Expand Down
7 changes: 3 additions & 4 deletions ompi/mca/coll/adapt/coll_adapt.h
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ typedef struct mca_coll_adapt_component_t {
/* MCA parameter: Priority of this component */
int adapt_priority;

/* MCA parameter: Output verbose level */
/* MCA parameter: Output stream and verbose level */
int adapt_output;
int adapt_verbose;

/* MCA parameter: Maximum number of segment in context free list */
int adapt_context_free_list_max;
Expand All @@ -57,7 +58,6 @@ typedef struct mca_coll_adapt_component_t {
int adapt_ibcast_max_recv_requests;
/* Bcast free list */
opal_free_list_t *adapt_ibcast_context_free_list;
opal_atomic_int32_t adapt_ibcast_context_free_list_enabled;

/* Reduce MCA parameter */
int adapt_ireduce_algorithm;
Expand All @@ -70,7 +70,6 @@ typedef struct mca_coll_adapt_component_t {

/* Reduce free list */
opal_free_list_t *adapt_ireduce_context_free_list;
opal_atomic_int32_t adapt_ireduce_context_free_list_enabled;

} mca_coll_adapt_component_t;

Expand All @@ -91,7 +90,7 @@ OMPI_MODULE_DECLSPEC extern mca_coll_adapt_component_t mca_coll_adapt_component;
int ompi_coll_adapt_init_query(bool enable_progress_threads, bool enable_mpi_threads);
mca_coll_base_module_t * ompi_coll_adapt_comm_query(struct ompi_communicator_t *comm, int *priority);

/* Free ADAPT quest */
/* ADAPT request free */
int ompi_coll_adapt_request_free(ompi_request_t **request);

#endif /* MCA_COLL_ADAPT_EXPORT_H */
113 changes: 38 additions & 75 deletions ompi/mca/coll/adapt/coll_adapt_algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -20,82 +20,45 @@ typedef struct ompi_coll_adapt_algorithm_index_s {
} ompi_coll_adapt_algorithm_index_t;

/* Bcast */
int ompi_coll_adapt_ibcast_init(void);
int ompi_coll_adapt_ibcast_register(void);
int ompi_coll_adapt_ibcast_fini(void);
int ompi_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 ompi_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 ompi_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 ompi_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 ompi_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 ompi_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 ompi_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 ompi_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 ompi_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);
int ompi_coll_adapt_ibcast_tuned(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 ompi_coll_adapt_bcast(BCAST_ARGS);
int ompi_coll_adapt_ibcast(IBCAST_ARGS);
int ompi_coll_adapt_ibcast_generic(IBCAST_ARGS,
ompi_coll_tree_t * tree, size_t seg_size, int ibcast_tag);
int ompi_coll_adapt_ibcast_binomial(IBCAST_ARGS,
int ibcast_tag);
int ompi_coll_adapt_ibcast_in_order_binomial(IBCAST_ARGS,
int ibcast_tag);
int ompi_coll_adapt_ibcast_binary(IBCAST_ARGS,
int ibcast_tag);
int ompi_coll_adapt_ibcast_pipeline(IBCAST_ARGS,
int ibcast_tag);
int ompi_coll_adapt_ibcast_chain(IBCAST_ARGS,
int ibcast_tag);
int ompi_coll_adapt_ibcast_linear(IBCAST_ARGS,
int ibcast_tag);
int ompi_coll_adapt_ibcast_tuned(IBCAST_ARGS,
int ibcast_tag);

/* Reduce */
int ompi_coll_adapt_ireduce_init(void);
int ompi_coll_adapt_ireduce_register(void);
int ompi_coll_adapt_ireduce_fini(void);
int ompi_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 ompi_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 ompi_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 ompi_coll_adapt_ireduce_tuned(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 ompi_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 ompi_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 ompi_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 ompi_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 ompi_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 ompi_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);
int ompi_coll_adapt_reduce(REDUCE_ARGS);
int ompi_coll_adapt_ireduce(IREDUCE_ARGS);
int ompi_coll_adapt_ireduce_generic(IREDUCE_ARGS,
ompi_coll_tree_t * tree, size_t seg_size, int ireduce_tag);
int ompi_coll_adapt_ireduce_tuned(IREDUCE_ARGS,
int ireduce_tag);
int ompi_coll_adapt_ireduce_binomial(IREDUCE_ARGS,
int ireduce_tag);
int ompi_coll_adapt_ireduce_in_order_binomial(IREDUCE_ARGS,
int ireduce_tag);
int ompi_coll_adapt_ireduce_binary(IREDUCE_ARGS,
int ireduce_tag);
int ompi_coll_adapt_ireduce_pipeline(IREDUCE_ARGS,
int ireduce_tag);
int ompi_coll_adapt_ireduce_chain(IREDUCE_ARGS,
int ireduce_tag);
int ompi_coll_adapt_ireduce_linear(IREDUCE_ARGS,
int ireduce_tag);
13 changes: 8 additions & 5 deletions ompi/mca/coll/adapt/coll_adapt_bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,10 +17,13 @@ int ompi_coll_adapt_bcast(void *buff, int count, struct ompi_datatype_t *datatyp
{
if (count == 0) {
return MPI_SUCCESS;
} else {
ompi_request_t *request;
int err = ompi_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
ompi_request_wait(&request, MPI_STATUS_IGNORE);
return err;
}
ompi_request_t *request = NULL;
int err = ompi_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
if( MPI_SUCCESS != err ) {
if( NULL == request )
return err;
}
ompi_request_wait(&request, MPI_STATUS_IGNORE);
return err;
}
43 changes: 14 additions & 29 deletions ompi/mca/coll/adapt/coll_adapt_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,10 @@ mca_coll_adapt_component_t mca_coll_adapt_component = {

/* adapt-component specific information */

/* (default) priority */
0,
0, /* (default) priority */

/* (default) verbose level */
0,
0, /* (default) output stream */
0, /* (default) verbose level */

/* default values for non-MCA parameters */
/* Not specifying values here gives us all 0's */
Expand All @@ -78,25 +77,13 @@ mca_coll_adapt_component_t mca_coll_adapt_component = {
/* Open the component */
static int adapt_open(void)
{
int param;
mca_coll_adapt_component_t *cs = &mca_coll_adapt_component;

/*
* Get the global coll verbosity: it will be ours
*/
param = mca_base_var_find("ompi", "coll", "base", "verbose");
if (param >= 0) {
const int *verbose = NULL;
mca_base_var_get_value(param, &verbose, NULL, NULL);
if (verbose && verbose[0] > 0) {
cs->adapt_output = opal_output_open(NULL);
opal_output_set_verbosity(cs->adapt_output, verbose[0]);
}
if (cs->adapt_verbose > 0) {
cs->adapt_output = opal_output_open(NULL);
opal_output_set_verbosity(cs->adapt_output, cs->adapt_verbose);
}

opal_output_verbose(1, cs->adapt_output,
"coll:adapt:component_open: done!");

return OMPI_SUCCESS;
}

Expand Down Expand Up @@ -131,40 +118,38 @@ static int adapt_register(void)
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY, &cs->adapt_priority);

int adapt_verbose = 0;
cs->adapt_verbose = ompi_coll_base_framework.framework_verbose;
(void) mca_base_component_var_register(c, "verbose",
"Verbose level",
"Verbose level (default set to the collective framework verbosity)",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY, &adapt_verbose);
cs->adapt_output = opal_output_open(NULL);
opal_output_set_verbosity(cs->adapt_output, adapt_verbose);
MCA_BASE_VAR_SCOPE_READONLY, &cs->adapt_verbose);

cs->adapt_context_free_list_min = 10;
cs->adapt_context_free_list_min = 64;
(void) mca_base_component_var_register(c, "context_free_list_min",
"Minimum number of segments in context free list",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&cs->adapt_context_free_list_min);

cs->adapt_context_free_list_max = 10000;
cs->adapt_context_free_list_max = 1024;
(void) mca_base_component_var_register(c, "context_free_list_max",
"Maximum number of segments in context free list",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&cs->adapt_context_free_list_max);

cs->adapt_context_free_list_inc = 10;
cs->adapt_context_free_list_inc = 32;
(void) mca_base_component_var_register(c, "context_free_list_inc",
"Increasement number of segments in context free list",
MCA_BASE_VAR_TYPE_INT, NULL, 0, 0,
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&cs->adapt_context_free_list_inc);
ompi_coll_adapt_ibcast_init();
ompi_coll_adapt_ireduce_init();
ompi_coll_adapt_ibcast_register();
ompi_coll_adapt_ireduce_register();

return adapt_verify_mca_variables();
}
51 changes: 4 additions & 47 deletions ompi/mca/coll/adapt/coll_adapt_context.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,58 +12,15 @@
#include "ompi/mca/coll/coll.h"
#include "coll_adapt_context.h"

static void ompi_coll_adapt_bcast_context_constructor(ompi_coll_adapt_bcast_context_t * bcast_context)
{
}

static void ompi_coll_adapt_bcast_context_destructor(ompi_coll_adapt_bcast_context_t * bcast_context)
{
}

static void
ompi_coll_adapt_constant_bcast_context_constructor(ompi_coll_adapt_constant_bcast_context_t * con)
{
}

static void ompi_coll_adapt_constant_bcast_context_destructor(ompi_coll_adapt_constant_bcast_context_t
* con)
{
}


OBJ_CLASS_INSTANCE(ompi_coll_adapt_bcast_context_t, opal_free_list_item_t,
ompi_coll_adapt_bcast_context_constructor,
ompi_coll_adapt_bcast_context_destructor);
NULL, NULL);

OBJ_CLASS_INSTANCE(ompi_coll_adapt_constant_bcast_context_t, opal_object_t,
ompi_coll_adapt_constant_bcast_context_constructor,
ompi_coll_adapt_constant_bcast_context_destructor);

static void ompi_coll_adapt_reduce_context_constructor(ompi_coll_adapt_reduce_context_t *
reduce_context)
{
}

static void ompi_coll_adapt_reduce_context_destructor(ompi_coll_adapt_reduce_context_t *
reduce_context)
{
}

static void
ompi_coll_adapt_constant_reduce_context_constructor(ompi_coll_adapt_constant_reduce_context_t * con)
{
}

static void
ompi_coll_adapt_constant_reduce_context_destructor(ompi_coll_adapt_constant_reduce_context_t * con)
{
}

NULL, NULL);

OBJ_CLASS_INSTANCE(ompi_coll_adapt_reduce_context_t, opal_free_list_item_t,
ompi_coll_adapt_reduce_context_constructor,
ompi_coll_adapt_reduce_context_destructor);
NULL, NULL);

OBJ_CLASS_INSTANCE(ompi_coll_adapt_constant_reduce_context_t, opal_object_t,
ompi_coll_adapt_constant_reduce_context_constructor,
ompi_coll_adapt_constant_reduce_context_destructor);
NULL, NULL);
Loading

0 comments on commit d712645

Please sign in to comment.