root/ompi/mca/coll/libnbc/nbc_igatherv.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. nbc_gatherv_init
  2. ompi_coll_libnbc_igatherv
  3. nbc_gatherv_inter_init
  4. ompi_coll_libnbc_igatherv_inter
  5. ompi_coll_libnbc_gatherv_init
  6. ompi_coll_libnbc_gatherv_inter_init

   1 /* -*- Mode: C; c-basic-offset:2 ; indent-tabs-mode:nil -*- */
   2 /*
   3  * Copyright (c) 2006      The Trustees of Indiana University and Indiana
   4  *                         University Research and Technology
   5  *                         Corporation.  All rights reserved.
   6  * Copyright (c) 2006      The Technical University of Chemnitz. All
   7  *                         rights reserved.
   8  * Copyright (c) 2013      The University of Tennessee and The University
   9  *                         of Tennessee Research Foundation.  All rights
  10  *                         reserved.
  11  * Copyright (c) 2014-2018 Research Organization for Information Science
  12  *                         and Technology (RIST).  All rights reserved.
  13  * Copyright (c) 2015      Los Alamos National Security, LLC.  All rights
  14  *                         reserved.
  15  * Copyright (c) 2015      Mellanox Technologies. All rights reserved.
  16  * Copyright (c) 2017      IBM Corporation.  All rights reserved.
  17  * Copyright (c) 2018      FUJITSU LIMITED.  All rights reserved.
  18  * $COPYRIGHT$
  19  *
  20  * Additional copyrights may follow
  21  *
  22  * Author(s): Torsten Hoefler <htor@cs.indiana.edu>
  23  *
  24  */
  25 #include "nbc_internal.h"
  26 
  27 /* an gatherv schedule can not be cached easily because the contents
  28  * ot the recvcounts array may change, so a comparison of the address
  29  * would not be sufficient ... we simply do not cache it */
  30 
  31 
  32 static int nbc_gatherv_init(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
  33                             void* recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype,
  34                             int root, struct ompi_communicator_t *comm, ompi_request_t ** request,
  35                             struct mca_coll_base_module_2_3_0_t *module, bool persistent) {
  36   int rank, p, res;
  37   MPI_Aint rcvext = 0;
  38   NBC_Schedule *schedule;
  39   char *rbuf, inplace = 0;
  40   ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
  41 
  42   rank = ompi_comm_rank (comm);
  43   if (root == rank) {
  44     NBC_IN_PLACE(sendbuf, recvbuf, inplace);
  45   }
  46   p = ompi_comm_size (comm);
  47 
  48   if (rank == root) {
  49     res = ompi_datatype_type_extent(recvtype, &rcvext);
  50     if (MPI_SUCCESS != res) {
  51       NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
  52       return res;
  53     }
  54   }
  55 
  56   schedule = OBJ_NEW(NBC_Schedule);
  57   if (OPAL_UNLIKELY(NULL == schedule)) {
  58     return OMPI_ERR_OUT_OF_RESOURCE;
  59   }
  60 
  61   /* send to root */
  62   if (rank != root) {
  63     /* send msg to root */
  64     res = NBC_Sched_send (sendbuf, false, sendcount, sendtype, root, schedule, false);
  65     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
  66       OBJ_RELEASE(schedule);
  67       return res;
  68     }
  69   } else {
  70     for (int i = 0 ; i < p ; ++i) {
  71       rbuf = (char *) recvbuf + displs[i] * rcvext;
  72       if (i == root) {
  73         if (!inplace) {
  74           /* if I am the root - just copy the message */
  75           res = NBC_Sched_copy ((void *)sendbuf, false, sendcount, sendtype,
  76                                 rbuf, false, recvcounts[i], recvtype, schedule, false);
  77           if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
  78             OBJ_RELEASE(schedule);
  79             return res;
  80           }
  81         }
  82       } else {
  83         /* root receives message to the right buffer */
  84         res = NBC_Sched_recv (rbuf, false, recvcounts[i], recvtype, i, schedule, false);
  85         if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
  86           OBJ_RELEASE(schedule);
  87           return res;
  88         }
  89       }
  90     }
  91   }
  92 
  93   res = NBC_Sched_commit (schedule);
  94   if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
  95     OBJ_RELEASE(schedule);
  96     return res;
  97   }
  98 
  99   res = NBC_Schedule_request(schedule, comm, libnbc_module, persistent, request, NULL);
 100   if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 101     OBJ_RELEASE(schedule);
 102     return res;
 103   }
 104 
 105   return OMPI_SUCCESS;
 106 }
 107 
 108 int ompi_coll_libnbc_igatherv(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
 109                               void* recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype,
 110                               int root, struct ompi_communicator_t *comm, ompi_request_t ** request,
 111                               struct mca_coll_base_module_2_3_0_t *module) {
 112     int res = nbc_gatherv_init(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root,
 113                                comm, request, module, false);
 114     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 115         return res;
 116     }
 117   
 118     res = NBC_Start(*(ompi_coll_libnbc_request_t **)request);
 119     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 120         NBC_Return_handle (*(ompi_coll_libnbc_request_t **)request);
 121         *request = &ompi_request_null.request;
 122         return res;
 123     }
 124 
 125     return OMPI_SUCCESS;
 126 }
 127 
 128 static int nbc_gatherv_inter_init (const void* sendbuf, int sendcount, MPI_Datatype sendtype,
 129                                    void* recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype,
 130                                    int root, struct ompi_communicator_t *comm, ompi_request_t ** request,
 131                                    struct mca_coll_base_module_2_3_0_t *module, bool persistent) {
 132   int res, rsize;
 133   MPI_Aint rcvext;
 134   NBC_Schedule *schedule;
 135   char *rbuf;
 136   ompi_coll_libnbc_module_t *libnbc_module = (ompi_coll_libnbc_module_t*) module;
 137 
 138   rsize = ompi_comm_remote_size (comm);
 139 
 140   if (MPI_ROOT == root) {
 141     res = ompi_datatype_type_extent(recvtype, &rcvext);
 142     if (MPI_SUCCESS != res) {
 143       NBC_Error("MPI Error in ompi_datatype_type_extent() (%i)", res);
 144       return res;
 145     }
 146   }
 147 
 148   schedule = OBJ_NEW(NBC_Schedule);
 149   if (OPAL_UNLIKELY(NULL == schedule)) {
 150     return OMPI_ERR_OUT_OF_RESOURCE;
 151   }
 152 
 153   /* send to root */
 154   if (MPI_ROOT != root && MPI_PROC_NULL != root) {
 155     /* send msg to root */
 156     res = NBC_Sched_send (sendbuf, false, sendcount, sendtype, root, schedule, false);
 157     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 158       OBJ_RELEASE(schedule);
 159       return res;
 160     }
 161   } else if (MPI_ROOT == root) {
 162     for (int i = 0 ; i < rsize ; ++i) {
 163       rbuf = (char *) recvbuf + displs[i] * rcvext;
 164       /* root receives message to the right buffer */
 165       res = NBC_Sched_recv (rbuf, false, recvcounts[i], recvtype, i, schedule, false);
 166       if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 167         OBJ_RELEASE(schedule);
 168         return res;
 169       }
 170     }
 171   }
 172 
 173   res = NBC_Sched_commit (schedule);
 174   if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 175     OBJ_RELEASE(schedule);
 176     return res;
 177   }
 178 
 179   res = NBC_Schedule_request(schedule, comm, libnbc_module, persistent, request, NULL);
 180   if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 181     OBJ_RELEASE(schedule);
 182     return res;
 183   }
 184 
 185   return OMPI_SUCCESS;
 186 }
 187 
 188 int ompi_coll_libnbc_igatherv_inter(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
 189                                     void* recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype,
 190                                     int root, struct ompi_communicator_t *comm, ompi_request_t ** request,
 191                                     struct mca_coll_base_module_2_3_0_t *module) {
 192     int res = nbc_gatherv_inter_init(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root,
 193                                      comm, request, module, false);
 194     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 195         return res;
 196     }
 197   
 198     res = NBC_Start(*(ompi_coll_libnbc_request_t **)request);
 199     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 200         NBC_Return_handle (*(ompi_coll_libnbc_request_t **)request);
 201         *request = &ompi_request_null.request;
 202         return res;
 203     }
 204 
 205     return OMPI_SUCCESS;
 206 }
 207 
 208 int ompi_coll_libnbc_gatherv_init(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
 209                                   void* recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype,
 210                                   int root, struct ompi_communicator_t *comm, MPI_Info info, ompi_request_t ** request,
 211                                   struct mca_coll_base_module_2_3_0_t *module) {
 212     int res = nbc_gatherv_init(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root,
 213                                comm, request, module, true);
 214     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 215         return res;
 216     }
 217 
 218     return OMPI_SUCCESS;
 219 }
 220 
 221 int ompi_coll_libnbc_gatherv_inter_init(const void* sendbuf, int sendcount, MPI_Datatype sendtype,
 222                                         void* recvbuf, const int *recvcounts, const int *displs, MPI_Datatype recvtype,
 223                                         int root, struct ompi_communicator_t *comm, MPI_Info info, ompi_request_t ** request,
 224                                         struct mca_coll_base_module_2_3_0_t *module) {
 225     int res = nbc_gatherv_inter_init(sendbuf, sendcount, sendtype, recvbuf, recvcounts, displs, recvtype, root,
 226                                      comm, request, module, true);
 227     if (OPAL_UNLIKELY(OMPI_SUCCESS != res)) {
 228         return res;
 229     }
 230 
 231     return OMPI_SUCCESS;
 232 }

/* [<][>][^][v][top][bottom][index][help] */