Skip to content

Commit

Permalink
Coll/adapt Bull (#15)
Browse files Browse the repository at this point in the history
* piggybacking Bull functionalities

* coll/adapt: Fix naming conventions and C11 atomic use

This commit fixes some naming convention issues, such as function names
which should follow the naming ompi_coll_adapt instead of
mca_coll_adapt, reserved for component and module naming (cf. tuned
collective component);

It also fixes the use of _Atomic construct, which is only valid in C11.
OPAL constructs have already been adapted to that use, so use
opal_atomic_* types instead.

* coll/adapt: Remove unused component field in module

This commit removes an unneeded field referencing the component in the
module of adapt, as it is already available through the
mca_coll_adapt_component global variable.

Signed-off-by: Marc Sergent <[email protected]>
Co-authored-by: Lemarinier, Pierre <[email protected]>
Co-authored-by: pierrele <[email protected]>
  • Loading branch information
3 people authored and jsquyres committed Aug 24, 2020
1 parent fe73586 commit a4be3bb
Show file tree
Hide file tree
Showing 14 changed files with 343 additions and 296 deletions.
25 changes: 12 additions & 13 deletions ompi/mca/coll/adapt/coll_adapt.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,13 +21,15 @@
#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;
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).
* values).
*/
typedef struct mca_coll_adapt_component_t {
/* Base coll component */
Expand All @@ -45,7 +47,7 @@ typedef struct mca_coll_adapt_component_t {
/* 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 */
/* MCA parameter: Increasement number of segment in context free list */
int adapt_context_free_list_inc;

/* Bcast MCA parameter */
Expand All @@ -55,7 +57,7 @@ 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;
_Atomic int32_t adapt_ibcast_context_free_list_enabled;
opal_atomic_int32_t adapt_ibcast_context_free_list_enabled;

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

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

} mca_coll_adapt_component_t;

Expand All @@ -78,21 +80,18 @@ struct mca_coll_adapt_module_t {
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;
bool adapt_enabled;
};
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);
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 */
int adapt_request_free(ompi_request_t ** request);
int ompi_coll_adapt_request_free(ompi_request_t **request);

#endif /* MCA_COLL_ADAPT_EXPORT_H */
#endif /* MCA_COLL_ADAPT_EXPORT_H */
56 changes: 31 additions & 25 deletions ompi/mca/coll/adapt/coll_adapt_algorithms.h
Original file line number Diff line number Diff line change
Expand Up @@ -14,82 +14,88 @@
#include "ompi/mca/coll/base/coll_base_functions.h"
#include <math.h>

typedef struct mca_coll_adapt_algorithm_index_s {
typedef struct ompi_coll_adapt_algorithm_index_s {
int algorithm_index;
uintptr_t algorithm_fn_ptr;
} mca_coll_adapt_algorithm_index_t;
} ompi_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,
int ompi_coll_adapt_ibcast_init(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 mca_coll_adapt_ibcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
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 mca_coll_adapt_ibcast_generic(void *buff, int count, struct ompi_datatype_t *datatype, int root,
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 mca_coll_adapt_ibcast_binomial(void *buff, int count, struct ompi_datatype_t *datatype,
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 mca_coll_adapt_ibcast_in_order_binomial(void *buff, int count, struct ompi_datatype_t *datatype,
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 mca_coll_adapt_ibcast_binary(void *buff, int count, struct ompi_datatype_t *datatype, int root,
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 mca_coll_adapt_ibcast_pipeline(void *buff, int count, struct ompi_datatype_t *datatype,
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 mca_coll_adapt_ibcast_chain(void *buff, int count, struct ompi_datatype_t *datatype, int root,
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 mca_coll_adapt_ibcast_linear(void *buff, int count, struct ompi_datatype_t *datatype, int root,
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);

/* 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,
int ompi_coll_adapt_ireduce_init(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 mca_coll_adapt_ireduce(const void *sbuf, void *rbuf, int count, struct ompi_datatype_t *dtype,
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 mca_coll_adapt_ireduce_generic(const void *sbuf, void *rbuf, int count,
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 mca_coll_adapt_ireduce_binomial(const void *sbuf, void *rbuf, int count,
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 mca_coll_adapt_ireduce_in_order_binomial(const void *sbuf, void *rbuf, int count,
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 mca_coll_adapt_ireduce_binary(const void *sbuf, void *rbuf, int count,
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 mca_coll_adapt_ireduce_pipeline(const void *sbuf, void *rbuf, int count,
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 mca_coll_adapt_ireduce_chain(const void *sbuf, void *rbuf, int count,
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 mca_coll_adapt_ireduce_linear(const void *sbuf, void *rbuf, int count,
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);
4 changes: 2 additions & 2 deletions ompi/mca/coll/adapt/coll_adapt_bcast.c
Original file line number Diff line number Diff line change
Expand Up @@ -12,14 +12,14 @@
#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,
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)
{
if (count == 0) {
return MPI_SUCCESS;
} else {
ompi_request_t *request;
int err = mca_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
int err = ompi_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
ompi_request_wait(&request, MPI_STATUS_IGNORE);
return err;
}
Expand Down
82 changes: 49 additions & 33 deletions ompi/mca/coll/adapt/coll_adapt_component.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,35 +36,32 @@ static int adapt_register(void);
*/

mca_coll_adapt_component_t mca_coll_adapt_component = {

/* First, fill in the super */

{
/* First, the mca_component_t struct containing meta
information about the component itself */

{
MCA_COLL_BASE_VERSION_2_0_0,

/* Component name and version */
"adapt",
OMPI_MAJOR_VERSION,
OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION,

/* Component functions */
adapt_open, /* open */
adapt_close,
NULL, /* query */
adapt_register},
{
/* The component is not checkpoint ready */
MCA_BASE_METADATA_PARAM_NONE},

/* Initialization / querying functions */
mca_coll_adapt_init_query,
mca_coll_adapt_comm_query,
},
/* First, the mca_component_t struct containing meta
information about the component itself */
.collm_version = {
MCA_COLL_BASE_VERSION_2_0_0,

/* Component name and version */
.mca_component_name = "adapt",
MCA_BASE_MAKE_VERSION(component, OMPI_MAJOR_VERSION, OMPI_MINOR_VERSION,
OMPI_RELEASE_VERSION),

/* Component functions */
.mca_open_component = adapt_open,
.mca_close_component = adapt_close,
.mca_register_component_params = adapt_register,
},
.collm_data = {
/* The component is not checkpoint ready */
MCA_BASE_METADATA_PARAM_NONE
},

/* Initialization / querying functions */
.collm_init_query = ompi_coll_adapt_init_query,
.collm_comm_query = ompi_coll_adapt_comm_query,
},

/* adapt-component specific information */

Expand All @@ -81,15 +78,34 @@ 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]);
}
}

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

return OMPI_SUCCESS;
}


/* Shut down the component */
static int adapt_close(void)
{
mca_coll_adapt_ibcast_fini();
mca_coll_adapt_ireduce_fini();
ompi_coll_adapt_ibcast_fini();
ompi_coll_adapt_ireduce_fini();

return OMPI_SUCCESS;
}
Expand Down Expand Up @@ -125,15 +141,15 @@ static int adapt_register(void)
opal_output_set_verbosity(cs->adapt_output, adapt_verbose);

cs->adapt_context_free_list_min = 10;
(void) mca_base_component_var_register(c, "context_free_list_max",
(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;
(void) mca_base_component_var_register(c, "context_free_list_min",
(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,
Expand All @@ -147,8 +163,8 @@ static int adapt_register(void)
OPAL_INFO_LVL_9,
MCA_BASE_VAR_SCOPE_READONLY,
&cs->adapt_context_free_list_inc);
mca_coll_adapt_ibcast_init();
mca_coll_adapt_ireduce_init();
ompi_coll_adapt_ibcast_init();
ompi_coll_adapt_ireduce_init();

return adapt_verify_mca_variables();
}
Loading

0 comments on commit a4be3bb

Please sign in to comment.