|
| 1 | +/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */ |
| 2 | +/* |
| 3 | + * Copyright (c) 2024 Advanced Micro Devices, Inc. All rights reserved. |
| 4 | + * $COPYRIGHT$ |
| 5 | + * |
| 6 | + * Additional copyrights may follow |
| 7 | + * |
| 8 | + * $HEADER$ |
| 9 | + */ |
| 10 | + |
| 11 | +#ifndef MCA_COLL_ACOLL_EXPORT_H |
| 12 | +#define MCA_COLL_ACOLL_EXPORT_H |
| 13 | + |
| 14 | +#include "ompi_config.h" |
| 15 | + |
| 16 | +#include "mpi.h" |
| 17 | +#include "ompi/communicator/communicator.h" |
| 18 | +#include "ompi/mca/coll/base/coll_base_functions.h" |
| 19 | +#include "ompi/mca/coll/coll.h" |
| 20 | +#include "ompi/mca/mca.h" |
| 21 | +#include "ompi/request/request.h" |
| 22 | + |
| 23 | +#ifdef HAVE_XPMEM_H |
| 24 | +#include "opal/mca/rcache/base/base.h" |
| 25 | +#include <xpmem.h> |
| 26 | +#endif |
| 27 | + |
| 28 | +#include "opal/mca/shmem/base/base.h" |
| 29 | +#include "opal/mca/shmem/shmem.h" |
| 30 | + |
| 31 | +BEGIN_C_DECLS |
| 32 | + |
| 33 | +/* Globally exported variables */ |
| 34 | +OMPI_DECLSPEC extern const mca_coll_base_component_3_0_0_t mca_coll_acoll_component; |
| 35 | +extern int mca_coll_acoll_priority; |
| 36 | +extern int mca_coll_acoll_sg_size; |
| 37 | +extern int mca_coll_acoll_sg_scale; |
| 38 | +extern int mca_coll_acoll_node_size; |
| 39 | +extern int mca_coll_acoll_use_dynamic_rules; |
| 40 | +extern int mca_coll_acoll_mnode_enable; |
| 41 | +extern int mca_coll_acoll_bcast_lin0; |
| 42 | +extern int mca_coll_acoll_bcast_lin1; |
| 43 | +extern int mca_coll_acoll_bcast_lin2; |
| 44 | +extern int mca_coll_acoll_bcast_nonsg; |
| 45 | +extern int mca_coll_acoll_allgather_lin; |
| 46 | +extern int mca_coll_acoll_allgather_ring_1; |
| 47 | + |
| 48 | +/* API functions */ |
| 49 | +int mca_coll_acoll_init_query(bool enable_progress_threads, bool enable_mpi_threads); |
| 50 | +mca_coll_base_module_t *mca_coll_acoll_comm_query(struct ompi_communicator_t *comm, int *priority); |
| 51 | + |
| 52 | +int mca_coll_acoll_module_enable(mca_coll_base_module_t *module, struct ompi_communicator_t *comm); |
| 53 | + |
| 54 | +int mca_coll_acoll_allgather(const void *sbuf, size_t scount, struct ompi_datatype_t *sdtype, |
| 55 | + void *rbuf, size_t rcount, struct ompi_datatype_t *rdtype, |
| 56 | + struct ompi_communicator_t *comm, mca_coll_base_module_t *module); |
| 57 | + |
| 58 | +int mca_coll_acoll_bcast(void *buff, size_t count, struct ompi_datatype_t *datatype, int root, |
| 59 | + struct ompi_communicator_t *comm, mca_coll_base_module_t *module); |
| 60 | + |
| 61 | +int mca_coll_acoll_gather_intra(const void *sbuf, size_t scount, struct ompi_datatype_t *sdtype, |
| 62 | + void *rbuf, size_t rcount, struct ompi_datatype_t *rdtype, int root, |
| 63 | + struct ompi_communicator_t *comm, mca_coll_base_module_t *module); |
| 64 | + |
| 65 | +int mca_coll_acoll_reduce_intra(const void *sbuf, void *rbuf, size_t count, |
| 66 | + struct ompi_datatype_t *dtype, struct ompi_op_t *op, int root, |
| 67 | + struct ompi_communicator_t *comm, mca_coll_base_module_t *module); |
| 68 | + |
| 69 | +int mca_coll_acoll_allreduce_intra(const void *sbuf, void *rbuf, size_t count, |
| 70 | + struct ompi_datatype_t *dtype, struct ompi_op_t *op, |
| 71 | + struct ompi_communicator_t *comm, |
| 72 | + mca_coll_base_module_t *module); |
| 73 | + |
| 74 | +int mca_coll_acoll_barrier_intra(struct ompi_communicator_t *comm, mca_coll_base_module_t *module); |
| 75 | + |
| 76 | +END_C_DECLS |
| 77 | + |
| 78 | +#define MCA_COLL_ACOLL_MAX_CID 100 |
| 79 | +#define MCA_COLL_ACOLL_ROOT_CHANGE_THRESH 10 |
| 80 | + |
| 81 | +typedef enum MCA_COLL_ACOLL_SG_SIZES { |
| 82 | + MCA_COLL_ACOLL_SG_SIZE_1 = 8, |
| 83 | + MCA_COLL_ACOLL_SG_SIZE_2 = 16 |
| 84 | +} MCA_COLL_ACOLL_SG_SIZES; |
| 85 | + |
| 86 | +typedef enum MCA_COLL_ACOLL_SG_SCALES { |
| 87 | + MCA_COLL_ACOLL_SG_SCALE_1 = 1, |
| 88 | + MCA_COLL_ACOLL_SG_SCALE_2 = 2, |
| 89 | + MCA_COLL_ACOLL_SG_SCALE_3 = 4, |
| 90 | + MCA_COLL_ACOLL_SG_SCALE_4 = 8, |
| 91 | + MCA_COLL_ACOLL_SG_SCALE_5 = 16 |
| 92 | +} MCA_COLL_ACOLL_SG_SCALES; |
| 93 | + |
| 94 | +typedef enum MCA_COLL_ACOLL_SUBCOMMS { |
| 95 | + MCA_COLL_ACOLL_NODE_L = 0, |
| 96 | + MCA_COLL_ACOLL_INTRA, |
| 97 | + MCA_COLL_ACOLL_SOCK_L, |
| 98 | + MCA_COLL_ACOLL_NUMA_L, |
| 99 | + MCA_COLL_ACOLL_L3_L, |
| 100 | + MCA_COLL_ACOLL_LEAF, |
| 101 | + MCA_COLL_ACOLL_NUM_SC |
| 102 | +} MCA_COLL_ACOLL_SUBCOMMS; |
| 103 | + |
| 104 | +typedef enum MCA_COLL_ACOLL_LAYERS { |
| 105 | + MCA_COLL_ACOLL_LYR_NODE = 0, |
| 106 | + MCA_COLL_ACOLL_LYR_SOCKET, |
| 107 | + MCA_COLL_ACOLL_NUM_LAYERS |
| 108 | +} MCA_COLL_ACOLL_LAYERS; |
| 109 | + |
| 110 | +typedef enum MCA_COLL_ACOLL_BASE_LYRS { |
| 111 | + MCA_COLL_ACOLL_L3CACHE = 0, |
| 112 | + MCA_COLL_ACOLL_NUMA, |
| 113 | + MCA_COLL_ACOLL_NUM_BASE_LYRS |
| 114 | +} MCA_COLL_ACOLL_BASE_LYRS; |
| 115 | + |
| 116 | +typedef struct coll_acoll_data { |
| 117 | +#ifdef HAVE_XPMEM_H |
| 118 | + xpmem_segid_t *allseg_id; |
| 119 | + xpmem_apid_t *all_apid; |
| 120 | + void **allshm_sbuf; |
| 121 | + void **allshm_rbuf; |
| 122 | + void **xpmem_saddr; |
| 123 | + void **xpmem_raddr; |
| 124 | + mca_rcache_base_module_t **rcache; |
| 125 | + void *scratch; |
| 126 | +#endif |
| 127 | + opal_shmem_ds_t *allshmseg_id; |
| 128 | + void **allshmmmap_sbuf; |
| 129 | + |
| 130 | + int comm_size; |
| 131 | + int l1_local_rank; |
| 132 | + int l2_local_rank; |
| 133 | + int l1_gp_size; |
| 134 | + int *l1_gp; |
| 135 | + int *l2_gp; |
| 136 | + int l2_gp_size; |
| 137 | + int offset[4]; |
| 138 | + int sync[2]; |
| 139 | +} coll_acoll_data_t; |
| 140 | + |
| 141 | +typedef struct coll_acoll_subcomms { |
| 142 | + ompi_communicator_t *local_comm; |
| 143 | + ompi_communicator_t *local_r_comm; |
| 144 | + ompi_communicator_t *leader_comm; |
| 145 | + ompi_communicator_t *subgrp_comm; |
| 146 | + ompi_communicator_t *numa_comm; |
| 147 | + ompi_communicator_t *base_comm[MCA_COLL_ACOLL_NUM_BASE_LYRS][MCA_COLL_ACOLL_NUM_LAYERS]; |
| 148 | + ompi_communicator_t *orig_comm; |
| 149 | + ompi_communicator_t *socket_comm; |
| 150 | + ompi_communicator_t *socket_ldr_comm; |
| 151 | + int num_nodes; |
| 152 | + int derived_node_size; |
| 153 | + int is_root_node; |
| 154 | + int is_root_sg; |
| 155 | + int is_root_numa; |
| 156 | + int is_root_socket; |
| 157 | + int local_root[MCA_COLL_ACOLL_NUM_LAYERS]; |
| 158 | + int outer_grp_root; |
| 159 | + int subgrp_root; |
| 160 | + int numa_root; |
| 161 | + int socket_ldr_root; |
| 162 | + int base_root[MCA_COLL_ACOLL_NUM_BASE_LYRS][MCA_COLL_ACOLL_NUM_LAYERS]; |
| 163 | + int base_rank[MCA_COLL_ACOLL_NUM_BASE_LYRS]; |
| 164 | + int socket_rank; |
| 165 | + int subgrp_size; |
| 166 | + int initialized; |
| 167 | + int prev_init_root; |
| 168 | + int num_root_change; |
| 169 | + |
| 170 | + ompi_communicator_t *numa_comm_ldrs; |
| 171 | + ompi_communicator_t *node_comm; |
| 172 | + ompi_communicator_t *inter_comm; |
| 173 | + int cid; |
| 174 | + coll_acoll_data_t *data; |
| 175 | + bool initialized_data; |
| 176 | + bool initialized_shm_data; |
| 177 | +#ifdef HAVE_XPMEM_H |
| 178 | + uint64_t xpmem_buf_size; |
| 179 | + int without_xpmem; |
| 180 | + int xpmem_use_sr_buf; |
| 181 | +#endif |
| 182 | + |
| 183 | +} coll_acoll_subcomms_t; |
| 184 | + |
| 185 | +typedef struct coll_acoll_reserve_mem { |
| 186 | + void *reserve_mem; |
| 187 | + uint64_t reserve_mem_size; |
| 188 | + bool reserve_mem_allocate; |
| 189 | + bool reserve_mem_in_use; |
| 190 | +} coll_acoll_reserve_mem_t; |
| 191 | + |
| 192 | +struct mca_coll_acoll_module_t { |
| 193 | + mca_coll_base_module_t super; |
| 194 | + MCA_COLL_ACOLL_SG_SIZES sg_size; |
| 195 | + MCA_COLL_ACOLL_SG_SCALES sg_scale; |
| 196 | + int sg_cnt; |
| 197 | + // Todo: Remove log2 variables |
| 198 | + int log2_sg_cnt; |
| 199 | + int node_cnt; |
| 200 | + int log2_node_cnt; |
| 201 | + int use_dyn_rules; |
| 202 | + // Todo: Use substructure for every API related ones |
| 203 | + int use_mnode; |
| 204 | + int use_lin0; |
| 205 | + int use_lin1; |
| 206 | + int use_lin2; |
| 207 | + int mnode_sg_size; |
| 208 | + int mnode_log2_sg_size; |
| 209 | + int allg_lin; |
| 210 | + int allg_ring; |
| 211 | + coll_acoll_subcomms_t subc[MCA_COLL_ACOLL_MAX_CID]; |
| 212 | + coll_acoll_reserve_mem_t reserve_mem_s; |
| 213 | +}; |
| 214 | + |
| 215 | +#ifdef HAVE_XPMEM_H |
| 216 | +struct acoll_xpmem_rcache_reg_t { |
| 217 | + mca_rcache_base_registration_t base; |
| 218 | + void *xpmem_vaddr; |
| 219 | +}; |
| 220 | +#endif |
| 221 | + |
| 222 | +typedef struct mca_coll_acoll_module_t mca_coll_acoll_module_t; |
| 223 | +OMPI_DECLSPEC OBJ_CLASS_DECLARATION(mca_coll_acoll_module_t); |
| 224 | + |
| 225 | +#endif /* MCA_COLL_ACOLL_EXPORT_H */ |
0 commit comments