Changeset 16438


Ignore:
Timestamp:
10/16/13 22:26:48 (11 years ago)
Author:
Eric.Larour
Message:

CHG: optimizing sparse mpi matrix

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

Legend:

Unmodified
Added
Removed
  • TabularUnified issm/trunk-jpl/src/c/modules/AllocateSystemMatricesx/AllocateSystemMatricesx.cpp

    r16126 r16438  
    2424
    2525        bool oldalloc=false;
     26        char* toolkittype=NULL;
    2627
    2728        /*retrieve parameters: */
     
    3637
    3738        numberofdofspernode=femmodel->nodes->MaxNumDofs(configuration_type,GsetEnum);
     39
     40        /*if our matrices are coming from issm, we don't do dynamic allocation like Petsc
     41         * does, and this routine is essentially useless. Force oldalloc in this case: */
     42        toolkittype=ToolkitOptions::GetToolkitType();
     43        if(strcmp(toolkittype,"issm")==0)oldalloc=true;
    3844
    3945        if(oldalloc){
     
    6369                if(ppf) pf =new Vector<IssmDouble>(flocalsize,fsize);
    6470        }
     71       
     72        /*Free ressources: */
     73        xDelete<char>(toolkittype);
    6574
    6675        /*Allocate output pointers*/
  • TabularUnified issm/trunk-jpl/src/c/toolkits/issm/SparseRow.h

    r16415 r16438  
    1313class SparseRow{
    1414
     15        private:
     16                int*        buffer; //used during SetValues
     17
    1518        public:
    1619
     
    1922                int*        indices;
    2023                doubletype* values;
    21 
     24               
    2225                /*SparseRow constructors, destructors*/
    2326                SparseRow(){ /*{{{*/
     
    2629                         indices=NULL;
    2730                         values=NULL;
     31                         buffer=NULL;
    2832                } /*}}}*/
    2933                SparseRow(int in_M){/*{{{*/
     
    3337                        indices=NULL;
    3438                        values=NULL;
     39
     40                        buffer=xNewZeroInit<int>(M);
    3541                } /*}}}*/
    3642                ~SparseRow(){/*{{{*/
     
    3945                                xDelete<doubletype>(values);
    4046                        }
     47                        if(buffer)xDelete<int>(buffer);
    4148                } /*}}}*/
    4249
     
    5360                        int count;
    5461                        int i,j;
    55                         int* buffer=NULL;
    5662
    5763                        if(!M)_error_("unknow dimension for this sparse row!");
     
    6773
    6874                        /*Figure out number of non-zero values ncols: */
    69                         buffer=xNewZeroInit<int>(M);
     75                        for(i=0;i<numvalues;i++)buffer[i]=0;
     76                       
     77                        ncols=0;
    7078                        for(i=0;i<numvalues;i++){
     79                                if(!buffer[cols[i]])ncols++;
    7180                                if(mods[i]==ADD_VAL){
    7281                                        if(buffer[cols[i]]!=2)buffer[cols[i]]=1;
     
    7483                                else buffer[cols[i]]=2;
    7584                        }
    76                         ncols=0;
    77                         for(i=0;i<M;i++)if(buffer[i]!=0)ncols++;
    78                         _assert_(ncols);
    79 
    8085
    8186                        /*Allocate:*/
     
    109114                        }
    110115                        if(count!=ncols)_error_("counter problem during set values operations");
    111 
    112                         /*Free ressources: */
    113                         xDelete<int>(buffer);
    114 
    115116                } /*}}}*/
    116117                doubletype Norm(NormMode mode){ /*{{{*/
Note: See TracChangeset for help on using the changeset viewer.