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

📄 mpid_coll.c

📁 fortran并行计算包
💻 C
📖 第 1 页 / 共 2 页
字号:
                      &MPIDI_CollectiveProtocols.allreduce.rectanglering,                      &allreduce_config) != DCMF_SUCCESS)      MPIDI_CollectiveProtocols.allreduce.userectring = 0;   if(ALLREDUCE_REGISTER(DCMF_TORUS_BINOMIAL_ALLREDUCE_PROTOCOL,                      &MPIDI_CollectiveProtocols.allreduce.binomial,                      &allreduce_config) != DCMF_SUCCESS)         MPIDI_CollectiveProtocols.allreduce.usebinom = 0;   /* Register alltoallv protocols */   if(ALLTOALLV_REGISTER(DCMF_TORUS_ALLTOALLV_PROTOCOL,                      &MPIDI_CollectiveProtocols.alltoallv.torus,                      &alltoallv_config) != DCMF_SUCCESS)   {         MPIDI_CollectiveProtocols.alltoallv.usetorus = 0;         MPIDI_CollectiveProtocols.alltoallw.usetorus = 0;         MPIDI_CollectiveProtocols.alltoall.usetorus = 0;   }   /* Register reduce protocols */   if(MPIDI_CollectiveProtocols.reduce.usetree ||      MPIDI_CollectiveProtocols.reduce.useccmitree)   {      if(REDUCE_REGISTER(DCMF_TREE_REDUCE_PROTOCOL,                      &MPIDI_CollectiveProtocols.reduce.tree,                      &reduce_config) != DCMF_SUCCESS)      {              MPIDI_CollectiveProtocols.reduce.usetree = 0;              MPIDI_CollectiveProtocols.reduce.useccmitree = 0;      }   }   if(REDUCE_REGISTER(DCMF_TORUS_BINOMIAL_REDUCE_PROTOCOL,                   &MPIDI_CollectiveProtocols.reduce.binomial,                   &reduce_config) != DCMF_SUCCESS)         MPIDI_CollectiveProtocols.reduce.usebinom = 0;   if(REDUCE_REGISTER(DCMF_TORUS_RECTANGLE_REDUCE_PROTOCOL,                   &MPIDI_CollectiveProtocols.reduce.rectangle,                   &reduce_config) != DCMF_SUCCESS)         MPIDI_CollectiveProtocols.reduce.userect = 0;   if(REDUCE_REGISTER(DCMF_TORUS_RECTANGLE_RING_REDUCE_PROTOCOL,                   &MPIDI_CollectiveProtocols.reduce.rectanglering,                   &reduce_config) != DCMF_SUCCESS)         MPIDI_CollectiveProtocols.reduce.userectring = 0;}/** * \brief Create collective communicators * * Hook function to handle collective-specific optimization during communicator creation */void MPIDI_Coll_Comm_create (MPID_Comm *comm){  MPID_assert (comm!= NULL);  int global=0;  MPID_Comm *comm_world;  if (comm->coll_fns) MPIU_Free(comm->coll_fns);  comm->coll_fns=NULL;   /* !!! Intercomm_merge does not NULL the fcns,                          * leading to stale functions for new comms.                          * We'll null it here until argonne confirms                          * this is the correct behavior of merge                          */   /* comm-specific protocol flags */   comm->dcmf.allreducetree = 1;   comm->dcmf.reducetree = 1;   comm->dcmf.allreduceccmitree = 1;   comm->dcmf.reduceccmitree = 1;   comm->dcmf.bcasttree = 1;    comm->dcmf.alltoalls = 1;  /* ****************************************** */  /* Allocate space for the collective pointers */  /* ****************************************** */   comm->coll_fns = (MPID_Collops *)MPIU_Malloc(sizeof(MPID_Collops));   MPID_assert(comm->coll_fns != NULL);   memset(comm->coll_fns, 0, sizeof(MPID_Collops));  /* ****************************************** */  /* Set all defaults                           */  /* ****************************************** */  comm->dcmf.worldranks              = NULL;  /* If we are an intracomm, MPICH should handle */  if (comm->comm_kind != MPID_INTRACOMM) return;  /* User may disable all collectives */  if (!MPIDI_Process.optimized.collectives) return;   MPID_Comm_get_ptr(MPI_COMM_WORLD, comm_world);   MPID_assert_debug(comm_world != NULL);   /* creates ranks array in comm, geometry stores pointer to this array */   /* should we pass the returned int * to geometry_init? */  MPIDI_Comm_worldranks_init(comm);   if(MPIR_ThreadInfo.thread_provided == MPI_THREAD_MULTIPLE)   {      if(comm != comm_world)      {         global = 0;         /* alltoall protocols not entirely thread-safe so turn off for this          * communicator          */          comm->dcmf.alltoalls = 0;      }      /* we are comm_world */      else         global = 1;   }   else /* single MPI thread. */   {      /* and if we are a dupe of comm_world, global context is also safe */     if(comm->local_size == comm_world->local_size)       global = 1;     else       global = 0;   }  /* ****************************************** */  /* These are ALL the pointers in the object   */  /* ****************************************** */      comm->coll_fns->Barrier        = MPIDO_Barrier;      comm->coll_fns->Bcast          = MPIDO_Bcast;      comm->coll_fns->Reduce         = MPIDO_Reduce;      comm->coll_fns->Allreduce      = MPIDO_Allreduce;      comm->coll_fns->Alltoall       = MPIDO_Alltoall;      comm->coll_fns->Alltoallv      = MPIDO_Alltoallv;      comm->coll_fns->Alltoallw       = MPIDO_Alltoallw;      comm->coll_fns->Allgather      = MPIDO_Allgather;      comm->coll_fns->Allgatherv     = MPIDO_Allgatherv;  comm->coll_fns->Gather         = MPIDO_Gather;  comm->coll_fns->Gatherv        = MPIDO_Gatherv;  comm->coll_fns->Scatter        = MPIDO_Scatter;  comm->coll_fns->Scatterv       = MPIDO_Scatterv;  comm->coll_fns->Reduce_scatter = MPIDO_Reduce_scatter;  comm->coll_fns->Scan           = MPIDO_Scan;  comm->coll_fns->Exscan         = MPIDO_Exscan;     /* ******************************************************* */  /* Setup Barriers and geometry for this communicator       */  /* ******************************************************* */  DCMF_Geometry_initialize(             &comm->dcmf.geometry,             comm->context_id,             comm->dcmf.worldranks,             comm->local_size,             barriers,             barriers_num,             local_barriers,             local_barriers_num,             &comm->dcmf.barrier,             MPIDI_CollectiveProtocols.numcolors,             global);//   fprintf(stderr,//       "context_id: %d, context_id mod MAX: %d\n",//       comm->context_id, (comm->context_id) % MAXGEOMETRIES);   mpid_geometrytable[(comm->context_id)%MAXGEOMETRIES] = &comm->dcmf.geometry;   if((MPIDI_CollectiveProtocols.allreduce.usetree ||       MPIDI_CollectiveProtocols.allreduce.useccmitree) &&      !DCMF_Geometry_analyze(&comm->dcmf.geometry,			     &MPIDI_CollectiveProtocols.allreduce.tree))   {       comm->dcmf.allreducetree = 0;       comm->dcmf.allreduceccmitree = 0;   }   else   {       comm->dcmf.allreducetree = MPIDI_CollectiveProtocols.allreduce.usetree;       comm->dcmf.allreduceccmitree = MPIDI_CollectiveProtocols.allreduce.useccmitree;   }   if((MPIDI_CollectiveProtocols.reduce.usetree ||       MPIDI_CollectiveProtocols.reduce.useccmitree) &&      !DCMF_Geometry_analyze(&comm->dcmf.geometry,			     &MPIDI_CollectiveProtocols.reduce.tree))   {       comm->dcmf.reducetree = 0;       comm->dcmf.reduceccmitree = 0;   }   else   {       comm->dcmf.reducetree = MPIDI_CollectiveProtocols.reduce.usetree;       comm->dcmf.reduceccmitree = MPIDI_CollectiveProtocols.reduce.useccmitree;   }      if(MPIDI_CollectiveProtocols.allreduce.usepipelinedtree &&      !DCMF_Geometry_analyze(&comm->dcmf.geometry,			     &MPIDI_CollectiveProtocols.allreduce.pipelinedtree))     comm->dcmf.allreducepipelinedtree = 0;   else     comm->dcmf.allreducepipelinedtree = MPIDI_CollectiveProtocols.allreduce.usepipelinedtree;   if(MPIDI_CollectiveProtocols.broadcast.usetree &&      !DCMF_Geometry_analyze(&comm->dcmf.geometry,			     &MPIDI_CollectiveProtocols.broadcast.tree))     comm->dcmf.bcasttree = 0;   else     comm->dcmf.bcasttree = MPIDI_CollectiveProtocols.broadcast.usetree;   comm->dcmf.sndlen = NULL;   comm->dcmf.rcvlen = NULL;   comm->dcmf.sdispls = NULL;   comm->dcmf.rdispls = NULL;   comm->dcmf.sndcounters = NULL;   comm->dcmf.rcvcounters = NULL;   if(MPIDI_CollectiveProtocols.alltoall.premalloc)   {      comm->dcmf.sndlen = MPIU_Malloc(sizeof(unsigned) * comm->local_size);      comm->dcmf.rcvlen = MPIU_Malloc(sizeof(unsigned) * comm->local_size);      comm->dcmf.sdispls = MPIU_Malloc(sizeof(unsigned) * comm->local_size);      comm->dcmf.rdispls = MPIU_Malloc(sizeof(unsigned) * comm->local_size);      comm->dcmf.sndcounters = MPIU_Malloc(sizeof(unsigned) * comm->local_size);      comm->dcmf.rcvcounters = MPIU_Malloc(sizeof(unsigned) * comm->local_size);   }    MPIR_Barrier(comm);}/** * \brief Destroy a communicator * * Hook function to handle collective-specific optimization during communicator destruction * * \note  We want to free the associated coll_fns buffer at this time. */void MPIDI_Coll_Comm_destroy (MPID_Comm *comm){  MPID_assert (comm != NULL);  if (comm->coll_fns) MPIU_Free(comm->coll_fns); comm->coll_fns = NULL;  if(comm->dcmf.worldranks) MPIU_Free(comm->dcmf.worldranks);  DCMF_Geometry_free(&comm->dcmf.geometry);  comm->dcmf.worldranks=NULL;  if(comm->dcmf.sndlen)   MPIU_Free(comm->dcmf.sndlen);  if(comm->dcmf.rcvlen)   MPIU_Free(comm->dcmf.rcvlen);  if(comm->dcmf.sdispls)   MPIU_Free(comm->dcmf.sdispls);  if(comm->dcmf.rdispls)   MPIU_Free(comm->dcmf.rdispls);  if(comm->dcmf.sndcounters)   MPIU_Free(comm->dcmf.sndcounters);  if(comm->dcmf.rcvcounters)   MPIU_Free(comm->dcmf.rcvcounters);  comm->dcmf.sndlen = comm->dcmf.rcvlen =  comm->dcmf.sdispls = comm->dcmf.rdispls =  comm->dcmf.sndcounters = comm->dcmf.rcvcounters = NULL;}

⌨️ 快捷键说明

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