Changeset 14727


Ignore:
Timestamp:
04/23/13 21:31:41 (12 years ago)
Author:
Eric.Larour
Message:

CHG: fixed matlab wrappers. i/o had to be updated so that MatlabVectorTo... and MatlabMatrixTo...
routines were up to date with the new ISSM toolkit.

Location:
issm/trunk-jpl
Files:
3 added
3 deleted
9 edited

Legend:

Unmodified
Added
Removed
  • issm/trunk-jpl/src/c/Makefile.am

    r14714 r14727  
    750750                                ./toolkits/mpi/patches/mpipatches.h\
    751751                                ./toolkits/mpi/patches/DetermineLocalSize.cpp\
     752                                ./toolkits/mpi/patches/DetermineGlobalSize.cpp\
    752753                                ./toolkits/mpi/patches/DetermineRowRankFromLocalSize.cpp\
    753754                                ./toolkits/mpi/patches/GetOwnershipBoundariesFromRange.cpp\
  • issm/trunk-jpl/src/c/classes/objects/Bucket.h

    r14709 r14727  
    5252                                this->values=xNew<doubletype>(this->n*this->m);
    5353                                xMemCpy(this->values,valuesin,this->n*this->m);
     54                        }
     55                } /*}}}*/
     56                Bucket(int min,int* idxmin,doubletype* valuesin,InsMode modein){ /*{{{*/
     57                        this->m=min;
     58                        this->n=1;
     59                        this->mode=modein;
     60                        if(this->m){
     61                                this->idxm=xNew<int>(this->m);
     62                                xMemCpy(this->idxm,idxmin,this->m);
     63                        }
     64                        if(this->m){
     65                                this->values=xNew<doubletype>(this->m);
     66                                xMemCpy(this->values,valuesin,this->m);
    5467                        }
    5568                } /*}}}*/
     
    119132                };
    120133                /*}}}*/
    121                 void Isend(int receiver_rank,MPI_Request* requests,int* pcount,MPI_Comm comm){ /*{{{*/
     134#ifdef _HAVE_MPI_
     135                        void Isend(int receiver_rank,MPI_Request* requests,int* pcount,MPI_Comm comm){ /*{{{*/
    122136                        int count=0;
    123137                        int int_mode;
     
    162176
    163177                } /*}}}*/
     178#endif
    164179};
    165180
  • issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h

    r14671 r14727  
    2222#include "../../shared/Alloc/alloc.h"
    2323#include "../../include/macros.h"
     24#ifdef _HAVE_MPI_
     25#include "../mpi/mpiincludes.h"
     26#endif
    2427#include <math.h>
    2528
     
    3639        public:
    3740
    38                 doubletype* vector;
    39                 int M;
     41                int M; //global size
     42                int m; //local number of rows
     43                doubletype* vector;  /*here, doubletype is either IssmDouble or IssmPDouble*/
     44                DataSet*    buckets;  /*here, we store buckets of values that we will Assemble into a global vector.*/
    4045
    4146                /*IssmMpiVec constructors, destructors*/
     
    4449
    4550                        this->M=0;
     51                        this->m=0;
    4652                        this->vector=NULL;
     53                        this->buckets=new DataSet();
    4754                }
    4855                /*}}}*/
    4956                /*FUNCTION IssmMpiVec(int M){{{*/
    50                 IssmMpiVec(int pM){
    51 
    52                         this->M=pM;
     57                IssmMpiVec(int Min){
     58                        this->Init(Min,false);
     59                }
     60                /*}}}*/
     61                /*FUNCTION IssmMpiVec(int m,int M){{{*/
     62                /*IssmMpiVec(int min,int Min){
     63                        this->Init(Min,false);
     64                }*/
     65                /*}}}*/
     66                /*FUNCTION IssmMpiVec(int M,bool fromlocalsize){{{*/
     67                IssmMpiVec(int Min, bool fromlocalsize){
     68                        this->Init(Min,fromlocalsize);
     69                }
     70                /*}}}*/
     71                /*FUNCTION IssmMpiVec(doubletype* serial_vec,int M){{{*/
     72                IssmMpiVec(doubletype* buffer,int Min){
     73
     74                        this->Init(Min,false);
     75
     76                        if(this->M){
     77                                this->vector=xNew<doubletype>(Min);
     78                                xMemCpy<doubletype>(this->vector,buffer,this->m);
     79                        }
     80                }
     81                /*}}}*/
     82                /*FUNCTION IssmMpiVec::Init(int Min,bool fromlocalsize){{{*/
     83                void Init(int Min,bool fromlocalsize){
     84
     85                        this->buckets=new DataSet();
     86                       
     87                        if(fromlocalsize){
     88                                this->m=Min;
     89                                this->M=DetermineGlobalSize(this->m,IssmComm::GetComm());
     90                        }
     91                        else{
     92                                this->M=Min;
     93                                this->m=DetermineLocalSize(this->M,IssmComm::GetComm());
     94                        }
     95                       
     96                        /*Initialize pointer: */
    5397                        this->vector=NULL;
    54                         if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
    55                 }
    56                 /*}}}*/
    57                 /*FUNCTION IssmMpiVec(int m,int M){{{*/
    58                 IssmMpiVec(int pm,int pM){
    59 
    60                         this->M=pM;
    61                         this->vector=NULL;
    62                         if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
    63                 }
    64                 /*}}}*/
    65                 /*FUNCTION IssmMpiVec(int M,bool fromlocalsize){{{*/
    66                 IssmMpiVec(int pM,bool fromlocalsize){
    67 
    68                         this->M=pM;
    69                         this->vector=NULL;
    70                         if(this->M) this->vector=xNewZeroInit<doubletype>(pM);
    71                 }
    72                 /*}}}*/
    73                 /*FUNCTION IssmMpiVec(doubletype* serial_vec,int M){{{*/
    74                 IssmMpiVec(doubletype* buffer,int pM){
    75 
    76                         this->M=pM;
    77                         this->vector=NULL;
    78                         if(this->M){
    79                                 this->vector=xNew<doubletype>(pM);
    80                                 xMemCpy<doubletype>(this->vector,buffer,pM);
    81                         }
     98
     99                        /*Allocate: */
     100                        if (m)this->vector=xNewZeroInit<doubletype>(this->m);
    82101                }
    83102                /*}}}*/
     
    85104                ~IssmMpiVec(){
    86105                        xDelete<doubletype>(this->vector);
    87                         M=0;
     106                        this->M=0;
     107                        this->n=0;
     108                        delete buckets;
    88109                }
    89110                /*}}}*/
     
    92113                /*FUNCTION Echo{{{*/
    93114                void Echo(void){
    94 
    95                         int i;
    96                         _printLine_("IssmMpiVec size " << this->M);
    97                         for(i=0;i<M;i++){
    98                                 _printString_(vector[i] << "\n ");
     115                       
     116                        int i,j;
     117
     118                        /*Do a synchronized dump across all the rows: */
     119                        for(i=0;i<IssmComm::GetSize();i++){
     120                                if (IssmComm::GetRank()==i){
     121                                        printf("cpu %i #rows: %i\n",i,this->m);
     122                                        for (j=0;j<this->m;j++){
     123                                                printf("row %i %g",j,this->vector[j]);
     124                                        }
     125                                }
     126                                MPI_Barrier(IssmComm::GetComm());
    99127                        }
    100128                }
     
    102130                /*FUNCTION Assemble{{{*/
    103131                void Assemble(void){
    104 
    105                         /*do nothing*/
    106 
     132                        _error_("not implemented yet!");
    107133                }
    108134                /*}}}*/
    109135                /*FUNCTION SetValues{{{*/
    110136                void SetValues(int ssize, int* list, doubletype* values, InsMode mode){
    111 
    112                         int i;
    113                         switch(mode){
    114                                 case ADD_VAL:
    115                                         for(i=0;i<ssize;i++) this->vector[list[i]]+=values[i];
    116                                         break;
    117                                 case INS_VAL:
    118                                         for(i=0;i<ssize;i++) this->vector[list[i]]=values[i];
    119                                         break;
    120                                 default:
    121                                         _error_("unknown insert mode!");
    122                                         break;
    123                         }
     137                       
     138                        /*we need to store all the values we collect here in order to Assemble later.
     139                         * Indeed, the values we are collecting here most of the time will not belong
     140                         * to us, but to another part of the vector on another cpu: */
     141                        _assert_(buckets);
     142
     143                        buckets->AddObject(new Bucket<doubletype>(ssize, list, values, mode));
    124144
    125145                }
     
    128148                void SetValue(int dof, doubletype value, InsMode mode){
    129149
    130                         switch(mode){
    131                                 case ADD_VAL:
    132                                         this->vector[dof]+=value;
    133                                         break;
    134                                 case INS_VAL:
    135                                         this->vector[dof]=value;
    136                                         break;
    137                                 default:
    138                                         _error_("unknown insert mode!");
    139                                         break;
    140                         }
     150                        /*we need to store the value we collect here in order to Assemble later.
     151                         * Indeed, the value we are collecting here most of the time will not belong
     152                         * to us, but to another part of the vector on another cpu: */
     153                        _assert_(buckets);
     154
     155                        buckets->AddObject(new Bucket<doubletype>(1,&dof,&value, mode));
    141156                }
    142157                /*}}}*/
    143158                /*FUNCTION GetValue{{{*/
    144159                void GetValue(doubletype* pvalue,int dof){
    145 
    146                         *pvalue=this->vector[dof];
     160                        _error_("Get value on a MpiVec vector not implemented yet!");
    147161
    148162                }
     
    158172                void GetLocalSize(int* pM){
    159173
    160                         *pM=this->M;
     174                        *pM=this->m;
    161175
    162176                }
     
    173187
    174188                        int i;
    175                         for(i=0;i<this->M;i++)this->vector[i]=value;
     189                        for(i=0;i<this->m;i++)this->vector[i]=value;
    176190
    177191                }
     
    179193                /*FUNCTION AXPY{{{*/
    180194                void AXPY(IssmAbsVec<doubletype>* Xin, doubletype a){
    181 
    182                         int i;
    183                        
    184                         /*Assume X is of the correct type, and downcast: */
    185                         IssmMpiVec* X=NULL;
    186 
    187                         X=(IssmMpiVec<doubletype>*)Xin;
    188 
    189 
    190                         /*y=a*x+y where this->vector is y*/
    191                         for(i=0;i<this->M;i++)this->vector[i]=a*X->vector[i]+this->vector[i];
    192 
     195                        _error_("not implemented yet!");
    193196                }
    194197                /*}}}*/
    195198                /*FUNCTION AYPX{{{*/
    196199                void AYPX(IssmAbsVec<doubletype>* Xin, doubletype a){
    197 
    198                         int i;
    199 
    200                         /*Assume X is of the correct type, and downcast: */
    201                         IssmMpiVec* X=NULL;
    202 
    203                         X=(IssmMpiVec<doubletype>*)Xin;
    204 
    205                         /*y=x+a*y where this->vector is y*/
    206                         for(i=0;i<this->M;i++)this->vector[i]=X->vector[i]+a*this->vector[i];
    207 
     200                        _error_("not implemented yet!");
    208201                }
    209202                /*}}}*/
  • issm/trunk-jpl/src/c/toolkits/mpi/patches/mpipatches.h

    r14706 r14727  
    1111int* DetermineRowRankFromLocalSize(int global_size,int localsize,COMM comm);
    1212void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range,COMM comm);
     13int DetermineGlobalSize(int local_size,COMM comm);
    1314
    1415#endif
  • issm/trunk-jpl/src/wrappers/matlab/Makefile.am

    r14716 r14727  
    2323                                ./io/MatlabVectorToDoubleVector.cpp\
    2424                                ./io/MatlabMatrixToDoubleMatrix.cpp\
    25                                 ./io/MatlabMatrixToIssmDenseMat.cpp\
    26                                 ./io/MatlabVectorToIssmSeqVec.cpp
     25                                ./io/MatlabMatrixToIssmMat.cpp\
     26                                ./io/MatlabVectorToIssmVec.cpp
    2727                               
    2828if PETSC
  • issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp

    r14656 r14727  
    2525        matrix->pmatrix=MatlabMatrixToPetscMat(mxmatrix);
    2626        #else
    27         matrix->smatrix=MatlabMatrixToIssmDenseMat(mxmatrix);
     27        matrix->imatrix=MatlabMatrixToIssmMat(mxmatrix);
    2828        #endif
    2929
  • issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp

    r14656 r14727  
    2525        vector->pvector=MatlabVectorToPetscVec(mxvector);
    2626        #else
    27         vector->svector=MatlabVectorToIssmSeqVec(mxvector);
     27        vector->ivector=MatlabVectorToIssmVec(mxvector);
    2828        #endif
    2929
  • issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h

    r14719 r14727  
    8585
    8686/*Matlab to IssmDenseMat routines: */
    87 IssmDenseMat<double>* MatlabMatrixToIssmDenseMat(const mxArray* dataref);
    88 IssmSeqVec<double>* MatlabVectorToIssmSeqVec(const mxArray* dataref);
     87IssmMat<double>* MatlabMatrixToIssmMat(const mxArray* dataref);
     88IssmVec<double>* MatlabVectorToIssmVec(const mxArray* dataref);
    8989
    9090/*Matlab to Petsc routines: */
  • issm/trunk-jpl/test/NightlyRun/test101.m

    r13670 r14727  
    33md=parameterize(md,'../Par/SquareShelfConstrained.par');
    44md=setflowequation(md,'macayeal','all');
    5 md.cluster=generic('name',oshostname(),'np',3);
     5md.cluster=generic('name',oshostname(),'np',8);
    66md.diagnostic.requested_outputs=StressTensorEnum();
     7md.toolkits.DefaultAnalysis=issmsolver();
     8md.verbose=verbose('11111111');
     9%md.debug.valgrind=true;
    710md=solve(md,DiagnosticSolutionEnum());
    811
Note: See TracChangeset for help on using the changeset viewer.