21 #ifndef MCA_COLL_SM_EXPORT_H
22 #define MCA_COLL_SM_EXPORT_H
24 #include "ompi_config.h"
28 #include "opal/datatype/opal_convertor.h"
31 #include "ompi/mca/common/sm/common_sm.h"
38 #define SPIN_CONDITION_MAX 100000
39 #define SPIN_CONDITION(cond, exit_label) \
41 if (cond) goto exit_label; \
42 for (i = 0; i < SPIN_CONDITION_MAX; ++i) { \
43 if (cond) { goto exit_label; } \
195 mca_coll_base_module_reduce_fn_t previous_reduce;
208 int mca_coll_sm_init_query(
bool enable_progress_threads,
209 bool enable_mpi_threads);
219 int mca_coll_sm_allgather_intra(
void *sbuf,
int scount,
221 void *rbuf,
int rcount,
226 int mca_coll_sm_allgatherv_intra(
void *sbuf,
int scount,
228 void * rbuf,
int *rcounts,
int *disps,
237 int mca_coll_sm_alltoall_intra(
void *sbuf,
int scount,
239 void* rbuf,
int rcount,
243 int mca_coll_sm_alltoallv_intra(
void *sbuf,
int *scounts,
int *sdisps,
245 void *rbuf,
int *rcounts,
int *rdisps,
249 int mca_coll_sm_alltoallw_intra(
void *sbuf,
int *scounts,
int *sdisps,
251 void *rbuf,
int *rcounts,
int *rdisps,
262 int mca_coll_sm_bcast_log_intra(
void *buff,
int count,
267 int mca_coll_sm_exscan_intra(
void *sbuf,
void *rbuf,
int count,
272 int mca_coll_sm_gather_intra(
void *sbuf,
int scount,
277 int mca_coll_sm_gatherv_intra(
void *sbuf,
int scount,
279 int *rcounts,
int *disps,
289 int mca_coll_sm_reduce_log_intra(
void *sbuf,
void* rbuf,
int count,
295 int mca_coll_sm_reduce_scatter_intra(
void *sbuf,
void *rbuf,
301 int mca_coll_sm_scan_intra(
void *sbuf,
void *rbuf,
int count,
306 int mca_coll_sm_scatter_intra(
void *sbuf,
int scount,
311 int mca_coll_sm_scatterv_intra(
void *sbuf,
int *scounts,
int *disps,
313 void* rbuf,
int rcount,
318 int mca_coll_sm_ft_event(
int state);
330 #define FLAG_SETUP(flag_num, flag, data) \
331 (flag) = (mca_coll_sm_in_use_flag_t*) \
332 (((char *) (data)->mcb_in_use_flags) + \
333 ((flag_num) * mca_coll_sm_component.sm_control_size))
338 #define FLAG_WAIT_FOR_IDLE(flag, label) \
339 SPIN_CONDITION(0 == (flag)->mcsiuf_num_procs_using, label)
346 #define FLAG_WAIT_FOR_OP(flag, op, label) \
347 SPIN_CONDITION((op) == flag->mcsiuf_operation_count, label)
352 #define FLAG_RETAIN(flag, num_procs, op_count) \
353 (flag)->mcsiuf_num_procs_using = (num_procs); \
354 (flag)->mcsiuf_operation_count = (op_count)
359 #define FLAG_RELEASE(flag) \
360 opal_atomic_add(&(flag)->mcsiuf_num_procs_using, -1)
366 #define COPY_FRAGMENT_IN(convertor, index, rank, iov, max_data) \
368 (index)->mcbmi_data + \
369 ((rank) * mca_coll_sm_component.sm_fragment_size); \
370 (iov).iov_len = (max_data); \
371 opal_convertor_pack(&(convertor), &(iov), &mca_coll_sm_one, \
378 #define COPY_FRAGMENT_OUT(convertor, src_rank, index, iov, max_data) \
379 (iov).iov_base = (((char*) (index)->mcbmi_data) + \
380 ((src_rank) * (mca_coll_sm_component.sm_fragment_size))); \
381 (iov).iov_len = (max_data); \
382 opal_convertor_unpack(&(convertor), &(iov), &mca_coll_sm_one, \
388 #define COPY_FRAGMENT_BETWEEN(src_rank, dest_rank, index, len) \
389 memcpy(((index)->mcbmi_data + \
390 ((dest_rank) * mca_coll_sm_component.sm_fragment_size)), \
391 ((index)->mcbmi_data + \
393 mca_coll_sm_component.sm_fragment_size)), \
401 #define PARENT_NOTIFY_CHILDREN(children, num_children, index, value) \
403 for (i = 0; i < (num_children); ++i) { \
405 (((char*) index->mcbmi_control) + \
406 (mca_coll_sm_component.sm_control_size * \
407 (((children)[i]->mcstn_id + root) % size)))) = (value); \
416 #define CHILD_WAIT_FOR_NOTIFY(rank, index, value, label) \
418 uint32_t volatile *ptr = ((uint32_t*) \
419 (((char*) index->mcbmi_control) + \
420 ((rank) * mca_coll_sm_component.sm_control_size))); \
421 SPIN_CONDITION(0 != *ptr, label); \
430 #define CHILD_NOTIFY_PARENT(child_rank, parent_rank, index, value) \
431 ((size_t volatile *) \
432 (((char*) (index)->mcbmi_control) + \
433 (mca_coll_sm_component.sm_control_size * \
434 (parent_rank))))[(child_rank)] = (value)
441 #define PARENT_WAIT_FOR_NOTIFY_SPECIFIC(child_rank, parent_rank, index, value, label) \
443 size_t volatile *ptr = ((size_t volatile *) \
444 (((char*) index->mcbmi_control) + \
445 (mca_coll_sm_component.sm_control_size * \
446 (parent_rank)))) + child_rank; \
447 SPIN_CONDITION(0 != *ptr, label); \
char * mcbmi_data
Pointer to beginning of message fragment data.
Definition: coll_sm.h:133
uint32_t mca_coll_sm_one
Global variables used in the macros (essentially constants, so these are thread safe) ...
Definition: coll_sm_module.c:70
struct mca_coll_sm_in_use_flag_t mca_coll_sm_in_use_flag_t
Simple structure comprising the "in use" flags.
int mca_coll_sm_allreduce_intra(void *sbuf, void *rbuf, int count, struct ompi_datatype_t *dtype, struct ompi_op_t *op, struct ompi_communicator_t *comm, mca_coll_base_module_t *module)
Shared memory allreduce.
Definition: coll_sm_allreduce.c:34
volatile uint32_t mcsiuf_num_procs_using
Number of processes currently using this set of segments.
Definition: coll_sm.h:116
Collective module interface.
Definition: coll.h:316
Definition: common_sm.h:60
uint32_t volatile * mcbmi_control
Pointer to beginning of control data.
Definition: coll_sm.h:131
Definition: ompi_datatype.h:68
mca_coll_base_component_2_0_0_t super
Base coll component.
Definition: coll_sm.h:57
Structure for representing a node in the tree.
Definition: coll_sm.h:95
int mca_coll_sm_barrier_intra(struct ompi_communicator_t *comm, mca_coll_base_module_t *module)
Shared memory barrier.
Definition: coll_sm_barrier.c:52
int sm_priority
MCA parameter: Priority of this component.
Definition: coll_sm.h:60
int mcstn_num_children
Number of children, or 0 if a leaf.
Definition: coll_sm.h:101
Collective component interface.
Definition: coll.h:283
int sm_comm_num_segments
MCA parameter: Number of segments for each communicator in the data mpool.
Definition: coll_sm.h:71
int mca_coll_sm_reduce_intra(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)
Shared memory reduction.
Definition: coll_sm_reduce.c:67
uint32_t mcb_operation_count
Operation number (i.e., which segment number to use)
Definition: coll_sm.h:180
int sm_segs_per_inuse_flag
How many fragment segments are protected by a single in-use flags.
Definition: coll_sm.h:89
struct mca_coll_sm_component_t mca_coll_sm_component_t
Structure to hold the sm coll component.
mca_coll_base_module_t super
Base module.
Definition: coll_sm.h:186
volatile uint32_t mcsiuf_operation_count
Must match data->mcb_count.
Definition: coll_sm.h:118
Structure for the sm coll module to hang off the communicator.
Definition: coll_sm.h:142
Top-level interface for all MCA components.
struct mca_coll_sm_module_t mca_coll_sm_module_t
Coll sm module.
int sm_fragment_size
MCA parameter: Fragment size for data.
Definition: coll_sm.h:74
Collective Communication Interface.
int sm_tree_degree
MCA parameter: Degree of tree for tree-based collectives.
Definition: coll_sm.h:77
struct mca_coll_sm_comm_t mca_coll_sm_comm_t
Structure for the sm coll module to hang off the communicator.
mca_coll_sm_in_use_flag_t * mcb_in_use_flags
"In use" flags indicating which segments are available
Definition: coll_sm.h:168
int sm_comm_num_in_use_flags
MCA parameter: Number of "in use" flags in each communicator's area in the data mpool.
Definition: coll_sm.h:67
int sm_control_size
MCA parameter: Length of a cache line or page (in bytes)
Definition: coll_sm.h:63
struct mca_coll_sm_data_index_t mca_coll_sm_data_index_t
Structure containing pointers to various arrays of data in the per-communicator shmem data segment (o...
int mcb_barrier_count
Number of barriers that we have executed (i.e., which set of barrier buffers to use).
Definition: coll_sm.h:165
mca_coll_sm_tree_node_t * mcb_tree
Array of graph nodes representing the tree used for communications.
Definition: coll_sm.h:177
Structure to hold the sm coll component.
Definition: coll_sm.h:55
struct mca_coll_sm_tree_node_t ** mcstn_children
Pointer to an array of children, or NULL if 0 == mcstn_num_children.
Definition: coll_sm.h:104
int sm_info_comm_size
MCA parameter: Number of processes to use in the calculation of the "info" MCA parameter.
Definition: coll_sm.h:81
int mcstn_id
Arbitrary ID number, starting from 0.
Definition: coll_sm.h:97
uint32_t * mcb_barrier_control_children
Pointers to my childrens' barrier control pages (they're contiguous in memory, so we only point to th...
Definition: coll_sm.h:161
uint32_t * mcb_barrier_control_parent
Pointer to my parent's barrier control pages (will be NULL for communicator rank 0; odd index pages a...
Definition: coll_sm.h:154
int mca_coll_sm_bcast_intra(void *buff, int count, struct ompi_datatype_t *datatype, int root, struct ompi_communicator_t *comm, mca_coll_base_module_t *module)
Shared memory broadcast.
Definition: coll_sm_bcast.c:58
OMPI_MODULE_DECLSPEC mca_coll_sm_component_t mca_coll_sm_component
Global component instance.
Definition: coll_sm_component.c:55
Simple structure comprising the "in use" flags.
Definition: coll_sm.h:113
struct mca_coll_sm_tree_node_t * mcstn_parent
Pointer to parent, or NULL if root.
Definition: coll_sm.h:99
mca_coll_sm_data_index_t * mcb_data_index
Array of indexes into the per-communicator shmem data segment for control and data fragment passing (...
Definition: coll_sm.h:173
Definition: communicator.h:118
Back-end type of MPI_Op.
Definition: op.h:100
uint32_t * mcb_barrier_control_me
Pointer to my barrier control pages (odd index pages are "in", even index pages are "out") ...
Definition: coll_sm.h:149
Coll sm module.
Definition: coll_sm.h:184
#define OBJ_CLASS_DECLARATION(NAME)
Declaration for class descriptor.
Definition: opal_object.h:236
struct mca_coll_sm_tree_node_t mca_coll_sm_tree_node_t
Structure for representing a node in the tree.
Structure containing pointers to various arrays of data in the per-communicator shmem data segment (o...
Definition: coll_sm.h:129