|
| 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 */ |
0 commit comments