Changeset 14727
- Timestamp:
- 04/23/13 21:31:41 (12 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 3 added
- 3 deleted
- 9 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/Makefile.am
r14714 r14727 750 750 ./toolkits/mpi/patches/mpipatches.h\ 751 751 ./toolkits/mpi/patches/DetermineLocalSize.cpp\ 752 ./toolkits/mpi/patches/DetermineGlobalSize.cpp\ 752 753 ./toolkits/mpi/patches/DetermineRowRankFromLocalSize.cpp\ 753 754 ./toolkits/mpi/patches/GetOwnershipBoundariesFromRange.cpp\ -
issm/trunk-jpl/src/c/classes/objects/Bucket.h
r14709 r14727 52 52 this->values=xNew<doubletype>(this->n*this->m); 53 53 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); 54 67 } 55 68 } /*}}}*/ … … 119 132 }; 120 133 /*}}}*/ 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){ /*{{{*/ 122 136 int count=0; 123 137 int int_mode; … … 162 176 163 177 } /*}}}*/ 178 #endif 164 179 }; 165 180 -
issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h
r14671 r14727 22 22 #include "../../shared/Alloc/alloc.h" 23 23 #include "../../include/macros.h" 24 #ifdef _HAVE_MPI_ 25 #include "../mpi/mpiincludes.h" 26 #endif 24 27 #include <math.h> 25 28 … … 36 39 public: 37 40 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.*/ 40 45 41 46 /*IssmMpiVec constructors, destructors*/ … … 44 49 45 50 this->M=0; 51 this->m=0; 46 52 this->vector=NULL; 53 this->buckets=new DataSet(); 47 54 } 48 55 /*}}}*/ 49 56 /*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: */ 53 97 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); 82 101 } 83 102 /*}}}*/ … … 85 104 ~IssmMpiVec(){ 86 105 xDelete<doubletype>(this->vector); 87 M=0; 106 this->M=0; 107 this->n=0; 108 delete buckets; 88 109 } 89 110 /*}}}*/ … … 92 113 /*FUNCTION Echo{{{*/ 93 114 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()); 99 127 } 100 128 } … … 102 130 /*FUNCTION Assemble{{{*/ 103 131 void Assemble(void){ 104 105 /*do nothing*/ 106 132 _error_("not implemented yet!"); 107 133 } 108 134 /*}}}*/ 109 135 /*FUNCTION SetValues{{{*/ 110 136 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)); 124 144 125 145 } … … 128 148 void SetValue(int dof, doubletype value, InsMode mode){ 129 149 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)); 141 156 } 142 157 /*}}}*/ 143 158 /*FUNCTION GetValue{{{*/ 144 159 void GetValue(doubletype* pvalue,int dof){ 145 146 *pvalue=this->vector[dof]; 160 _error_("Get value on a MpiVec vector not implemented yet!"); 147 161 148 162 } … … 158 172 void GetLocalSize(int* pM){ 159 173 160 *pM=this-> M;174 *pM=this->m; 161 175 162 176 } … … 173 187 174 188 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; 176 190 177 191 } … … 179 193 /*FUNCTION AXPY{{{*/ 180 194 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!"); 193 196 } 194 197 /*}}}*/ 195 198 /*FUNCTION AYPX{{{*/ 196 199 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!"); 208 201 } 209 202 /*}}}*/ -
issm/trunk-jpl/src/c/toolkits/mpi/patches/mpipatches.h
r14706 r14727 11 11 int* DetermineRowRankFromLocalSize(int global_size,int localsize,COMM comm); 12 12 void GetOwnershipBoundariesFromRange(int* plower_row,int* pupper_row,int range,COMM comm); 13 int DetermineGlobalSize(int local_size,COMM comm); 13 14 14 15 #endif -
issm/trunk-jpl/src/wrappers/matlab/Makefile.am
r14716 r14727 23 23 ./io/MatlabVectorToDoubleVector.cpp\ 24 24 ./io/MatlabMatrixToDoubleMatrix.cpp\ 25 ./io/MatlabMatrixToIssm DenseMat.cpp\26 ./io/MatlabVectorToIssm SeqVec.cpp25 ./io/MatlabMatrixToIssmMat.cpp\ 26 ./io/MatlabVectorToIssmVec.cpp 27 27 28 28 if PETSC -
issm/trunk-jpl/src/wrappers/matlab/io/MatlabMatrixToMatrix.cpp
r14656 r14727 25 25 matrix->pmatrix=MatlabMatrixToPetscMat(mxmatrix); 26 26 #else 27 matrix-> smatrix=MatlabMatrixToIssmDenseMat(mxmatrix);27 matrix->imatrix=MatlabMatrixToIssmMat(mxmatrix); 28 28 #endif 29 29 -
issm/trunk-jpl/src/wrappers/matlab/io/MatlabVectorToVector.cpp
r14656 r14727 25 25 vector->pvector=MatlabVectorToPetscVec(mxvector); 26 26 #else 27 vector-> svector=MatlabVectorToIssmSeqVec(mxvector);27 vector->ivector=MatlabVectorToIssmVec(mxvector); 28 28 #endif 29 29 -
issm/trunk-jpl/src/wrappers/matlab/io/matlabio.h
r14719 r14727 85 85 86 86 /*Matlab to IssmDenseMat routines: */ 87 Issm DenseMat<double>* MatlabMatrixToIssmDenseMat(const mxArray* dataref);88 Issm SeqVec<double>* MatlabVectorToIssmSeqVec(const mxArray* dataref);87 IssmMat<double>* MatlabMatrixToIssmMat(const mxArray* dataref); 88 IssmVec<double>* MatlabVectorToIssmVec(const mxArray* dataref); 89 89 90 90 /*Matlab to Petsc routines: */ -
issm/trunk-jpl/test/NightlyRun/test101.m
r13670 r14727 3 3 md=parameterize(md,'../Par/SquareShelfConstrained.par'); 4 4 md=setflowequation(md,'macayeal','all'); 5 md.cluster=generic('name',oshostname(),'np', 3);5 md.cluster=generic('name',oshostname(),'np',8); 6 6 md.diagnostic.requested_outputs=StressTensorEnum(); 7 md.toolkits.DefaultAnalysis=issmsolver(); 8 md.verbose=verbose('11111111'); 9 %md.debug.valgrind=true; 7 10 md=solve(md,DiagnosticSolutionEnum()); 8 11
Note:
See TracChangeset
for help on using the changeset viewer.