Changeset 21615
- Timestamp:
- 03/16/17 13:02:24 (8 years ago)
- Location:
- issm/trunk-jpl
- Files:
-
- 8 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/m4/issm_options.m4
r21525 r21615 770 770 ADOLCLIB="-L$ADOLC_ROOT/lib -ladolc" 771 771 AC_DEFINE([_HAVE_ADOLC_],[1],[with adolc in ISSM src]) 772 AC_DEFINE([_HAVE_AD_],[1],[with AD in ISSM src]) 772 773 AC_SUBST([ADOLCINCL]) 773 774 AC_SUBST([ADOLCLIB]) -
issm/trunk-jpl/src/c/classes/IoModel.cpp
r21542 r21615 1719 1719 if(M*N){ 1720 1720 buffer=xNew<IssmPDouble>(M*N); 1721 // AD performance is sensitive to calls to ensurecontiguous. 1722 // Providing "t" will cause ensurecontiguous to be called. 1723 #ifdef _HAVE_AD_ 1724 matrix=xNew<IssmDouble>(M*N,"t"); 1725 #else 1721 1726 matrix=xNew<IssmDouble>(M*N); 1727 #endif 1722 1728 1723 1729 /*Read matrix on node 0, then broadcast: */ -
issm/trunk-jpl/src/c/shared/MemOps/MemOps.cpp
r18125 r21615 15 15 16 16 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 17 template <> adouble* xNew(unsigned int size) { 18 ensureContiguousLocations(size); 17 template <> adouble* xNew(unsigned int size, const char* const contig) { 18 if (*contig == 't') 19 ensureContiguousLocations(size); 20 19 21 adouble* aT_p=new adouble[size]; 20 22 assert(aT_p); -
issm/trunk-jpl/src/c/shared/MemOps/MemOps.h
r18125 r21615 16 16 #endif 17 17 18 static char const DEFCONTIG = 'f'; 19 20 // AD (mostly ADOLC) is sensitive to calls to ensurecontiguous. These changes limit its use. 21 #ifdef _HAVE_AD_ 22 template <class T> T* xNew(unsigned int size, const char* const contig = &DEFCONTIG) { /*{{{*/ 23 #else 18 24 template <class T> T* xNew(unsigned int size) { /*{{{*/ 25 #endif 19 26 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES 20 27 T* aT_p=new T[size]; … … 49 56 #endif 50 57 }/*}}}*/ 58 // AD (mostly ADOLC) is sensitive to calls to ensurecontiguous. These changes limit its use. 59 #ifdef _HAVE_AD_ 60 template <class T> T* xNewZeroInit(unsigned int size,const char* const contig = &DEFCONTIG) {/*{{{*/ 61 #else 51 62 template <class T> T* xNewZeroInit(unsigned int size) {/*{{{*/ 63 #endif 52 64 #ifdef USE_CXX_MEMORY_MANAGMENT_FOR_NON_POD_TYPES 65 #ifdef _HAVE_AD_ 66 T* aT_p=xNew<T>(size,contig); 67 #else 53 68 T* aT_p=xNew<T>(size); 69 #endif 54 70 for (unsigned int i=0; i<size;++i) 55 71 aT_p[i]=(T)0; … … 144 160 #if defined(_HAVE_ADOLC_) && !defined(_WRAPPERS_) 145 161 #include "../Numerics/types.h" 146 template <> adouble* xNew(unsigned int size );162 template <> adouble* xNew(unsigned int size, const char* const contig); 147 163 #endif 148 164 -
issm/trunk-jpl/src/c/toolkits/gsl/DenseGslSolve.cpp
r19490 r21615 216 216 if(Kff_M!=Kff_N)_error_("Stiffness matrix should be square!"); 217 217 218 ensureContiguousLocations(Kff_N); 218 // AD performance is sensitive to calls to ensurecontiguous. 219 // Providing "t" will cause ensurecontiguous to be called. 220 #ifdef _HAVE_AD_ 221 IssmDouble *x = xNew<IssmDouble>(Kff_N,"t"); 222 #else 219 223 IssmDouble *x = xNew<IssmDouble>(Kff_N); 224 #endif 220 225 221 226 SolverxSeq(x,Kff,pf,Kff_N,parameters); … … 227 232 void SolverxSeq(IssmDouble *X,IssmDouble *A,IssmDouble *B,int n, Parameters* parameters){/*{{{*/ 228 233 // pack inputs to conform to the EDF-prescribed interface 229 // ensure a contiguous block of locations: 230 ensureContiguousLocations(n*(n+1)); 231 IssmDouble* adoubleEDFin=xNew<IssmDouble>(n*(n+1)); // packed inputs, i.e. matrix and right hand side 234 // AD performance is sensitive to calls to ensurecontiguous. 235 // Providing "t" will cause ensurecontiguous to be called. 236 #ifdef _HAVE_AD_ 237 IssmDouble* adoubleEDFin=xNew<IssmDouble>(n*(n+1),"t"); 238 #else 239 IssmDouble* adoubleEDFin=xNew<IssmDouble>(n*(n+1)); 240 #endif 241 // packed inputs, i.e. matrix and right hand side 232 242 for(int i=0; i<n*n;i++)adoubleEDFin[i] =A[i]; // pack matrix 233 243 for(int i=0; i<n; i++)adoubleEDFin[i+n*n]=B[i]; // pack the right hand side -
issm/trunk-jpl/src/c/toolkits/issm/IssmMpiSparseMat.h
r18063 r21615 232 232 row_indices_fromcpu[i]=xNew<int>(size); 233 233 col_indices_fromcpu[i]=xNew<int>(size); 234 // AD performance is sensitive to calls to ensurecontiguous. 235 // Providing "t" will cause ensurecontiguous to be called. 236 #ifdef _HAVE_AD_ 237 values_fromcpu[i]=xNew<doubletype>(size,"t"); 238 #else 234 239 values_fromcpu[i]=xNew<doubletype>(size); 240 #endif 241 235 242 modes_fromcpu[i]=xNew<int>(size); 236 243 } … … 492 499 row_indices_forcpu = xNew<int>(total_size); 493 500 col_indices_forcpu = xNew<int>(total_size); 501 // AD performance is sensitive to calls to ensurecontiguous. 502 // Providing "t" will cause ensurecontiguous to be called. 503 #ifdef _HAVE_AD_ 504 values_forcpu = xNew<doubletype>(total_size,"t"); 505 #else 494 506 values_forcpu = xNew<doubletype>(total_size); 507 #endif 508 495 509 modes_forcpu = xNew<int>(total_size); 496 510 -
issm/trunk-jpl/src/c/toolkits/issm/IssmMpiVec.h
r20040 r21615 67 67 68 68 if(this->M){ 69 // AD performance is sensitive to calls to ensurecontiguous. 70 // Providing "t" will cause ensurecontiguous to be called. 71 #ifdef _HAVE_AD_ 72 this->vector=xNew<doubletype>(this->m,"t"); 73 #else 69 74 this->vector=xNew<doubletype>(this->m); 75 #endif 76 70 77 xMemCpy<doubletype>(this->vector,buffer,this->m); 71 78 } … … 80 87 81 88 if(this->m){ 89 // AD performance is sensitive to calls to ensurecontiguous. 90 // Providing "t" will cause ensurecontiguous to be called. 91 #ifdef _HAVE_AD_ 92 this->vector=xNew<doubletype>(this->m,"t"); 93 #else 82 94 this->vector=xNew<doubletype>(this->m); 95 #endif 96 83 97 xMemCpy<doubletype>(this->vector,buffer,this->m); 84 98 } … … 102 116 103 117 /*Allocate: */ 118 // AD performance is sensitive to calls to ensurecontiguous. 119 // Providing "t" will cause ensurecontiguous to be called. 120 #ifdef _HAVE_AD_ 121 if (m)this->vector=xNewZeroInit<doubletype>(this->m,"t"); 122 #else 104 123 if (m)this->vector=xNewZeroInit<doubletype>(this->m); 124 #endif 125 105 126 } 106 127 /*}}}*/ … … 196 217 if(size){ 197 218 row_indices_fromcpu[i]=xNew<int>(size); 219 // AD performance is sensitive to calls to ensurecontiguous. 220 // Providing "t" will cause ensurecontiguous to be called. 221 #ifdef _HAVE_AD_ 222 values_fromcpu[i]=xNew<doubletype>(size,"t"); 223 #else 198 224 values_fromcpu[i]=xNew<doubletype>(size); 225 #endif 226 199 227 modes_fromcpu[i]=xNew<int>(size); 200 228 } … … 375 403 376 404 /*Allocate: */ 405 // AD performance is sensitive to calls to ensurecontiguous. 406 // Providing "t" will cause ensurecontiguous to be called. 407 #ifdef _HAVE_AD_ 408 buffer=xNew<doubletype>(M,"t"); 409 #else 377 410 buffer=xNew<doubletype>(M); 411 #endif 412 378 413 recvcounts=xNew<int>(num_procs); 379 414 displs=xNew<int>(num_procs); … … 527 562 /*Allocate buffers: */ 528 563 row_indices_forcpu = xNew<int>(total_size); 564 // AD performance is sensitive to calls to ensurecontiguous. 565 // Providing "t" will cause ensurecontiguous to be called. 566 #ifdef _HAVE_AD_ 567 values_forcpu = xNew<doubletype>(total_size,"t"); 568 #else 529 569 values_forcpu = xNew<doubletype>(total_size); 570 #endif 571 530 572 modes_forcpu = xNew<int>(total_size); 531 573 -
issm/trunk-jpl/src/c/toolkits/mumps/MumpsSolve.cpp
r19491 r21615 167 167 } 168 168 /*Deal with right hand side. We need to ISSM_MPI_Gather it onto cpu 0: */ 169 // AD performance is sensitive to calls to ensurecontiguous. 170 // Providing "t" will cause ensurecontiguous to be called. 171 #ifdef _HAVE_AD_ 172 rhs=xNew<IssmDouble>(pf_M,"t"); 173 #else 169 174 rhs=xNew<IssmDouble>(pf_M); 175 #endif 176 170 177 171 178 recvcounts=xNew<int>(num_procs); … … 246 253 } 247 254 /*Deal with right hand side. We need to ISSM_MPI_Gather it onto cpu 0: */ 255 // AD performance is sensitive to calls to ensurecontiguous. 256 // Providing "t" will cause ensurecontiguous to be called. 257 #ifdef _HAVE_AD_ 258 rhs=xNew<IssmDouble>(pf_M,"t"); 259 #else 248 260 rhs=xNew<IssmDouble>(pf_M); 261 #endif 262 249 263 250 264 recvcounts=xNew<int>(num_procs); … … 314 328 packedDimsSparseArr[3+local_nnz+i]=jcn_loc[i]; 315 329 } 330 // AD performance is sensitive to calls to ensurecontiguous. 331 // Providing "t" will cause ensurecontiguous to be called. 332 #ifdef _HAVE_AD_ 333 IssmDouble *pack_A_rhs=xNew<IssmDouble>(local_nnz+n,"t"); 334 #else 316 335 IssmDouble *pack_A_rhs=xNew<IssmDouble>(local_nnz+n); 336 #endif 337 317 338 for (int i=0;i<local_nnz;++i) { 318 339 pack_A_rhs[i]=a_loc[i]; … … 321 342 pack_A_rhs[local_nnz+i]=rhs[i]; 322 343 } 344 // AD performance is sensitive to calls to ensurecontiguous. 345 // Providing "t" will cause ensurecontiguous to be called. 346 #ifdef _HAVE_AD_ 347 IssmDouble *sol=xNew<IssmDouble>(n,"t"); 348 #else 323 349 IssmDouble *sol=xNew<IssmDouble>(n); 350 #endif 351 324 352 call_ext_fct(xDynamicCast<GenericParam<Adolc_edf> * >(parameters->FindParamObject(AdolcParamEnum))->GetParameterValue().myEDF_for_solverx_p, 325 353 packedDimsSparseArrLength, packedDimsSparseArr,
Note:
See TracChangeset
for help on using the changeset viewer.