Skip to content

Commit fe73586

Browse files
dycz0fxjsquyres
authored andcommitted
Add ADAPT module
Add comments in the ADAPT module Signed-off-by: Xi Luo <[email protected]> Signed-off-by: George Bosilca <[email protected]>
1 parent eefaadf commit fe73586

19 files changed

+2579
-8
lines changed

ompi/communicator/comm_init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -382,7 +382,9 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
382382
comm->c_pml_comm = NULL;
383383
comm->c_topo = NULL;
384384
comm->c_coll = NULL;
385-
385+
comm->c_ibcast_tag = 0;
386+
comm->c_ireduce_tag = 0;
387+
386388
/* A keyhash will be created if/when an attribute is cached on
387389
this communicator */
388390
comm->c_keyhash = NULL;

ompi/communicator/communicator.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -187,6 +187,10 @@ struct ompi_communicator_t {
187187

188188
/* Collectives module interface and data */
189189
mca_coll_base_comm_coll_t *c_coll;
190+
191+
/* Non-blocking collective tag */
192+
_Atomic int32_t c_ibcast_tag;
193+
_Atomic int32_t c_ireduce_tag;
190194
};
191195
typedef struct ompi_communicator_t ompi_communicator_t;
192196

ompi/mca/coll/adapt/Makefile.am

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
#
2+
# Copyright (c) 2014 The University of Tennessee and The University
3+
# of Tennessee Research Foundation. All rights
4+
# reserved.
5+
# $COPYRIGHT$
6+
#
7+
# Additional copyrights may follow
8+
#
9+
# $HEADER$
10+
#
11+
12+
13+
sources = \
14+
coll_adapt_component.c \
15+
coll_adapt_module.c \
16+
coll_adapt_bcast.c \
17+
coll_adapt_ibcast.c \
18+
coll_adapt_reduce.c \
19+
coll_adapt_ireduce.c \
20+
coll_adapt.h \
21+
coll_adapt_algorithms.h \
22+
coll_adapt_context.h \
23+
coll_adapt_context.c \
24+
coll_adapt_inbuf.c \
25+
coll_adapt_inbuf.h \
26+
coll_adapt_item.c \
27+
coll_adapt_item.h
28+
29+
# Make the output library in this directory, and name it either
30+
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
31+
# (for static builds).
32+
33+
component_noinst =
34+
component_install =
35+
if MCA_BUILD_ompi_coll_adapt_DSO
36+
component_install += mca_coll_adapt.la
37+
else
38+
component_noinst += libmca_coll_adapt.la
39+
endif
40+
41+
mcacomponentdir = $(ompilibdir)
42+
mcacomponent_LTLIBRARIES = $(component_install)
43+
mca_coll_adapt_la_SOURCES = $(sources)
44+
mca_coll_adapt_la_LDFLAGS = -module -avoid-version
45+
mca_coll_adapt_la_LIBADD =
46+
47+
noinst_LTLIBRARIES = $(component_noinst)
48+
libmca_coll_adapt_la_SOURCES =$(sources)
49+
libmca_coll_adapt_la_LDFLAGS = -module -avoid-version

ompi/mca/coll/adapt/coll_adapt.h

Lines changed: 98 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,98 @@
1+
/*
2+
* Copyright (c) 2014-2020 The University of Tennessee and The University
3+
* of Tennessee Research Foundation. All rights
4+
* reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
12+
13+
#ifndef MCA_COLL_ADAPT_EXPORT_H
14+
#define MCA_COLL_ADAPT_EXPORT_H
15+
16+
#include "ompi_config.h"
17+
18+
#include "mpi.h"
19+
#include "opal/mca/mca.h"
20+
#include "opal/datatype/opal_convertor.h"
21+
#include "ompi/mca/coll/coll.h"
22+
#include "ompi/mca/coll/base/coll_base_topo.h"
23+
24+
BEGIN_C_DECLS typedef struct mca_coll_adapt_module_t mca_coll_adapt_module_t;
25+
26+
/*
27+
* Structure to hold the adapt coll component. First it holds the
28+
* base coll component, and then holds a bunch of
29+
* adapt-coll-component-specific stuff (e.g., current MCA param
30+
* values).
31+
*/
32+
typedef struct mca_coll_adapt_component_t {
33+
/* Base coll component */
34+
mca_coll_base_component_2_0_0_t super;
35+
36+
/* MCA parameter: Priority of this component */
37+
int adapt_priority;
38+
39+
/* MCA parameter: Output verbose level */
40+
int adapt_output;
41+
42+
/* MCA parameter: Maximum number of segment in context free list */
43+
int adapt_context_free_list_max;
44+
45+
/* MCA parameter: Minimum number of segment in context free list */
46+
int adapt_context_free_list_min;
47+
48+
/* MCA parameter: Increasment number of segment in context free list */
49+
int adapt_context_free_list_inc;
50+
51+
/* Bcast MCA parameter */
52+
int adapt_ibcast_algorithm;
53+
size_t adapt_ibcast_segment_size;
54+
int adapt_ibcast_max_send_requests;
55+
int adapt_ibcast_max_recv_requests;
56+
/* Bcast free list */
57+
opal_free_list_t *adapt_ibcast_context_free_list;
58+
_Atomic int32_t adapt_ibcast_context_free_list_enabled;
59+
60+
/* Reduce MCA parameter */
61+
int adapt_ireduce_algorithm;
62+
size_t adapt_ireduce_segment_size;
63+
int adapt_ireduce_max_send_requests;
64+
int adapt_ireduce_max_recv_requests;
65+
int adapt_inbuf_free_list_min;
66+
int adapt_inbuf_free_list_max;
67+
int adapt_inbuf_free_list_inc;
68+
69+
/* Reduce free list */
70+
opal_free_list_t *adapt_ireduce_context_free_list;
71+
_Atomic int32_t adapt_ireduce_context_free_list_enabled;
72+
73+
} mca_coll_adapt_component_t;
74+
75+
/* Coll adapt module per communicator*/
76+
struct mca_coll_adapt_module_t {
77+
/* Base module */
78+
mca_coll_base_module_t super;
79+
80+
/* Whether this module has been lazily initialized or not yet */
81+
bool enabled;
82+
/* Pointer to mca_coll_adapt_component */
83+
mca_coll_adapt_component_t *adapt_component;
84+
};
85+
OBJ_CLASS_DECLARATION(mca_coll_adapt_module_t);
86+
87+
/* Global component instance */
88+
OMPI_MODULE_DECLSPEC extern mca_coll_adapt_component_t mca_coll_adapt_component;
89+
90+
/* ADAPT module functions */
91+
int mca_coll_adapt_init_query(bool enable_progress_threads, bool enable_mpi_threads);
92+
93+
mca_coll_base_module_t *mca_coll_adapt_comm_query(struct ompi_communicator_t *comm, int *priority);
94+
95+
/* Free ADAPT quest */
96+
int adapt_request_free(ompi_request_t ** request);
97+
98+
#endif /* MCA_COLL_ADAPT_EXPORT_H */
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
/*
2+
* Copyright (c) 2014-2020 The University of Tennessee and The University
3+
* of Tennessee Research Foundation. All rights
4+
* reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
12+
#include "ompi/mca/coll/coll.h"
13+
#include "ompi/mca/coll/base/coll_base_topo.h"
14+
#include "ompi/mca/coll/base/coll_base_functions.h"
15+
#include <math.h>
16+
17+
typedef struct mca_coll_adapt_algorithm_index_s {
18+
int algorithm_index;
19+
uintptr_t algorithm_fn_ptr;
20+
} mca_coll_adapt_algorithm_index_t;
21+
22+
/* Bcast */
23+
int mca_coll_adapt_ibcast_init(void);
24+
int mca_coll_adapt_ibcast_fini(void);
25+
int mca_coll_adapt_bcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
26+
struct ompi_communicator_t *comm, mca_coll_base_module_t * module);
27+
int mca_coll_adapt_ibcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
28+
struct ompi_communicator_t *comm, ompi_request_t ** request,
29+
mca_coll_base_module_t * module);
30+
int mca_coll_adapt_ibcast_generic(void *buff, int count, struct ompi_datatype_t *datatype, int root,
31+
struct ompi_communicator_t *comm, ompi_request_t ** request,
32+
mca_coll_base_module_t * module, ompi_coll_tree_t * tree,
33+
size_t seg_size, int ibcast_tag);
34+
int mca_coll_adapt_ibcast_binomial(void *buff, int count, struct ompi_datatype_t *datatype,
35+
int root, struct ompi_communicator_t *comm,
36+
ompi_request_t ** request, mca_coll_base_module_t * module,
37+
int ibcast_tag);
38+
int mca_coll_adapt_ibcast_in_order_binomial(void *buff, int count, struct ompi_datatype_t *datatype,
39+
int root, struct ompi_communicator_t *comm,
40+
ompi_request_t ** request,
41+
mca_coll_base_module_t * module, int ibcast_tag);
42+
int mca_coll_adapt_ibcast_binary(void *buff, int count, struct ompi_datatype_t *datatype, int root,
43+
struct ompi_communicator_t *comm, ompi_request_t ** request,
44+
mca_coll_base_module_t * module, int ibcast_tag);
45+
int mca_coll_adapt_ibcast_pipeline(void *buff, int count, struct ompi_datatype_t *datatype,
46+
int root, struct ompi_communicator_t *comm,
47+
ompi_request_t ** request, mca_coll_base_module_t * module,
48+
int ibcast_tag);
49+
int mca_coll_adapt_ibcast_chain(void *buff, int count, struct ompi_datatype_t *datatype, int root,
50+
struct ompi_communicator_t *comm, ompi_request_t ** request,
51+
mca_coll_base_module_t * module, int ibcast_tag);
52+
int mca_coll_adapt_ibcast_linear(void *buff, int count, struct ompi_datatype_t *datatype, int root,
53+
struct ompi_communicator_t *comm, ompi_request_t ** request,
54+
mca_coll_base_module_t * module, int ibcast_tag);
55+
56+
57+
/* Reduce */
58+
int mca_coll_adapt_ireduce_init(void);
59+
int mca_coll_adapt_ireduce_fini(void);
60+
int mca_coll_adapt_reduce(const void *sbuf, void *rbuf, int count, struct ompi_datatype_t *dtype,
61+
struct ompi_op_t *op, int root, struct ompi_communicator_t *comm,
62+
mca_coll_base_module_t * module);
63+
int mca_coll_adapt_ireduce(const void *sbuf, void *rbuf, int count, struct ompi_datatype_t *dtype,
64+
struct ompi_op_t *op, int root, struct ompi_communicator_t *comm,
65+
ompi_request_t ** request, mca_coll_base_module_t * module);
66+
int mca_coll_adapt_ireduce_generic(const void *sbuf, void *rbuf, int count,
67+
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
68+
struct ompi_communicator_t *comm, ompi_request_t ** request,
69+
mca_coll_base_module_t * module, ompi_coll_tree_t * tree,
70+
size_t seg_size, int ireduce_tag);
71+
int mca_coll_adapt_ireduce_binomial(const void *sbuf, void *rbuf, int count,
72+
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
73+
struct ompi_communicator_t *comm, ompi_request_t ** request,
74+
mca_coll_base_module_t * module, int ireduce_tag);
75+
int mca_coll_adapt_ireduce_in_order_binomial(const void *sbuf, void *rbuf, int count,
76+
struct ompi_datatype_t *dtype, struct ompi_op_t *op,
77+
int root, struct ompi_communicator_t *comm,
78+
ompi_request_t ** request,
79+
mca_coll_base_module_t * module, int ireduce_tag);
80+
int mca_coll_adapt_ireduce_binary(const void *sbuf, void *rbuf, int count,
81+
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
82+
struct ompi_communicator_t *comm, ompi_request_t ** request,
83+
mca_coll_base_module_t * module, int ireduce_tag);
84+
int mca_coll_adapt_ireduce_pipeline(const void *sbuf, void *rbuf, int count,
85+
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
86+
struct ompi_communicator_t *comm, ompi_request_t ** request,
87+
mca_coll_base_module_t * module, int ireduce_tag);
88+
int mca_coll_adapt_ireduce_chain(const void *sbuf, void *rbuf, int count,
89+
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
90+
struct ompi_communicator_t *comm, ompi_request_t ** request,
91+
mca_coll_base_module_t * module, int ireduce_tag);
92+
int mca_coll_adapt_ireduce_linear(const void *sbuf, void *rbuf, int count,
93+
struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root,
94+
struct ompi_communicator_t *comm, ompi_request_t ** request,
95+
mca_coll_base_module_t * module, int ireduce_tag);
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
/*
2+
* Copyright (c) 2014-2020 The University of Tennessee and The University
3+
* of Tennessee Research Foundation. All rights
4+
* reserved.
5+
* $COPYRIGHT$
6+
*
7+
* Additional copyrights may follow
8+
*
9+
* $HEADER$
10+
*/
11+
12+
#include "coll_adapt.h"
13+
#include "coll_adapt_algorithms.h"
14+
15+
int mca_coll_adapt_bcast(void *buff, int count, struct ompi_datatype_t *datatype, int root,
16+
struct ompi_communicator_t *comm, mca_coll_base_module_t * module)
17+
{
18+
if (count == 0) {
19+
return MPI_SUCCESS;
20+
} else {
21+
ompi_request_t *request;
22+
int err = mca_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
23+
ompi_request_wait(&request, MPI_STATUS_IGNORE);
24+
return err;
25+
}
26+
}

0 commit comments

Comments
 (0)