Changeset 15837
- Timestamp:
- 08/19/13 14:13:48 (12 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
issm/trunk-jpl/src/c/toolkits/mpi/issmmpi.cpp
r15836 r15837 13 13 #include <cstring> // for memcpy 14 14 15 #include "issmmpi.h" 16 17 // for now - needs to be replaced by issm's type header file >>>>---- from here 18 #ifdef _HAVE_ADOLC_ 19 # include "adolc/adolc.h" 20 typedef adouble IssmDouble; 21 #else 22 typedef double IssmDouble; 23 #endif 24 // ------<<<< until here 15 #include "./issmmpi.h" 16 #include "../../shared/Numerics/types.h" 25 17 26 18 #ifndef _HAVE_MPI_ 27 ISSM MPI_Status ourIssmMPIStatusIgnore=0;28 size_t sizeHelper(ISSM MPI_Datatype type) { /*{{{*/19 ISSM_MPI_Status ourIssmMPIStatusIgnore=0; 20 size_t sizeHelper(ISSM_MPI_Datatype type) { /*{{{*/ 29 21 30 22 switch(type) { 31 case ISSM MPI_CHAR:23 case ISSM_MPI_CHAR: 32 24 return sizeof(char); 33 25 break; 34 case ISSM MPI_DOUBLE:26 case ISSM_MPI_DOUBLE: 35 27 return sizeof(double); 36 28 break; 37 case ISSM MPI_INT:29 case ISSM_MPI_INT: 38 30 return sizeof(int); 39 31 break; … … 46 38 #endif 47 39 48 int ISSM MPI_Allgather(void *sendbuf, int sendcount, ISSMMPI_Datatype sendtype, void *recvbuf, int recvcount, ISSMMPI_Datatype recvtype, ISSMMPI_Comm comm) { /*{{{*/40 int ISSM_MPI_Allgather(void *sendbuf, int sendcount, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcount, ISSM_MPI_Datatype recvtype, ISSM_MPI_Comm comm) { /*{{{*/ 49 41 int rc=0; 50 42 assert(sendcount==recvcount || sendtype==recvtype); // we handle only identical representations … … 69 61 #else 70 62 # ifdef _HAVE_ADOLC_ 71 if (sendtype==ISSM MPI_DOUBLE) {63 if (sendtype==ISSM_MPI_DOUBLE) { 72 64 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 73 65 IssmDouble* activeRecvBuf=(IssmDouble*)recvbuf; … … 80 72 return rc; 81 73 } /*}}}*/ 82 int ISSM MPI_Allgatherv(void *sendbuf, int sendcount, ISSMMPI_Datatype sendtype, void *recvbuf, int *recvcounts, int *displs, ISSMMPI_Datatype recvtype, ISSMMPI_Comm comm) { /*{{{*/74 int ISSM_MPI_Allgatherv(void *sendbuf, int sendcount, ISSM_MPI_Datatype sendtype, void *recvbuf, int *recvcounts, int *displs, ISSM_MPI_Datatype recvtype, ISSM_MPI_Comm comm) { /*{{{*/ 83 75 int rc=0; 84 76 assert(sendtype==recvtype); // we handle only identical representations … … 106 98 assert(sendcount==recvcounts[0]); // we handle only identical representations 107 99 # ifdef _HAVE_ADOLC_ 108 if (sendtype==ISSM MPI_DOUBLE) {100 if (sendtype==ISSM_MPI_DOUBLE) { 109 101 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 110 102 IssmDouble* activeRecvBuf=(IssmDouble*)(recvbuf)+displs[0]; … … 117 109 return rc; 118 110 }/*}}}*/ 119 int ISSM MPI_Allreduce(void *sendbuf, void *recvbuf, int count, ISSMMPI_Datatype datatype, ISSMMPI_Op op, ISSMMPI_Comm comm){/*{{{*/111 int ISSM_MPI_Allreduce(void *sendbuf, void *recvbuf, int count, ISSM_MPI_Datatype datatype, ISSM_MPI_Op op, ISSM_MPI_Comm comm){/*{{{*/ 120 112 121 113 int rc=0; … … 138 130 #else 139 131 # ifdef _HAVE_ADOLC_ 140 if (datatype==ISSM MPI_DOUBLE) {132 if (datatype==ISSM_MPI_DOUBLE) { 141 133 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 142 134 IssmDouble* activeRecvBuf=(IssmDouble*)recvbuf; … … 149 141 return rc; 150 142 }/*}}}*/ 151 int ISSM MPI_Barrier(ISSMMPI_Comm comm){ /*{{{*/143 int ISSM_MPI_Barrier(ISSM_MPI_Comm comm){ /*{{{*/ 152 144 153 145 int rc=0; … … 163 155 return rc; 164 156 }/*}}}*/ 165 int ISSM MPI_Bcast(void *buffer, int count, ISSMMPI_Datatype datatype, int root, ISSMMPI_Comm comm){ /*{{{*/157 int ISSM_MPI_Bcast(void *buffer, int count, ISSM_MPI_Datatype datatype, int root, ISSM_MPI_Comm comm){ /*{{{*/ 166 158 167 159 int rc=0; … … 185 177 return rc; 186 178 }/*}}}*/ 187 int ISSM MPI_Comm_free(ISSMMPI_Comm *comm){ /*{{{*/179 int ISSM_MPI_Comm_free(ISSM_MPI_Comm *comm){ /*{{{*/ 188 180 189 181 int rc=0; … … 199 191 return rc; 200 192 }/*}}}*/ 201 int ISSM MPI_Comm_rank(ISSMMPI_Comm comm, int *rank){ /*{{{*/193 int ISSM_MPI_Comm_rank(ISSM_MPI_Comm comm, int *rank){ /*{{{*/ 202 194 203 195 int rc=0; … … 210 202 return rc; 211 203 }/*}}}*/ 212 int ISSM MPI_Comm_size( ISSMMPI_Comm comm, int *size){ /*{{{*/204 int ISSM_MPI_Comm_size( ISSM_MPI_Comm comm, int *size){ /*{{{*/ 213 205 214 206 int rc=0; … … 221 213 return rc; 222 214 }/*}}}*/ 223 int ISSM MPI_Finalize(void){ /*{{{*/215 int ISSM_MPI_Finalize(void){ /*{{{*/ 224 216 225 217 int rc=0; … … 233 225 return rc; 234 226 }/*}}}*/ 235 int ISSM MPI_Gather(void *sendbuf, int sendcnt, ISSMMPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSMMPI_Datatype recvtype, int root, ISSMMPI_Comm comm){ /*{{{*/227 int ISSM_MPI_Gather(void *sendbuf, int sendcnt, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm){ /*{{{*/ 236 228 237 229 int rc=0; … … 259 251 #else 260 252 # ifdef _HAVE_ADOLC_ 261 if (sendtype==ISSM MPI_DOUBLE) {253 if (sendtype==ISSM_MPI_DOUBLE) { 262 254 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 263 255 IssmDouble* activeRecvBuf=(IssmDouble*)recvbuf; … … 270 262 return rc; 271 263 }/*}}}*/ 272 int ISSM MPI_Gatherv(void *sendbuf, int sendcnt, ISSMMPI_Datatype sendtype, void *recvbuf, int *recvcnts, int *displs, ISSMMPI_Datatype recvtype, int root, ISSMMPI_Comm comm){/*{{{*/264 int ISSM_MPI_Gatherv(void *sendbuf, int sendcnt, ISSM_MPI_Datatype sendtype, void *recvbuf, int *recvcnts, int *displs, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm){/*{{{*/ 273 265 274 266 int rc=0; … … 299 291 assert(sendcnt==recvcnts[0]); // we handle only identical representations 300 292 # ifdef _HAVE_ADOLC_ 301 if (sendtype==ISSM MPI_DOUBLE) {293 if (sendtype==ISSM_MPI_DOUBLE) { 302 294 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 303 295 IssmDouble* activeRecvBuf=(IssmDouble*)(recvbuf)+displs[0]; … … 310 302 return rc; 311 303 }/*}}}*/ 312 int ISSM MPI_Init(int *argc, char ***argv){ /*{{{*/304 int ISSM_MPI_Init(int *argc, char ***argv){ /*{{{*/ 313 305 314 306 int rc=0; … … 322 314 return rc; 323 315 }/*}}}*/ 324 int ISSM MPI_Recv(void *buf, int count, ISSMMPI_Datatype datatype, int source, int tag, ISSMMPI_Comm comm, ISSMMPI_Status *status){ /*{{{*/316 int ISSM_MPI_Recv(void *buf, int count, ISSM_MPI_Datatype datatype, int source, int tag, ISSM_MPI_Comm comm, ISSM_MPI_Status *status){ /*{{{*/ 325 317 326 318 int rc=0; … … 351 343 return rc; 352 344 }/*}}}*/ 353 int ISSM MPI_Reduce(void *sendbuf, void *recvbuf, int count, ISSMMPI_Datatype datatype, ISSMMPI_Op op, int root, ISSMMPI_Comm comm){ /*{{{*/345 int ISSM_MPI_Reduce(void *sendbuf, void *recvbuf, int count, ISSM_MPI_Datatype datatype, ISSM_MPI_Op op, int root, ISSM_MPI_Comm comm){ /*{{{*/ 354 346 355 347 int rc=0; … … 374 366 #else 375 367 # ifdef _HAVE_ADOLC_ 376 if (datatype==ISSM MPI_DOUBLE) {368 if (datatype==ISSM_MPI_DOUBLE) { 377 369 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 378 370 IssmDouble* activeRecvBuf=(IssmDouble*)recvbuf; … … 385 377 return rc; 386 378 }/*}}}*/ 387 int ISSM MPI_Scatter(void *sendbuf, int sendcnt, ISSMMPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSMMPI_Datatype recvtype, int root, ISSMMPI_Comm comm){ /*{{{*/379 int ISSM_MPI_Scatter(void *sendbuf, int sendcnt, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm){ /*{{{*/ 388 380 389 381 int rc=0; … … 411 403 #else 412 404 # ifdef _HAVE_ADOLC_ 413 if (sendtype==ISSM MPI_DOUBLE) {405 if (sendtype==ISSM_MPI_DOUBLE) { 414 406 IssmDouble* activeSendBuf=(IssmDouble*)sendbuf; 415 407 IssmDouble* activeRecvBuf=(IssmDouble*)recvbuf; … … 422 414 return rc; 423 415 }/*}}}*/ 424 int ISSM MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, ISSMMPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSMMPI_Datatype recvtype, int root, ISSMMPI_Comm comm){ /*{{{*/416 int ISSM_MPI_Scatterv(void *sendbuf, int *sendcnts, int *displs, ISSM_MPI_Datatype sendtype, void *recvbuf, int recvcnt, ISSM_MPI_Datatype recvtype, int root, ISSM_MPI_Comm comm){ /*{{{*/ 425 417 426 418 int rc=0; … … 451 443 assert(sendcnts[0]==recvcnt); // we handle only identical representations 452 444 # ifdef _HAVE_ADOLC_ 453 if (sendtype==ISSM MPI_DOUBLE) {445 if (sendtype==ISSM_MPI_DOUBLE) { 454 446 IssmDouble* activeSendBuf=(IssmDouble*)(sendbuf)+displs[0]; 455 447 IssmDouble* activeRecvBuf=(IssmDouble*)recvbuf; … … 462 454 return rc; 463 455 }/*}}}*/ 464 int ISSM MPI_Send(void *buf, int count, ISSMMPI_Datatype datatype, int dest, int tag, ISSMMPI_Comm comm){ /*{{{*/456 int ISSM_MPI_Send(void *buf, int count, ISSM_MPI_Datatype datatype, int dest, int tag, ISSM_MPI_Comm comm){ /*{{{*/ 465 457 466 458 int rc=0; … … 487 479 return rc; 488 480 }/*}}}*/ 489 double ISSM MPI_Wtime(void){/*{{{*/481 double ISSM_MPI_Wtime(void){/*{{{*/ 490 482 491 483 assert(0); // to be implemented 492 484 return 0.0; 493 485 }/*}}}*/ 494 void ISSM MPI_ContiguousInAdolc(size_t aSize) { /*{{{*/486 void ISSM_MPI_ContiguousInAdolc(size_t aSize) { /*{{{*/ 495 487 496 488 #ifdef _HAVE_ADOLC_ … … 498 490 #endif 499 491 }/*}}}*/ 500
Note:
See TracChangeset
for help on using the changeset viewer.