Skip to content

Commit edf03e5

Browse files
authored
Merge pull request #7944 from bosilca/4.1/adapt
Import the ADAPT collective into the 4.1
2 parents 3ec835d + e65fa4f commit edf03e5

27 files changed

+2487
-38
lines changed

ompi/communicator/comm_init.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2017 The University of Tennessee and The University
6+
* Copyright (c) 2004-2020 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -39,6 +39,7 @@
3939
#include "ompi/constants.h"
4040
#include "ompi/mca/pml/pml.h"
4141
#include "ompi/mca/coll/base/base.h"
42+
#include "ompi/mca/coll/base/coll_tags.h"
4243
#include "ompi/mca/topo/base/base.h"
4344
#include "ompi/runtime/params.h"
4445
#include "ompi/communicator/communicator.h"
@@ -378,6 +379,7 @@ static void ompi_comm_construct(ompi_communicator_t* comm)
378379
comm->c_pml_comm = NULL;
379380
comm->c_topo = NULL;
380381
comm->c_coll = NULL;
382+
comm->c_nbc_tag = MCA_COLL_BASE_TAG_NONBLOCKING_BASE;
381383

382384
/* A keyhash will be created if/when an attribute is cached on
383385
this communicator */

ompi/communicator/communicator.h

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
* Copyright (c) 2004-2005 The Trustees of Indiana University and Indiana
44
* University Research and Technology
55
* Corporation. All rights reserved.
6-
* Copyright (c) 2004-2017 The University of Tennessee and The University
6+
* Copyright (c) 2004-2020 The University of Tennessee and The University
77
* of Tennessee Research Foundation. All rights
88
* reserved.
99
* Copyright (c) 2004-2005 High Performance Computing Center Stuttgart,
@@ -187,6 +187,13 @@ 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. These tags might be shared between
192+
* all non-blocking collective modules (to avoid message collision
193+
* between them in the case where multiple outstanding non-blocking
194+
* collective coexists using multiple backends).
195+
*/
196+
volatile int32_t c_nbc_tag;
190197
};
191198
typedef struct ompi_communicator_t ompi_communicator_t;
192199

ompi/mca/coll/adapt/Makefile.am

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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+
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+
coll_adapt_topocache.c \
29+
coll_adapt_topocache.h
30+
31+
# Make the output library in this directory, and name it either
32+
# mca_<type>_<name>.la (for DSO builds) or libmca_<type>_<name>.la
33+
# (for static builds).
34+
35+
component_noinst =
36+
component_install =
37+
if MCA_BUILD_ompi_coll_adapt_DSO
38+
component_install += mca_coll_adapt.la
39+
else
40+
component_noinst += libmca_coll_adapt.la
41+
endif
42+
43+
mcacomponentdir = $(ompilibdir)
44+
mcacomponent_LTLIBRARIES = $(component_install)
45+
mca_coll_adapt_la_SOURCES = $(sources)
46+
mca_coll_adapt_la_LDFLAGS = -module -avoid-version
47+
mca_coll_adapt_la_LIBADD =
48+
49+
noinst_LTLIBRARIES = $(component_noinst)
50+
libmca_coll_adapt_la_SOURCES =$(sources)
51+
libmca_coll_adapt_la_LDFLAGS = -module -avoid-version

ompi/mca/coll/adapt/coll_adapt.h

Lines changed: 145 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,145 @@
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
25+
26+
typedef struct mca_coll_adapt_module_t mca_coll_adapt_module_t;
27+
28+
typedef enum {
29+
OMPI_COLL_ADAPT_ALGORITHM_TUNED = 0,
30+
OMPI_COLL_ADAPT_ALGORITHM_BINOMIAL,
31+
OMPI_COLL_ADAPT_ALGORITHM_IN_ORDER_BINOMIAL,
32+
OMPI_COLL_ADAPT_ALGORITHM_BINARY,
33+
OMPI_COLL_ADAPT_ALGORITHM_PIPELINE,
34+
OMPI_COLL_ADAPT_ALGORITHM_CHAIN,
35+
OMPI_COLL_ADAPT_ALGORITHM_LINEAR,
36+
OMPI_COLL_ADAPT_ALGORITHM_COUNT /* number of algorithms, keep last! */
37+
} ompi_coll_adapt_algorithm_t;
38+
39+
/*
40+
* Structure to hold the adapt coll component. First it holds the
41+
* base coll component, and then holds a bunch of
42+
* adapt-coll-component-specific stuff (e.g., current MCA param
43+
* values).
44+
*/
45+
typedef struct mca_coll_adapt_component_t {
46+
/* Base coll component */
47+
mca_coll_base_component_2_0_0_t super;
48+
49+
/* MCA parameter: Priority of this component */
50+
int adapt_priority;
51+
52+
/* MCA parameter: Output stream and verbose level */
53+
int adapt_output;
54+
int adapt_verbose;
55+
56+
/* MCA parameter: Maximum number of segment in context free list */
57+
int adapt_context_free_list_max;
58+
59+
/* MCA parameter: Minimum number of segment in context free list */
60+
int adapt_context_free_list_min;
61+
62+
/* MCA parameter: Increasement number of segment in context free list */
63+
int adapt_context_free_list_inc;
64+
65+
/* Bcast MCA parameter */
66+
int adapt_ibcast_algorithm;
67+
size_t adapt_ibcast_segment_size;
68+
int adapt_ibcast_max_send_requests;
69+
int adapt_ibcast_max_recv_requests;
70+
bool adapt_ibcast_synchronous_send;
71+
/* Bcast free list */
72+
opal_free_list_t *adapt_ibcast_context_free_list;
73+
74+
/* Reduce MCA parameter */
75+
int adapt_ireduce_algorithm;
76+
size_t adapt_ireduce_segment_size;
77+
int adapt_ireduce_max_send_requests;
78+
int adapt_ireduce_max_recv_requests;
79+
int adapt_inbuf_free_list_min;
80+
int adapt_inbuf_free_list_max;
81+
int adapt_inbuf_free_list_inc;
82+
bool adapt_ireduce_synchronous_send;
83+
84+
/* Reduce free list */
85+
opal_free_list_t *adapt_ireduce_context_free_list;
86+
87+
} mca_coll_adapt_component_t;
88+
89+
/*
90+
* Structure used to store what is necessary for the collective operations
91+
* routines in case of fallback.
92+
*/
93+
typedef struct mca_coll_adapt_collective_fallback_s {
94+
union {
95+
mca_coll_base_module_reduce_fn_t reduce;
96+
mca_coll_base_module_ireduce_fn_t ireduce;
97+
} previous_routine;
98+
mca_coll_base_module_t *previous_module;
99+
} mca_coll_adapt_collective_fallback_t;
100+
101+
102+
typedef enum mca_coll_adapt_colltype {
103+
ADAPT_REDUCE = 0,
104+
ADAPT_IREDUCE = 1,
105+
ADAPT_COLLCOUNT
106+
} mca_coll_adapt_colltype_t;
107+
108+
/*
109+
* Some defines to stick to the naming used in the other components in terms of
110+
* fallback routines
111+
*/
112+
#define previous_reduce previous_routines[ADAPT_REDUCE].previous_routine.reduce
113+
#define previous_ireduce previous_routines[ADAPT_IREDUCE].previous_routine.ireduce
114+
115+
#define previous_reduce_module previous_routines[ADAPT_REDUCE].previous_module
116+
#define previous_ireduce_module previous_routines[ADAPT_IREDUCE].previous_module
117+
118+
119+
/* Coll adapt module per communicator*/
120+
struct mca_coll_adapt_module_t {
121+
/* Base module */
122+
mca_coll_base_module_t super;
123+
124+
/* To be able to fallback when the cases are not supported */
125+
struct mca_coll_adapt_collective_fallback_s previous_routines[ADAPT_COLLCOUNT];
126+
127+
/* cached topologies */
128+
opal_list_t *topo_cache;
129+
130+
/* Whether this module has been lazily initialized or not yet */
131+
bool adapt_enabled;
132+
};
133+
OBJ_CLASS_DECLARATION(mca_coll_adapt_module_t);
134+
135+
/* Global component instance */
136+
OMPI_MODULE_DECLSPEC extern mca_coll_adapt_component_t mca_coll_adapt_component;
137+
138+
/* ADAPT module functions */
139+
int ompi_coll_adapt_init_query(bool enable_progress_threads, bool enable_mpi_threads);
140+
mca_coll_base_module_t * ompi_coll_adapt_comm_query(struct ompi_communicator_t *comm, int *priority);
141+
142+
/* ADAPT request free */
143+
int ompi_coll_adapt_request_free(ompi_request_t **request);
144+
145+
#endif /* MCA_COLL_ADAPT_EXPORT_H */
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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 int (*ompi_mca_coll_adapt_ibcast_function_t)(IBCAST_ARGS);
18+
typedef int (*ompi_mca_coll_adapt_ireduce_function_t)(IREDUCE_ARGS);
19+
20+
typedef struct ompi_coll_adapt_algorithm_index_s {
21+
int algorithm_index;
22+
union {
23+
ompi_mca_coll_adapt_ibcast_function_t ibcast_fn_ptr;
24+
ompi_mca_coll_adapt_ireduce_function_t ireduce_fn_ptr;
25+
};
26+
} ompi_coll_adapt_algorithm_index_t;
27+
28+
/* Bcast */
29+
int ompi_coll_adapt_ibcast_register(void);
30+
int ompi_coll_adapt_ibcast_fini(void);
31+
int ompi_coll_adapt_bcast(BCAST_ARGS);
32+
int ompi_coll_adapt_ibcast(IBCAST_ARGS);
33+
34+
/* Reduce */
35+
int ompi_coll_adapt_ireduce_register(void);
36+
int ompi_coll_adapt_ireduce_fini(void);
37+
int ompi_coll_adapt_reduce(REDUCE_ARGS);
38+
int ompi_coll_adapt_ireduce(IREDUCE_ARGS);
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 ompi_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+
ompi_request_t *request = NULL;
19+
int err = ompi_coll_adapt_ibcast(buff, count, datatype, root, comm, &request, module);
20+
if( MPI_SUCCESS != err ) {
21+
if( NULL == request )
22+
return err;
23+
}
24+
ompi_request_wait(&request, MPI_STATUS_IGNORE);
25+
return err;
26+
}

0 commit comments

Comments
 (0)