Changeset 23502
- Timestamp:
- 12/04/18 08:48:03 (6 years ago)
- Location:
- issm/trunk-jpl/src/c/classes
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/classes/Vertices.cpp
r22780 r23502 101 101 void Vertices::FlagClones(int numberofobjects){/*{{{*/ 102 102 103 int i;104 int num_procs;103 /*Some checks in debug mode*/ 104 _assert_(numberofobjects>0); 105 105 106 int* ranks=NULL; 107 int* minranks=NULL; 108 109 /*recover num_procs:*/ 110 num_procs=IssmComm::GetSize(); 106 /*recover num_procs and rank*/ 107 int num_procs = IssmComm::GetSize(); 108 int my_rank = IssmComm::GetRank(); 111 109 112 110 /*Allocate ranks: */ 113 ranks=xNew<int>(numberofobjects);114 minranks=xNew<int>(numberofobjects);111 int *ranks = xNew<int>(numberofobjects); 112 for(int i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. 115 113 116 for(i=0;i<numberofobjects;i++)ranks[i]=num_procs; //no cpu can have rank num_procs. This is the maximum limit. 117 118 /*Now go through all our objects and ask them to report to who they belong (which rank): */ 119 Ranks(ranks); 114 /*Go through a dataset, and for each object, report it cpu: */ 115 for(int i=0;i<this->Size();i++){ 116 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); 117 ranks[vertex->Sid()]=my_rank; 118 } 120 119 121 120 /*We need to take the minimum rank for each vertex, and every cpu needs to get that result. That way, … … 123 122 * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing 124 123 * order of cpu rank. This is also why we initialized this array to num_procs.*/ 125 ISSM_MPI_Allreduce ( (void*)ranks,(void*)minranks,numberofobjects,ISSM_MPI_INT,ISSM_MPI_MIN,IssmComm::GetComm()); 124 int *minranks = xNew<int>(numberofobjects); 125 ISSM_MPI_Allreduce((void*)ranks,(void*)minranks,numberofobjects,ISSM_MPI_INT,ISSM_MPI_MIN,IssmComm::GetComm()); 126 xDelete<int>(ranks); 126 127 127 128 /*Now go through all objects, and use minranks to flag which objects are cloned: */ 128 for(i =0;i<this->Size();i++){129 for(int i=0;i<this->Size();i++){ 129 130 /*For this object, decide whether it is a clone: */ 130 131 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i)); … … 133 134 134 135 /*Free ressources: */ 135 xDelete<int>(ranks);136 136 xDelete<int>(minranks); 137 138 } 139 /*}}}*/ 137 }/*}}}*/ 140 138 int Vertices::NumberOfVertices(void){/*{{{*/ 141 139 … … 161 159 /*return:*/ 162 160 return max_sid; 163 }164 /*}}}*/165 void Vertices::Ranks(int* ranks){/*{{{*/166 167 int my_rank;168 int sid;169 170 /*recover my_rank:*/171 my_rank=IssmComm::GetRank();172 173 /*Go through a dataset, and for each object, report it cpu: */174 for(int i=0;i<this->Size();i++){175 /*Plug rank into ranks, according to id: */176 Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));177 sid=vertex->Sid();178 ranks[sid]=my_rank;179 }180 161 } 181 162 /*}}}*/ -
issm/trunk-jpl/src/c/classes/Vertices.h
r22778 r23502 24 24 void FlagClones(int numberofnodes); 25 25 int NumberOfVertices(void); 26 void Ranks(int* ranks); 27 void LatLonList(IssmDouble** lat,IssmDouble** lon); 26 void LatLonList(IssmDouble** lat,IssmDouble** lon); 28 27 }; 29 28
Note:
See TracChangeset
for help on using the changeset viewer.