Changeset 23502


Ignore:
Timestamp:
12/04/18 08:48:03 (6 years ago)
Author:
Mathieu Morlighem
Message:

CHG: trying to simplify Vertices Pid distribution, more changes to come

Location:
issm/trunk-jpl/src/c/classes
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/classes/Vertices.cpp

    r22780 r23502  
    101101void  Vertices::FlagClones(int numberofobjects){/*{{{*/
    102102
    103         int i;
    104         int num_procs;
     103        /*Some checks in debug mode*/
     104        _assert_(numberofobjects>0);
    105105
    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();
    111109
    112110        /*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.
    115113
    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        }
    120119
    121120        /*We need to take the minimum rank for each vertex, and every cpu needs to get that result. That way,
     
    123122         * dealt with by another cpu. We take the minimum because we are going to manage dof assignment in increasing
    124123         * 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);
    126127
    127128        /*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++){
    129130                /*For this object, decide whether it is a clone: */
    130131                Vertex* vertex=xDynamicCast<Vertex*>(this->GetObjectByOffset(i));
     
    133134
    134135        /*Free ressources: */
    135         xDelete<int>(ranks);
    136136        xDelete<int>(minranks);
    137 
    138 }
    139 /*}}}*/
     137}/*}}}*/
    140138int Vertices::NumberOfVertices(void){/*{{{*/
    141139
     
    161159        /*return:*/
    162160        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         }
    180161}
    181162/*}}}*/
  • issm/trunk-jpl/src/c/classes/Vertices.h

    r22778 r23502  
    2424                void  FlagClones(int numberofnodes);
    2525                int   NumberOfVertices(void);
    26                 void  Ranks(int* ranks);
    27                 void LatLonList(IssmDouble** lat,IssmDouble** lon);
     26                void  LatLonList(IssmDouble** lat,IssmDouble** lon);
    2827};
    2928
Note: See TracChangeset for help on using the changeset viewer.