⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mpido_allgatherv.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 2 页
字号:
/*  (C)Copyright IBM Corp.  2007, 2008  *//** * \file src/coll/allgatherv/mpido_allgatherv.c * \brief ??? */#include "mpido_coll.h"#pragma weak PMPIDO_Allgatherv = MPIDO_Allgatherv/* ****************************************************************** *//*** \brief Use (tree) MPIDO_Allreduce() to do a fast Allgatherv operation** \note This function requires that:*       - The send/recv data types are contiguous*       - The recv buffer is continuous*       - Tree allreduce is availible (for max performance)*//* ****************************************************************** */int MPIDO_Allgatherv_Allreduce(void *sendbuf,                               int sendcount,                               MPI_Datatype sendtype,                               void *recvbuf,                               int *recvcounts,                               int *displs,                               MPI_Datatype recvtype,                               MPID_Comm * comm_ptr,                               MPI_Aint send_true_lb,                               MPI_Aint recv_true_lb,                               size_t send_size,                               size_t recv_size,                               int buffer_sum){   int start;   int length;   char *startbuf = NULL;   char *destbuf = NULL;   startbuf = (char *) recvbuf + recv_true_lb;   destbuf = startbuf + displs[comm_ptr->rank] * recv_size;   start = 0;   length = displs[comm_ptr->rank] * recv_size;   memset(startbuf + start, 0, length);   start  = (displs[comm_ptr->rank] +                    recvcounts[comm_ptr->rank]) * recv_size;   length = buffer_sum - (displs[comm_ptr->rank] +                    recvcounts[comm_ptr->rank]) * recv_size;   memset(startbuf + start, 0, length);   if (sendbuf != MPI_IN_PLACE)   {      char *outputbuf = (char *) sendbuf + send_true_lb;      memcpy(destbuf, outputbuf, send_size);   }   //if (0==comm_ptr->rank) puts("allreduce allgatherv");   return MPIDO_Allreduce(MPI_IN_PLACE,                          startbuf,                          buffer_sum/4,                          MPI_INT,                          MPI_BOR,                          comm_ptr);}/* ****************************************************************** *//*** \brief Use (tree/rect) MPIDO_Bcast() to do a fast Allgatherv operation** \note This function requires one of these (for max performance):*       - Tree broadcast*       - Rect broadcast*       ? Binomial broadcast*//* ****************************************************************** */int MPIDO_Allgatherv_Bcast(void *sendbuf,                           int sendcount,                           MPI_Datatype sendtype,                           void *recvbuf,                           int *recvcounts,                           int *displs,                           MPI_Datatype recvtype,                           MPID_Comm * comm_ptr){   int i;   MPI_Aint extent;   MPID_Datatype_get_extent_macro(recvtype, extent);   if (sendbuf != MPI_IN_PLACE)   {      void *destbuffer = recvbuf + displs[comm_ptr->rank] * extent;      MPIR_Localcopy(sendbuf,                     sendcount,                     sendtype,                     destbuffer,                     recvcounts[comm_ptr->rank],                     recvtype);   }   for (i = 0; i < comm_ptr->local_size; i++)   {      void *destbuffer = recvbuf + displs[i] * extent;      MPIDO_Bcast(destbuffer,                  recvcounts[i],                  recvtype,                  i,                  comm_ptr);   }   //if (0==comm_ptr->rank) puts("bcast allgatherv");   return MPI_SUCCESS;}/* ****************************************************************** *//*** \brief Use (tree/rect) MPIDO_Alltoall() to do a fast Allgatherv operation** \note This function requires that:*       - The send/recv data types are contiguous*       - DMA alltoallv is availible (for max performance)*//* ****************************************************************** */int MPIDO_Allgatherv_Alltoall(void *sendbuf,                              int sendcount,                              MPI_Datatype sendtype,                              void *recvbuf,                              int *recvcounts,                              int *displs,                              MPI_Datatype recvtype,                              MPID_Comm * comm_ptr,                              MPI_Aint send_true_lb,                              MPI_Aint recv_true_lb,                              size_t recv_size){   size_t send_size;   char *startbuf;   char *destbuf;   int i;   int aresult;   int my_recvcounts = -1;   void *a2a_sendbuf = NULL;   int a2a_sendcounts[comm_ptr->local_size];   int a2a_senddispls[comm_ptr->local_size];   send_size = recvcounts[comm_ptr->rank] * recv_size;   for (i = 0; i < comm_ptr->local_size; ++i)   {      a2a_sendcounts[i] = send_size;      a2a_senddispls[i] = 0;   }   if (sendbuf != MPI_IN_PLACE)   {      a2a_sendbuf = sendbuf + send_true_lb;   }   else   {      startbuf = (char *) recvbuf + recv_true_lb;      destbuf = startbuf + displs[comm_ptr->rank] * recv_size;      a2a_sendbuf = destbuf;      a2a_sendcounts[comm_ptr->rank] = 0;      my_recvcounts = recvcounts[comm_ptr->rank];      recvcounts[comm_ptr->rank] = 0;   }   //if (0==comm_ptr->rank) puts("all2all allgatherv");   aresult = MPIDO_Alltoallv(a2a_sendbuf,                             a2a_sendcounts,                             a2a_senddispls,                             MPI_CHAR,                             recvbuf,                             recvcounts,                             displs,                             recvtype,                             comm_ptr);   if (sendbuf == MPI_IN_PLACE)      recvcounts[comm_ptr->rank] = my_recvcounts;   return aresult;}intMPIDO_Allgatherv(void *sendbuf,                int sendcount,                MPI_Datatype sendtype,                void *recvbuf,                int *recvcounts,                int *displs,                MPI_Datatype recvtype,                MPID_Comm * comm_ptr){  /* *********************************   * Check the nature of the buffers   * *********************************   */   MPID_Datatype *dt_null = NULL;   MPI_Aint send_true_lb  = 0;   MPI_Aint recv_true_lb  = 0;   size_t   send_size     = 0;   size_t   recv_size     = 0;   MPIDO_Coll_config config = {1,1,1};   int      result        = MPI_SUCCESS;   if(MPIDI_CollectiveProtocols.optallgatherv &&      (MPIDI_CollectiveProtocols.allgatherv.useallreduce ||       MPIDI_CollectiveProtocols.allgatherv.usebcast ||       MPIDI_CollectiveProtocols.allgatherv.usealltoallv) == 0)   {      return MPIR_Allgatherv(sendbuf,                             sendcount,                             sendtype,                             recvbuf,                             recvcounts,                             displs,                             recvtype,                             comm_ptr);  }  MPIDI_Datatype_get_info(1,                          recvtype,                          config.recv_contig,                          recv_size,

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -