Changeset 16424


Ignore:
Timestamp:
10/16/13 08:36:27 (11 years ago)
Author:
Eric.Larour
Message:

CHG: improving hopefully on speed.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiSparseMat.h

    r16419 r16424  
    192192                        int*          this_row_mods       = NULL;
    193193                        doubletype*   this_row_values     = NULL;
     194                        int*          numvalues_perrow    = NULL;
    194195                        int           row;
    195196
     
    274275                        /*Plug values into global matrix. To do so, we are going to first figure out how many overall values each sparse row is going to get, then we fill up these values, and give it to each sparse row: {{{*/
    275276                        GetOwnershipBoundariesFromRange(&lower_row,&upper_row,m,comm);
     277
     278                        /*Figure out how many values each row is going to get: */
     279                        numvalues_perrow=xNewZeroInit<int>(this->m);
     280                        for(i=0;i<num_procs;i++){
     281                                int  numvalues=numvalues_fromcpu[i];
     282                                int* rows=row_indices_fromcpu[i];
     283                                for(j=0;j<numvalues;j++)numvalues_perrow[rows[j]-lower_row]++;
     284                        }
     285
    276286                       
    277287                        /*Deal with sparse row one at a time: */
    278288                        for(row=0;row<this->m;row++){
    279289
    280                                 /*figure out how many values this row is going to get: */
    281                                 count=0;
    282                                 for(i=0;i<num_procs;i++){
    283                                         int  numvalues=numvalues_fromcpu[i];
    284                                         int* rows=row_indices_fromcpu[i];
    285                                         for(j=0;j<numvalues;j++)if((rows[j]-lower_row)==row)count++;
    286                                 }
    287 
    288290                                /*Allocate: */
    289                                 this_row_numvalues=count;
     291                                this_row_numvalues=numvalues_perrow[row];
    290292                                this_row_cols=xNew<int>(this_row_numvalues);
    291293                                this_row_values=xNew<doubletype>(this_row_numvalues);
     
    323325
    324326                        /*Free ressources:{{{*/
     327                        xDelete<int>(numvalues_perrow);
    325328                        xDelete<int>(RowRank);
    326329                        xDelete<int>(row_indices_forcpu);
Note: See TracChangeset for help on using the changeset viewer.