File indexing completed on 2024-12-17 18:39:42 UTC
view on githubraw file Latest commit b4daa243 on 2023-05-28 03:53:22 UTC
b4daa24319 Shre*0001 /*
0002 ##########################################################
0003 # This file is part of the AdjoinableMPI library #
0004 # released under the MIT License. #
0005 # The full COPYRIGHT notice can be found in the top #
0006 # level directory of the AdjoinableMPI distribution. #
0007 ##########################################################
0008
0009 #ifndef _AMPI_MODIFIED_H_
0010 #define _AMPI_MODIFIED_H_
0011
0012 /**
0013 * \file
0014 * \ingroup UserInterfaceHeaders
0015 * AMPI routines that have adjoint functionality and do no merely pass through to the MPI originals; the routines may signatures with additional parameters compared to their original MPI counterparts
0016 */
0017
0018 #include "ampi/userIF/pairedWith.h"
0019 #include "ampi/userIF/request.h"
0020 #include "ampi/userIF/window.h"
0021
0022 /**
0023 * \todo move out of userIF
0024 * user-defined type data
0025 * only one instance of derivedTypeData exists at once
0026 * get pointer from getDTypeData, add new stuff with addDTypeData
0027 */
0028 typedef struct {
0029 int size;
0030 int preAlloc;
0031 int* num_actives;
0032 /* displacements of first/last active blocks */
0033 MPI_Aint* first_active_blocks;
0034 MPI_Aint* last_active_blocks;
0035 /* need to know last active block length to find last active element */
0036 int* last_active_block_lengths;
0037 MPI_Datatype* derived_types;
0038 int* counts;
0039 int** arrays_of_blocklengths;
0040 MPI_Aint** arrays_of_displacements;
0041 MPI_Datatype** arrays_of_types;
0042 MPI_Aint* lbs;
0043 MPI_Aint* extents;
0044 /* corresponding typemaps packed for sending */
0045 MPI_Datatype* packed_types;
0046 int** arrays_of_p_blocklengths;
0047 MPI_Aint** arrays_of_p_displacements;
0048 MPI_Datatype** arrays_of_p_types;
0049 MPI_Aint* p_extents;
0050 } derivedTypeData;
0051
0052 /**
0053 * \todo move out of userIF
0054 *
0055 */
0056 derivedTypeData* getDTypeData();
0057
0058 /**
0059 * \todo move out of userIF
0060 *
0061 */
0062 void releaseDTypeData();
0063 /**
0064 * \todo move out of userIF
0065 *
0066 * @param dat
0067 * @param count
0068 * @param array_of_blocklengths
0069 * @param array_of_displacements
0070 * @param array_of_types
0071 * @param lower_bound
0072 * @param extent
0073 * @param array_of_p_blocklengths
0074 * @param array_of_p_displacements
0075 * @param array_of_p_types
0076 * @param p_extent
0077 * @param newtype
0078 * @param packed_type
0079 * addDTypeData takes derived type data and adds a new entry; returns
0080 * position of new type in data struct; returns -1 if struct contains no active types;
0081 * doubles data struct size every time there's overflow
0082 */
0083 void addDTypeData(derivedTypeData* dat,
0084 int count,
0085 int array_of_blocklengths[],
0086 MPI_Aint array_of_displacements[],
0087 MPI_Datatype array_of_types[],
0088 MPI_Aint lower_bound,
0089 MPI_Aint extent,
0090 int array_of_p_blocklengths[],
0091 MPI_Aint array_of_p_displacements[],
0092 MPI_Datatype array_of_p_types[],
0093 MPI_Aint p_extent,
0094 MPI_Datatype* newtype,
0095 MPI_Datatype* packed_type);
0096 int derivedTypeIdx(MPI_Datatype datatype);
0097 /**
0098 * \todo move out of userIF
0099 * @param dt_idx
0100 * @return
0101 */
0102 int isDerivedType(int dt_idx);
0103
0104 /**
0105 * \todo move out of userIF
0106 * user-defined reduction op data
0107 * only one instance of userDefinedOpData exists at once
0108 * get pointer from getUOpData, add new stuff with addUOpData
0109 */
0110 typedef struct {
0111 int size;
0112 int preAlloc;
0113 MPI_Op* ops;
0114 MPI_User_function** functions;
0115 int* commutes;
0116 } userDefinedOpData;
0117
0118 /**
0119 * \todo move out of userIF
0120 * @return
0121 */
0122 userDefinedOpData* getUOpData();
0123
0124 /**
0125 * \todo move out of userIF
0126 * @param dat
0127 * @param op a user-defined operation
0128 * @param function
0129 * @param commute
0130 * takes user-defined op and adds a new entry;
0131 * doubles data struct size every
0132 * time there's overflow
0133 */
0134 void addUOpData(userDefinedOpData* dat,
0135 MPI_Op* op,
0136 MPI_User_function* function,
0137 int commute);
0138 /**
0139 * \todo move out of userIF
0140 * @param op
0141 * @return
0142 */
0143 int userDefinedOpIdx(MPI_Op op);
0144 /**
0145 * \todo move out of userIF
0146 * @param uop_idx
0147 * @return
0148 */
0149 int isUserDefinedOp(int uop_idx);
0150 /**
0151 * \todo move out of userIF
0152 */
0153 void releaseUOpData();
0154
0155 /** \ingroup UserInterfaceDeclarations
0156 * @{
0157 */
0158
0159 /**
0160 * active variant of the predefined MPI_DOUBLE
0161 */
0162 extern MPI_Datatype AMPI_ADOUBLE;
0163
0164 /**
0165 * active variant of the predefined MPI_FLOAT
0166 */
0167 extern MPI_Datatype AMPI_AFLOAT;
0168
0169 #ifdef AMPI_FORTRANCOMPATIBLE
0170
0171 /**
0172 * active variant of the predefined MPI_DOUBLE_PRECISION
0173 */
0174 extern MPI_Datatype AMPI_ADOUBLE_PRECISION;
0175
0176 /**
0177 * active variant of the predefined MPI_REAL
0178 */
0179 extern MPI_Datatype AMPI_AREAL;
0180
0181 #endif
0182
0183 /**
0184 * adjoint needs to MPI_Finalize; signature identical to original MPI call
0185 */
0186 int AMPI_Init(int* argc,
0187 char*** argv);
0188
0189 /**
0190 * adjoint needs to MPI_Init; signature identical to AMPI_Init (adjoint symmetry)
0191 */
0192 int AMPI_Finalize(int* argc,
0193 char*** argv);
0194
0195 /**
0196 * adjoint needs to detach; signature identical to original MPI call
0197 */
0198 int AMPI_Buffer_attach(void *buffer,
0199 int size);
0200
0201 /**
0202 * adjoint needs to attach; signature identical to original MPI call
0203 */
0204 int AMPI_Buffer_detach(void *buffer,
0205 int *size);
0206
0207 /**
0208 * all parameters as in the MPI standard with exceptions as listed
0209 * @param buf
0210 * @param count
0211 * @param datatype see \ref datatypes
0212 * @param dest
0213 * @param tag
0214 * @param pairedWith see \ref pairings
0215 * @param comm
0216 * @return
0217 */
0218 int AMPI_Send(void* buf,
0219 int count,
0220 MPI_Datatype datatype,
0221 int dest,
0222 int tag,
0223 AMPI_PairedWith pairedWith,
0224 MPI_Comm comm);
0225
0226 /**
0227 * all parameters as in the MPI standard with exceptions as listed
0228 * @param buf
0229 * @param count
0230 * @param datatype see \ref datatypes
0231 * @param src
0232 * @param tag
0233 * @param pairedWith see \ref pairings
0234 * @param comm
0235 * @param status
0236 * @return
0237 */
0238 int AMPI_Recv(void* buf,
0239 int count,
0240 MPI_Datatype datatype,
0241 int src,
0242 int tag,
0243 AMPI_PairedWith pairedWith,
0244 MPI_Comm comm,
0245 MPI_Status* status);
0246
0247 /**
0248 * all parameters as in the MPI standard with exceptions as listed
0249 * @param buf
0250 * @param count
0251 * @param datatype see \ref datatypes
0252 * @param dest
0253 * @param tag
0254 * @param pairedWith see \ref pairings
0255 * @param comm
0256 * @param request see \ref requests
0257 * @return
0258 */
0259 int AMPI_Isend (void* buf,
0260 int count,
0261 MPI_Datatype datatype,
0262 int dest,
0263 int tag,
0264 AMPI_PairedWith pairedWith,
0265 MPI_Comm comm,
0266 AMPI_Request* request);
0267
0268 /**
0269 * all parameters as in the MPI standard with exceptions as listed
0270 * @param buf
0271 * @param count
0272 * @param datatype see \ref datatypes
0273 * @param src
0274 * @param tag
0275 * @param pairedWith see \ref pairings
0276 * @param comm
0277 * @param request see \ref requests
0278 * @return
0279 */
0280 int AMPI_Irecv (void* buf,
0281 int count,
0282 MPI_Datatype datatype,
0283 int src,
0284 int tag,
0285 AMPI_PairedWith pairedWith,
0286 MPI_Comm comm,
0287 AMPI_Request* request);
0288
0289 /**
0290 * all parameters as in the MPI standard with exceptions as listed
0291 * @param buf
0292 * @param count
0293 * @param datatype see \ref datatypes
0294 * @param dest
0295 * @param tag
0296 * @param pairedWith see \ref pairings
0297 * @param comm
0298 * @return
0299 */
0300 int AMPI_Bsend(void *buf,
0301 int count,
0302 MPI_Datatype datatype,
0303 int dest,
0304 int tag,
0305 AMPI_PairedWith pairedWith,
0306 MPI_Comm comm);
0307
0308 /**
0309 * all parameters as in the MPI standard with exceptions as listed
0310 * @param buf
0311 * @param count
0312 * @param datatype see \ref datatypes
0313 * @param dest
0314 * @param tag
0315 * @param pairedWith see \ref pairings
0316 * @param comm
0317 * @return
0318 */
0319 int AMPI_Rsend(void *buf,
0320 int count,
0321 MPI_Datatype datatype,
0322 int dest,
0323 int tag,
0324 AMPI_PairedWith pairedWith,
0325 MPI_Comm comm);
0326
0327 /**
0328 * all parameters as in the MPI standard with exceptions as listed
0329 * @param buf
0330 * @param count
0331 * @param datatype see \ref datatypes
0332 * @param root
0333 * @param comm
0334 * @return
0335 */
0336 int AMPI_Bcast (void* buf,
0337 int count,
0338 MPI_Datatype datatype,
0339 int root,
0340 MPI_Comm comm);
0341
0342 /**
0343 * all parameters as in the MPI standard with exceptions as listed
0344 * @param sbuf
0345 * @param rbuf
0346 * @param count
0347 * @param datatype see \ref datatypes
0348 * @param op
0349 * @param root
0350 * @param comm
0351 * @return
0352 */
0353 int AMPI_Reduce (void* sbuf,
0354 void* rbuf,
0355 int count,
0356 MPI_Datatype datatype,
0357 MPI_Op op,
0358 int root,
0359 MPI_Comm comm);
0360
0361 /**
0362 * all parameters as in the MPI standard with exceptions as listed
0363 * @param sbuf
0364 * @param rbuf
0365 * @param count
0366 * @param datatype see \ref datatypes
0367 * @param op
0368 * @param comm
0369 * @return
0370 */
0371 int AMPI_Allreduce (void* sbuf,
0372 void* rbuf,
0373 int count,
0374 MPI_Datatype datatype,
0375 MPI_Op op,
0376 MPI_Comm comm);
0377
0378
0379 /**
0380 * before we start reverse we need to make sure there are no pending requests in our userIF bookkeeping
0381 */
0382 int AMPI_Wait(AMPI_Request *request,
0383 MPI_Status *status);
0384
0385 /**
0386 * all parameters as in the MPI standard with exceptions as listed
0387 * @param count
0388 * @param requests see \ref requests
0389 * @param statuses
0390 * @return
0391 */
0392 int AMPI_Waitall (int count,
0393 AMPI_Request requests[],
0394 MPI_Status statuses[]);
0395
0396 /**
0397 * @param count
0398 * @param requests see \ref requests
0399 * @param statuses
0400 * @return
0401 */
0402 int AMPI_Awaitall (int count,
0403 AMPI_Request requests[],
0404 MPI_Status statuses[]);
0405
0406 /**
0407 * all parameters as in the MPI standard with exceptions as listed
0408 * @param comm
0409 * @return
0410 */
0411 int AMPI_Barrier(MPI_Comm comm);
0412
0413 /**
0414 * all parameters as in the MPI standard with exceptions as listed
0415 * @param sendbuf
0416 * @param sendcnt
0417 * @param sendtype see \ref datatypes
0418 * @param recvbuf
0419 * @param recvcnt
0420 * @param recvtype see \ref datatypes
0421 * @param root
0422 * @param comm
0423 * @return
0424 */
0425 int AMPI_Gather(void *sendbuf,
0426 int sendcnt,
0427 MPI_Datatype sendtype,
0428 void *recvbuf,
0429 int recvcnt,
0430 MPI_Datatype recvtype,
0431 int root,
0432 MPI_Comm comm);
0433
0434 /**
0435 * all parameters as in the MPI standard with exceptions as listed
0436 * @param sendbuf
0437 * @param sendcnt
0438 * @param sendtype see \ref datatypes
0439 * @param recvbuf
0440 * @param recvcnt
0441 * @param recvtype see \ref datatypes
0442 * @param root
0443 * @param comm
0444 * @return
0445 */
0446 int AMPI_Scatter(void *sendbuf,
0447 int sendcnt,
0448 MPI_Datatype sendtype,
0449 void *recvbuf,
0450 int recvcnt,
0451 MPI_Datatype recvtype,
0452 int root,
0453 MPI_Comm comm);
0454
0455 /**
0456 * all parameters as in the MPI standard with exceptions as listed
0457 * @param sendbuf
0458 * @param sendcount
0459 * @param sendtype see \ref datatypes
0460 * @param recvbuf
0461 * @param recvcount
0462 * @param recvtype see \ref datatypes
0463 * @param comm
0464 * @return
0465 */
0466 int AMPI_Allgather(void *sendbuf,
0467 int sendcount,
0468 MPI_Datatype sendtype,
0469 void *recvbuf,
0470 int recvcount,
0471 MPI_Datatype recvtype,
0472 MPI_Comm comm);
0473
0474 /**
0475 * all parameters as in the MPI standard with exceptions as listed
0476 * @param sendbuf
0477 * @param sendcnt
0478 * @param sendtype see \ref datatypes
0479 * @param recvbuf
0480 * @param recvcnts
0481 * @param displs
0482 * @param recvtype see \ref datatypes
0483 * @param root
0484 * @param comm
0485 * @return
0486 */
0487 int AMPI_Gatherv(void *sendbuf,
0488 int sendcnt,
0489 MPI_Datatype sendtype,
0490 void *recvbuf,
0491 int *recvcnts,
0492 int *displs,
0493 MPI_Datatype recvtype,
0494 int root,
0495 MPI_Comm comm);
0496
0497 /**
0498 * all parameters as in the MPI standard with exceptions as listed
0499 * @param sendbuf
0500 * @param sendcnts
0501 * @param displs
0502 * @param sendtype see \ref datatypes
0503 * @param recvbuf
0504 * @param recvcnt
0505 * @param recvtype see \ref datatypes
0506 * @param root
0507 * @param comm
0508 * @return
0509 */
0510 int AMPI_Scatterv(void *sendbuf,
0511 int *sendcnts,
0512 int *displs,
0513 MPI_Datatype sendtype,
0514 void *recvbuf,
0515 int recvcnt,
0516 MPI_Datatype recvtype,
0517 int root, MPI_Comm comm);
0518
0519 /**
0520 * all parameters as in the MPI standard with exceptions as listed
0521 * @param sendbuf
0522 * @param sendcnt
0523 * @param sendtype see \ref datatypes
0524 * @param recvbuf
0525 * @param recvcnts
0526 * @param displs
0527 * @param recvtype see \ref datatypes
0528 * @param comm
0529 * @return
0530 */
0531 int AMPI_Allgatherv(void *sendbuf,
0532 int sendcnt,
0533 MPI_Datatype sendtype,
0534 void *recvbuf,
0535 int *recvcnts,
0536 int *displs,
0537 MPI_Datatype recvtype,
0538 MPI_Comm comm);
0539
0540
0541 int AMPI_Comm_dup(MPI_Comm comm, MPI_Comm *dupComm) ;
0542
0543 /**
0544 * Same as \ref AMPI_Comm_dup but manages the shadow communicators if code is differentiated in tangent mode with ST-AD with shadow variables (e.g. Tapenade)
0545 */
0546 int TLS_AMPI_Comm_dup(MPI_Comm comm, MPI_Comm *dupComm) ;
0547
0548 int AMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *dupComm) ;
0549
0550 /**
0551 * Same as \ref AMPI_Comm_split but manages the shadow communicators if code is differentiated in tangent mode with ST-AD with shadow variables (e.g. Tapenade)
0552 */
0553 int TLS_AMPI_Comm_split(MPI_Comm comm, int color, int key, MPI_Comm *dupComm) ;
0554
0555 int AMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *dupComm) ;
0556
0557 /**
0558 * Same as \ref AMPI_Comm_create but manages the shadow communicators if code is differentiated in tangent mode with ST-AD with shadow variables (e.g. Tapenade)
0559 */
0560 int TLS_AMPI_Comm_create(MPI_Comm comm, MPI_Group group, MPI_Comm *dupComm) ;
0561
0562 int AMPI_Comm_free(MPI_Comm *comm) ;
0563
0564 /**
0565 * Same as \ref AMPI_Comm_free but manages the shadow communicators if code is differentiated in tangent mode with ST-AD with shadow variables (e.g. Tapenade)
0566 */
0567 int TLS_AMPI_Comm_free(MPI_Comm *comm) ;
0568
0569 /**
0570 * all parameters as in the MPI standard with exceptions as listed
0571 * @param base
0572 * @param size
0573 * @param disp_unit
0574 * @param info
0575 * @param comm
0576 * @param win active window
0577 *
0578 * @return
0579 */
0580 int AMPI_Win_create( void *base,
0581 MPI_Aint size,
0582 int disp_unit,
0583 MPI_Info info,
0584 MPI_Comm comm,
0585 AMPI_Win *win );
0586
0587 /**
0588 * all parameters as in the MPI standard with exceptions as listed
0589 * @param assert
0590 * @param win active window
0591 *
0592 * @return
0593 */
0594 int AMPI_Win_fence( int assert,
0595 AMPI_Win win );
0596
0597 /**
0598 * all parameters as in the MPI standard with exceptions as listed
0599 * @param win active window
0600 *
0601 * @return
0602 */
0603 int AMPI_Win_free( AMPI_Win *win );
0604
0605 /**
0606 * all parameters as in the MPI standard with exceptions as listed
0607 * @param origin_addr
0608 * @param origin_count
0609 * @param origin_datatype see \ref datatypes
0610 * @param target_rank
0611 * @param target_disp
0612 * @param target_count
0613 * @param target_datatype see \ref datatypes
0614 * @param win active window
0615 *
0616 * @return
0617 */
0618 int AMPI_Get( void *origin_addr,
0619 int origin_count,
0620 MPI_Datatype origin_datatype,
0621 int target_rank,
0622 MPI_Aint target_disp,
0623 int target_count,
0624 MPI_Datatype target_datatype,
0625 AMPI_Win win );
0626
0627 /**
0628 * all parameters as in the MPI standard with exceptions as listed
0629 * @param origin_addr
0630 * @param origin_count
0631 * @param origin_datatype see \ref datatypes
0632 * @param target_rank
0633 * @param target_disp
0634 * @param target_count
0635 * @param target_datatype see \ref datatypes
0636 * @param win active window
0637 *
0638 * @return
0639 */
0640 int AMPI_Put( void *origin_addr,
0641 int origin_count,
0642 MPI_Datatype origin_datatype,
0643 int target_rank,
0644 MPI_Aint target_disp,
0645 int target_count,
0646 MPI_Datatype target_datatype,
0647 AMPI_Win win );
0648
0649 #endif