/usr/include/gromacs/thread_mpi/tmpi.h is in gromacs-dev 4.6.5-1build1.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 | /*
This source code file is part of thread_mpi.
Written by Sander Pronk, Erik Lindahl, and possibly others.
Copyright (c) 2009, Sander Pronk, Erik Lindahl.
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1) Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2) Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3) Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY US ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL WE BE LIABLE FOR ANY
DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
If you want to redistribute modifications, please consider that
scientific software is very special. Version control is crucial -
bugs must be traceable. We will be happy to consider code for
inclusion in the official distribution, but derived work should not
be called official thread_mpi. Details are found in the README & COPYING
files.
*/
#ifndef TMPI_TMPI_H_
#define TMPI_TMPI_H_
/** \file
*
* \brief Partial implementation of MPI using only threads.
*
* See the MPI specification at
* http://www.mpi-forum.org/docs/docs.html
* for an explanation of what these functions do.
*
* Because this is a thread-based library, be very careful with global
* variables and static variables in functions: they will be shared across
* all threads and lead to conflicts if not properly mutex-ed or barrier-ed
* out.
*
* \sa http://www.mpi-forum.org/docs/docs.html for MPI documentation.
*/
/* for size_t, include stddef.h - which is in C89. This is done
regardless of whether we're compiling C++ or C code because the base
library for this is in C. */
#include <stddef.h>
#include "visibility.h"
#ifdef __cplusplus
extern "C"
{
#endif
#if 0
} /* Avoids screwing up auto-indentation */
#endif
/** tMPI definition.
Use this to check for thread_mpi with the preprocessor. */
#define TMPI
/** tMPI initialization thread affinity strategy.
Used in the tMPI_Init_affinity() and tMPI_Init_fn_affinity() functions,
to control how affinity is set. The default tMPI_Init() and tMPI_Init_fn()
functions use the TMPI_AFFINITY_ALL_CORES strategy.
These strategies are fairly basic. For more flexibility, use the
tMPI_Set_affinity() function.*/
typedef enum
{
TMPI_AFFINITY_NONE = 0, /**< Do not set any thread affinity */
TMPI_AFFINITY_ALL_CORES, /**< Only set affinity if the number of threads
is equal to the number of hardware threads
(cores + hyperthreads). This is the only
safe way to set thread affinity,
without clashes between multiple
instances of the same program. */
} tMPI_Affinity_strategy;
/** tMPI Communicator
Holds the group of processes to communicate
with, and defines the scope for global operations such as broadcast. */
typedef struct tmpi_comm_ *tMPI_Comm;
/** tMPI Group
The group structure. Contains a list of threads. */
typedef struct tmpi_group_ *tMPI_Group;
/** tMPI Request
Request structure for holding data about non-blocking transfers. */
typedef struct tmpi_req_ *tMPI_Request;
/** tMPI datatype
tMPI data type structure. Holds info about datatypes. */
typedef struct tmpi_datatype_ *tMPI_Datatype;
/*! \name tMPI Data types
These are MPI data types as specified by the MPI standard.
Note that not all are available. */
/*! \{ */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_CHAR; /**< char */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_SHORT; /**< short */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_INT; /**< int */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_LONG; /**< long */
#ifdef SIZEOF_LONG_LONG_INT
TMPI_EXPORT
extern const tMPI_Datatype TMPI_LONG_LONG; /**< long long */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_LONG_LONG_INT; /**< long long int */
#endif
TMPI_EXPORT
extern const tMPI_Datatype TMPI_SIGNED_CHAR; /**< signed char */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_UNSIGNED_CHAR; /**< unsigned char */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_UNSIGNED_SHORT; /**< unsigned short */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_UNSIGNED; /**< unsigned int */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_UNSIGNED_LONG; /**< unsigned long */
#ifdef SIZEOF_LONG_LONG_INT
TMPI_EXPORT
extern const tMPI_Datatype TMPI_UNSIGNED_LONG_LONG; /**< unsigned long long */
#endif
TMPI_EXPORT
extern const tMPI_Datatype TMPI_FLOAT; /**< float */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_DOUBLE; /**< double */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_LONG_DOUBLE; /**< long double */
/*extern tMPI_Datatype tMPI_UNSIGNED_WCHAR */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_BYTE; /**< byte (for binary
xmissions) */
TMPI_EXPORT
extern const tMPI_Datatype TMPI_POINTER; /**< pointer (thread_mpi
specific) */
/*! \} */
/** Error codes */
enum
{
TMPI_SUCCESS = 0, /*!< No error */
TMPI_ERR_NO_MEM, /*!< Out of memory */
TMPI_ERR_IO, /*!< I/O Error (used for system errors) */
TMPI_ERR_INIT, /*!< Initialization error */
TMPI_ERR_FINALIZE, /*!< Finalize error */
TMPI_ERR_GROUP, /*!< Group error */
TMPI_ERR_COMM, /*!< Comm error */
TMPI_ERR_STATUS, /*!< Status error */
TMPI_ERR_GROUP_RANK, /*!< Group rank error */
TMPI_ERR_DIMS, /*!< Invalid topology dimensions */
TMPI_ERR_COORDS, /*!< Invalid topology coordinates */
TMPI_ERR_CART_CREATE_NPROCS, /*!< Not enough processes for topology*/
TMPI_ERR_XFER_COUNTERPART, /*!< Invalid counterpart for xfer */
TMPI_ERR_XFER_BUFSIZE, /*!< buffer size too small*/
TMPI_ERR_XFER_BUF_OVERLAP, /*!< buffer overlaps (thread error?)*/
TMPI_ERR_SEND_DEST, /*!< Faulty send destination */
TMPI_ERR_RECV_SRC, /*!< Faulty receive source */
TMPI_ERR_BUF, /*!< Invalid buffer */
TMPI_ERR_MULTI_MISMATCH, /*!< Comm not the same in collective call*/
TMPI_ERR_OP_FN, /*!< Invalid reduce operator*/
TMPI_ERR_ENVELOPES, /*!< out of envelopes (tMPI internal) */
TMPI_ERR_REQUESTS, /*!< out of requests (tMPI internal) */
TMPI_ERR_COPY_NBUFFERS, /*!< out of copy buffers (tMPI internal)*/
TMPI_ERR_COPY_BUFFER_SIZE, /*!< copy buffer size err (tMPI internal)*/
TMPI_ERR_IN_STATUS, /*!< error code in tMPI_Status */
TMPI_ERR_PROCNR, /*!< Hardware processor number (such as for
thread affinity) error */
TMPI_FAILURE, /*!< Transmission failure */
TMPI_ERR_UNKNOWN, /*!< Unknown error */
N_TMPI_ERR /* this must be the last one */
};
/** Maximum length of error string for tMPI_Error_string() */
#define TMPI_MAX_ERROR_STRING 256
/** default code for undefined value,
For example for undefined color in tMPI_Split(). */
#define TMPI_UNDEFINED -1
/** error handler function */
typedef void (*tMPI_Errhandler_fn)(tMPI_Comm*, int*);
/** error handler object */
typedef struct tmpi_errhandler_ *tMPI_Errhandler;
/** pre-defined error handler that abort()s on every error */
extern tMPI_Errhandler TMPI_ERRORS_ARE_FATAL;
/** pre-defined error handler that tries to continue on every error */
extern tMPI_Errhandler TMPI_ERRORS_RETURN;
/*! \name tMPI_Comm_compare() return codes */
/*! \{ */
/** Identical comms*/
#define TMPI_IDENT 0
/** Comms with the same members in the same order*/
#define TMPI_CONGRUENT 1
/** Comms with the same members in the different order*/
#define TMPI_SIMILAR 2
/** Comms with the different members */
#define TMPI_UNEQUAL 3
/*! \} */
/** Source number wildcard so tMPI_Recv(), etc. can receive from
any source. */
#define TMPI_ANY_SOURCE -1
/** Tag number wildcard so tMPI_Recv(), etc. can receive messages with
any tag. */
#define TMPI_ANY_TAG -1
/** Return code for Cartesian topology with tMPI_Topo_test(). */
#define TMPI_CART 1
/** Return code for graph topology with tMPI_Topo_test(). */
#define TMPI_GRAPH 2
/** Pre-initialized communicator with all available threads. */
TMPI_EXPORT
extern tMPI_Comm TMPI_COMM_WORLD;
/** A pre-defined NULL communicator to compare against, to check comm
validity */
#define TMPI_COMM_NULL NULL
/** A pre-defined NULL group to compare against, to check group
validity */
#define TMPI_GROUP_NULL NULL
/** the empty group */
extern tMPI_Group TMPI_GROUP_EMPTY;
/** The maximum processor name returned using tMPI_Get_processor_name(). */
#define TMPI_MAX_PROCESSOR_NAME 128
/** Used as NULL status for tMPI_Recv(), etc. */
#define TMPI_STATUS_IGNORE NULL
/** Used as NULL status list for tMPI_Waitall(), etc. */
#define TMPI_STATUSES_IGNORE NULL
/** tMPI Status.
Holds status info (tag, sender, amount of data transmitted) for receives.
The status object is user-maintained. */
typedef struct tmpi_status_
{
int TMPI_SOURCE; /**< Message source rank. */
int TMPI_TAG; /**< Message source tag. */
int TMPI_ERROR; /**< Message error. */
size_t transferred; /**< Number of transferred bytes */
int cancelled; /**< Whether the transmission was canceled */
} tMPI_Status;
/*typedef struct tmpi_status_ tMPI_Status;*/
/** NULL request */
#define TMPI_REQUEST_NULL NULL
/** collective communication special to signify that the send
buffer is to function as receive buffer.
Used, for example in tMPI_Reduce. */
#define TMPI_IN_PLACE NULL
/** tMPI_Reduce operators.
These all work (except obviously bad combinations like bitwise
and/or/xor on floats, etc): */
typedef enum
{
TMPI_MAX, /**< calculate maximum value */
TMPI_MIN, /**< calculate minimum value */
TMPI_SUM, /**< calculate sum */
TMPI_PROD, /**< calculate product */
TMPI_LAND, /**< calculate logical and */
TMPI_BAND, /**< calculate binary and */
TMPI_LOR, /**< calculate logical or */
TMPI_BOR, /**< calculate binary or */
TMPI_LXOR, /**< calculate logical xor */
TMPI_BXOR /**< calculate binary xor */
} tMPI_Op;
#ifndef DOXYGEN
/* function to obtain tMPI_COMM_SELF */
tMPI_Comm tMPI_Get_comm_self(void);
#endif
/** The thread-specific comm containing only the thread itself.
\hideinitializer
\return the self comm object associated with the thread. */
#define TMPI_COMM_SELF (tMPI_Get_comm_self())
/* functions: */
/*! \name Initialization and exit functions
\{ */
/** Traditional MPI initializer; spawns threads that start at the given
function.
Seeks the argument '-nt n', where n is the number of
threads that will be created. If n==0, the number of threads will
be the recommended number of threads for this platform as obtained
from tMPI_Get_recommended_ntreads().
The new threads then run the function start_function, with the original
argc and argv. This function could be main(), or any other function;
calling this function again - whether from the started threads or from
the main thread - has no effect.
On platforms that support thread affinity setting, this function will
use the 'all-cores' affinity strategy: it will only set thread affinity
if the number of threads is equal to the number of hardware threads
(cores + hyperthreads).
\param[in] argc argc of original main() invocation, or NULL
\param[in] argv argv of original main() invocation, or NULL.
\param[in] start_function Starting function of type
int start_function(int argc, char *argv[]);
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Init(int *argc, char ***argv,
int (*start_function)(int, char**));
/** Generic init function thread MPI intializer and thread spawner.
Creates N threads (including main thread)
that run the function start_function, which takes a void* argument,
given by arg. The function start_function also gets called by the main
thread. When the function start_function returns it, will behave
as if tMPI_Finalize is called, and if it's a sub-thread it will
stop running.
If N==0, the number of threads will be the recommended number of
threads for this platform as obtained from tMPI_Get_recommended_ntreads().
Note that thread affinity strategy only has an effect when this is
supported by the underlying platform. As of yet (2012), this is not the
case for Mac OS X, for example.
\param[in] main_thread_returns whether the control in the main thread
should return immediately (if true), or
the start_function() should be called
from the main thread, too (if false).
\param[in] N The number of threads to start (or 0 to
automatically determine this).
\param[in] aff_strategy The thread affinity strategy to use.
\param[in] start_function The function to start threads at
(including main thread if
main_thread_returns).
\param[in] arg An optional argument for start_function().
\return TMPI_FAILURE on failure, TMPI_SUCCESS on succes (after all
threads have finished if main_thread_returns=true). */
TMPI_EXPORT
int tMPI_Init_fn(int main_thread_returns, int N,
tMPI_Affinity_strategy aff_strategy,
void (*start_function)(void*), void *arg);
/** get the number of threads from the command line
can be called before tMPI_Init()
\param[in] argc argc from main()
\param[in] argv argv from main()
\param[in] optname name of the argument specifying the
number of threads to run. If this is
NULL, this function will read the first
argument and interpret it as the number
of threads.
\param[out] nthreads the number of threads
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Get_N(int *argc, char ***argv, const char *optname, int *nthreads);
/** Waits for all other threads to finish and cleans up
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Finalize(void);
/** Just kills all threads.
Not really neccesary because exit() would do that for us anyway.
\param[in] comm Comm to kill threads for
\param[in] errorcode Error code to exit with
\return Never returns. */
TMPI_EXPORT
int tMPI_Abort(tMPI_Comm comm, int errorcode);
/** whether tMPI_Init, but not yet tMPI_Finalize, has been run
\param[out] flag Set to TRUE if tMPI_Init() has been called,
FALSE if not.
\return always returns TMPI_SUCCESS. */
TMPI_EXPORT
int tMPI_Initialized(int *flag);
/** Determine whether tMPI_Finalize has been run.
\param[out] flag Set to TRUE if tMPI_Finalize() has been
called, FALSE if not.
\return always returns TMPI_SUCCESS. */
TMPI_EXPORT
int tMPI_Finalized(int *flag);
/** \} */
/*! \name Error handling functions
\{ */
/** Create an error handler object from a function.
\param[in] function The function to make an error handler of.
\param[out] errhandler The error handler.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Create_errhandler(tMPI_Errhandler_fn *function,
tMPI_Errhandler *errhandler);
/** Free the error handler object.
\param[in] errhandler The error handler.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Errhandler_free(tMPI_Errhandler *errhandler);
/** Set the error handler.
\param[in] comm the communicator to set the error handler for.
\param[in] errhandler the error handler.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_set_errhandler(tMPI_Comm comm, tMPI_Errhandler errhandler);
/** get the error handler.
Gets the error handler associated with a comm
\param[in] comm the communicator to get the error handler for.
\param[out] errhandler the error handler.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_get_errhandler(tMPI_Comm comm, tMPI_Errhandler *errhandler);
/** get the error string associated with an error code.
The length of the error string will never exceed TMPI_MAX_ERROR_STRING.
\param[in] errorcode The error code.
\param[out] string The pre-allocated char pointer to output to.
\param[out] resultlen The length of the error string. Will
never be longer than TMPI_MAX_ERROR_STRING.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Error_string(int errorcode, char *string, size_t *resultlen);
/** \} */
/*! \name Environment query functions
\{ */
/** returns string with thread number.
\param[out] name Pre-allocated string to output name to (will not
be longer than TMPI_MAX_PROCESSOR_NAME).
\param[out] resultlen The length of the output. Note that this is an
int instead of a size_t because the MPI standard
for some reason defines all sizes as int
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Get_processor_name(char *name, int *resultlen);
/** get a time value as a double, in seconds.
\return time value.
*/
TMPI_EXPORT
double tMPI_Wtime(void);
/** get the resolution of tMPI_Wtime as a double, in seconds
\return time resolution. */
TMPI_EXPORT
double tMPI_Wtick(void);
#ifndef DOXYGEN
#define tMPI_This_threadnr() (int)(tMPI_Get_current() - threads)
#else
/** Get the thread number of this thread.
Mostly for debugging.
\return the global thread number. */
int tMPI_This_Threadnr(void);
#endif
/** \} */
/*! \name tMPI_Group functions
\{ */
/** Get the size (number of members) of a group.
\param[in] group The group.
\param[out] size Size.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Group_size(tMPI_Group group, int *size);
/** Get the rank of a thread in a group
\param[in] group The group.
\param[out] rank Variable for the rank, or TMPI_UNDEFINED
if not in group.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Group_rank(tMPI_Group group, int *rank);
/** Create a new group as a the collection of threads with given ranks.
\param[in] group The group from which the ranks are taken.
\param[in] n The number of new group members.
\param[in] ranks The ranks of the threads to add to the new group.
\param[out] newgroup The new group.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Group_incl(tMPI_Group group, int n, int *ranks, tMPI_Group *newgroup);
/** Get a pointer to the group in the comm.
\param[in] comm The comm from which to take the group.
\param[out] group The comm's group.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_group(tMPI_Comm comm, tMPI_Group *group);
/** De-allocate a group
\param[in] group The group to de-allocate.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Group_free(tMPI_Group *group);
/*! \} */
/*! \name tMPI_Comm functions
\{ */
/** Get the comm size (nr. of threads).
\param[in] comm The comm to query.
\param[out] size The comm size.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_size(tMPI_Comm comm, int *size);
/** get the rank in comm of the current process
\param[in] comm The comm to query.
\param[out] rank Thread rank in comm.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_rank(tMPI_Comm comm, int *rank);
/** Compare two comms. Returns TMPI_IDENT if the two comms point to
the same underlying comm structure, TMPI_CONGRUENT if all
members appear in the both comms in the same order, TMPI_SIMILAR
if both comms have the smae members but not in the same order, or
TMPI_UNEQUAL if the comms have different members.
\param[in] comm1 The first comm to compare.
\param[in] comm2 The second comm to compare.
\param[out] result The output result, one of the values
described above.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_compare(tMPI_Comm comm1, tMPI_Comm comm2, int *result);
/** De-allocate a comm
Collective function.
\param[in] comm The comm to free.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_free(tMPI_Comm *comm);
/** Create a comm based on group membership.
Collective function that creates a new comm containing only proceses
that are members of the given group.
\param[in] comm The originating comm.
\param[in] group The group of threads to create a comm from.
\param[out] newcomm The new comm.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_create(tMPI_Comm comm, tMPI_Group group, tMPI_Comm *newcomm);
/** Split up a group into same-colored sub-groups ordered by key.
This is the main comm creation function: it's a collective call that takes
a color and a key from each process, and arranges all threads that
call tMPI_Split() withe the same color together into a comm.
The rank in the new group will be based on the value given in key.
Passing TMPI_UNDEFINED as a color will result in the thread not being
part of any group, and getting TMPI_COMM_NULL back in newcomm.
\param[in] comm The originating comm.
\param[in] color This thread's color (determines which comm it will
be in). Giving TMPI_UNDEFINED will result in
this thread not being in any group.
\param[in] key This thread's key (determines rank).
\param[out] newcomm The new comm.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_split(tMPI_Comm comm, int color, int key, tMPI_Comm *newcomm);
/** Make a duplicate of a comm.
Collective function.
\param[in] comm The originating comm.
\param[in] newcomm The new comm.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Comm_dup(tMPI_Comm comm, tMPI_Comm *newcomm);
/*! \} */
/*! \name Topology functions
\{ */
/* topology functions */
/** Check what type of topology the comm has.
\param[in] comm The comm to query
\param[out] status The type of topology.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Topo_test(tMPI_Comm comm, int *status);
/** Get the dimensionality of a comm with a topology.
\param[in] comm The comm to query.
\param[out] ndims The number of dimensions.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cartdim_get(tMPI_Comm comm, int *ndims);
/** Get the size and pbc a of a comm with a Cartesian topology has.
\param[in] comm The comm to query.
\param[in] maxdims The maximum number of dimensions in the periods
and coords parameter.
\param[out] dims The number of dimensions.
\param[out] periods The periodicity in each dimension.
\param[out] coords The number of coordinates in each dimension.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cart_get(tMPI_Comm comm, int maxdims, int *dims, int *periods,
int *coords);
/** Get rank that a specific set of process coordinates has in
a Cartesian topology.
\param[in] comm The comm to query.
\param[in] coords The coordinates in each dimension.
\param[out] rank The rank associated with the coordinates.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cart_rank(tMPI_Comm comm, int *coords, int *rank);
/** Get coordinates of a process rank in a Cartesian topology.
\param[in] comm The comm to query.
\param[in] rank The rank associated with the coordinates.
\param[in] maxdims The maximum number of dimensions in the coords
parameter.
\param[out] coords The coordinates in each dimension.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cart_coords(tMPI_Comm comm, int rank, int maxdims, int *coords);
/** Get optimal rank this process would have in a Cartesian topology.
\param[in] comm The comm to query.
\param[in] ndims The number of dimensions.
\param[in] dims The size in each dimension.
\param[in] periods The periodicity in each dimension.
\param[out] newrank The rank the thread would have given the topology.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cart_map(tMPI_Comm comm, int ndims, int *dims, int *periods,
int *newrank);
/** Create a comm with a Cartesian topology.
\param[in] comm_old The originating comm.
\param[in] ndims The number of dimensions.
\param[in] dims The size in each dimension.
\param[in] periods The periodicity in each dimension.
\param[in] reorder Whether to allow reordering of the threads
according to tMPI_Cart_map().
\param[out] comm_cart The new comm with Cartesian topology.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cart_create(tMPI_Comm comm_old, int ndims, int *dims, int *periods,
int reorder, tMPI_Comm *comm_cart);
/** Create a comms that are sub-spaces of the Cartesian topology communicator.
Works like a MPI_Comm_split() for the Cartesian dimensions specified
as false in remain_dims.
\param[in] comm The originating comm with Cartesian topology.
\param[in] remain_dims An Boolean array that decides whether a specific
dimensionality should remain in newcomm (if true),
or should be split up (if false).
\param[out] newcomm The new split communicator
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Cart_sub(tMPI_Comm comm, int *remain_dims, tMPI_Comm *newcomm);
/*! \} */
/*! \name Data type manipulation functions
\{ */
/** Create a contiguous data type (the only type possible right now).
Creates a datatype that is a vector of oldtype.
\param[in] count The number of oldtype types in the new type.
\param[in] oldtype The old data type.
\param[out] newtype The new data type (still needs to be committed).
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Type_contiguous(int count, tMPI_Datatype oldtype,
tMPI_Datatype *newtype);
/** Make a data type ready for use.
\param[in,out] datatype The new datatype.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Type_commit(tMPI_Datatype *datatype);
/*! \} */
/*! \name Point-to-point communication functions
\{ */
/* blocking transfers. The actual transfer (copy) is done on the receiving end
(so that the receiver's cache already contains the data that it presumably
will use soon). */
/** Send message; blocks until buf is reusable.
\param[in] buf The buffer with data to send.
\param[in] count The number of items to send.
\param[in] datatype The data type of the items in buf.
\param[in] dest The rank of the destination thread.
\param[in] tag The message tag.
\param[in] comm The shared communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Send(void* buf, int count, tMPI_Datatype datatype, int dest,
int tag, tMPI_Comm comm);
/** Receive message; blocks until buf is filled.
\param[out] buf The buffer for data to receive.
\param[in] count The maximum number of items to receive.
\param[in] datatype The data type of the items in buf.
\param[in] source The rank of the source thread (or TMPI_ANY_SOURCE).
\param[in] tag The message tag (or TMPI_ANY_TAG).
\param[in] comm The shared communicator.
\param[out] status The message status.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Recv(void* buf, int count, tMPI_Datatype datatype, int source,
int tag, tMPI_Comm comm, tMPI_Status *status);
/** Send & receive message at the same time.
Blocks until recvbuf is filled, and sendbuf is ready for reuse.
\param[in] sendbuf The buffer with data to send.
\param[in] sendcount The number of items to send.
\param[in] sendtype The data type of the items in send buf.
\param[in] dest The rank of the destination thread.
\param[in] sendtag The send message tag.
\param[out] recvbuf The buffer for data to receive.
\param[in] recvcount The maximum number of items to receive.
\param[in] recvtype The data type of the items in recvbuf.
\param[in] source The rank of the source thread (or TMPI_ANY_SOURCE).
\param[in] recvtag The recveive message tag (or TMPI_ANY_TAG).
\param[in] comm The shared communicator.
\param[out] status The received message status.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Sendrecv(void *sendbuf, int sendcount, tMPI_Datatype sendtype,
int dest, int sendtag, void *recvbuf, int recvcount,
tMPI_Datatype recvtype, int source, int recvtag,
tMPI_Comm comm, tMPI_Status *status);
/* async send/recv. The actual transfer is done on the receiving
end, during tMPI_Wait, tMPI_Waitall or tMPI_Test. For tMPI_Waitall,
the incoming messages are processed in the order they come in. */
/** Initiate sending a message, non-blocking.
This makes the buffer available to be received. The contents of buf
should not be touched before the transmission is finished with
tMPI_Wait(), tMPI_Test() or tMPI_Waitall().
\param[in] buf The buffer with data to send.
\param[in] count The number of items to send.
\param[in] datatype The data type of the items in buf.
\param[in] dest The rank of the destination thread.
\param[in] tag The message tag.
\param[in] comm The shared communicator.
\param[out] request The request object that can be used in tMPI_Wait(),
tMPI_Test, etc.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Isend(void* buf, int count, tMPI_Datatype datatype, int dest,
int tag, tMPI_Comm comm, tMPI_Request *request);
/** Initiate receiving a message.
This makes the buffer available to be filled with data. The contents of
buf should not be relied on before the transmission is finished with
tMPI_Wait(), tMPI_Test() or tMPI_Waitall().
\param[out] buf The buffer for data to receive.
\param[in] count The maximum number of items to receive.
\param[in] datatype The data type of the items in buf.
\param[in] source The rank of the source thread (or TMPI_ANY_SOURCE).
\param[in] tag The message tag (or TMPI_ANY_TAG).
\param[in] comm The shared communicator.
\param[out] request The request object that can be used in tMPI_Wait(),
tMPI_Test, etc.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Irecv(void* buf, int count, tMPI_Datatype datatype, int source,
int tag, tMPI_Comm comm, tMPI_Request *request);
/** Test whether a message is transferred.
\param[in,out] request The request obtained wit tMPI_Isend()/tMPI_Irecv().
\param[out] flag A flag set to TRUE(1) if the request is finished,
FALSE(0) otherwise.
\param[out] status Message status (can be set to TMPI_STATUS_IGNORE).
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Test(tMPI_Request *request, int *flag, tMPI_Status *status);
/** Wait until a message is transferred.
\param[in,out] request The request obtained wit tMPI_Isend()/tMPI_Irecv().
\param[out] status Message status.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Wait(tMPI_Request *request, tMPI_Status *status);
/** Wait until several messages are transferred.
\param[in] count The number of requests
\param[in,out] array_of_requests List of count requests obtained with
tMPI_Isend()/tMPI_Irecv().
\param[out] array_of_statuses List of count message statuses (can
be set to TMPI_STATUSES_IGNORE).
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Waitall(int count, tMPI_Request *array_of_requests,
tMPI_Status *array_of_statuses);
/** Test whether several messages are transferred.
\param[in] count The number of requests
\param[in,out] array_of_requests List of count requests obtained with
tMPI_Isend()/tMPI_Irecv().
\param[out] flag Whether all requests have completed.
\param[out] array_of_statuses List of count message statuses (can
be set to TMPI_STATUSES_IGNORE).
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Testall(int count, tMPI_Request *array_of_requests, int *flag,
tMPI_Status *array_of_statuses);
/** Wait until one of several messages is transferred.
\param[in] count The number of requests
\param[in,out] array_of_requests List of count requests obtained with
tMPI_Isend()/tMPI_Irecv().
\param[out] index Index of the request that has
completed.
\param[out] status Pointer to tMPI_Status object
associated with completed request.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Waitany(int count, tMPI_Request *array_of_requests,
int *index, tMPI_Status *status);
/** Test whether one of several messages is transferred.
\param[in] count The number of requests
\param[in,out] array_of_requests List of count requests obtained with
tMPI_Isend()/tMPI_Irecv().
\param[out] index Index of the request that has
completed.
\param[out] flag Whether any request has completed.
\param[out] status Pointer to tMPI_Status object
associated with completed request.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Testany(int count, tMPI_Request *array_of_requests,
int *index, int *flag, tMPI_Status *status);
/** Wait until some of several messages are transferred. Waits until at least
one message is transferred.
\param[in] incount The number of requests
\param[in,out] array_of_requests List of count requests obtained with
tMPI_Isend()/tMPI_Irecv().
\param[out] outcount Number of completed requests
\param[out] array_of_indices Array of ints that gets filled with
the indices of the completed requests.
\param[out] array_of_statuses List of count message statuses (can
be set to TMPI_STATUSES_IGNORE).
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Waitsome(int incount, tMPI_Request *array_of_requests,
int *outcount, int *array_of_indices,
tMPI_Status *array_of_statuses);
/** Test whether some of several messages are transferred.
\param[in] incount The number of requests
\param[in,out] array_of_requests List of count requests obtained with
tMPI_Isend()/tMPI_Irecv().
\param[out] outcount Number of completed requests
\param[out] array_of_indices Array of ints that gets filled with
the indices of the completed requests.
\param[out] array_of_statuses List of count message statuses (can
be set to TMPI_STATUSES_IGNORE).
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Testsome(int incount, tMPI_Request *array_of_requests,
int *outcount, int *array_of_indices,
tMPI_Status *array_of_statuses);
/** get the number of actually transferred items from a receive
status.
\param[in] status The status.
\param[in] datatype The data type which was received.
\param[out] count The number of items actually received.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Get_count(tMPI_Status *status, tMPI_Datatype datatype, int *count);
/*! \} */
/*! \name Synchronization functions
\{ */
/** Block until all threads in the comm call this function.
\param[in] comm The comm object.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Barrier(tMPI_Comm comm);
/*! \} */
/*! \name Multicast communication functions
\{ */
/** Broadcast from one thread to all others in comm.
Collective function; data is transferred from root's buffer to all others'
buffer.
\param[in,out] buffer The buffer to send from (root)/receive from
(other threads).
\param[in] count The number of items to send/receive.
\param[in] datatype The type of the items to send/receive.
\param[in] root The rank of the sending thread.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Bcast(void* buffer, int count, tMPI_Datatype datatype, int root,
tMPI_Comm comm);
/** Gather data from all threads in comm to root.
Collective function; assumes that all data is received in blocks of
recvcount.
\param[in] sendbuf The send buffer for all threads (root may
specify TMPI_IN_PLACE, in which case it
transfers nothing to itself).
\param[in] sendcount The number of items to send for all threads.
\param[in] sendtype The type of the items to send.
\param[out] recvbuf The receiving buffer (for root thread).
\param[in] recvcount The number of items to receive (for root).
\param[in] recvtype The type of the items to receive (for root).
\param[in] root The rank of root.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Gather(void* sendbuf, int sendcount, tMPI_Datatype sendtype,
void* recvbuf, int recvcount, tMPI_Datatype recvtype, int root,
tMPI_Comm comm);
/** Gather irregularly laid out data from all processes in comm to root.
Collective function.
\param[in] sendbuf The send buffer for all threads (root may
specify TMPI_IN_PLACE, in which case it
transfers nothing to itself).
\param[in] sendcount The number of items to send for all threads.
\param[in] sendtype The type of the items to send.
\param[out] recvbuf The receiving buffer (for root thread).
\param[in] recvcounts The list of number of items to receive (for
root).
\param[in] displs The list of displacements in recvbuf to
receive data in (for root).
\param[in] recvtype The type of the items to receive (for root).
\param[in] root The rank of root.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Gatherv(void* sendbuf, int sendcount, tMPI_Datatype sendtype,
void* recvbuf, int *recvcounts, int *displs,
tMPI_Datatype recvtype, int root, tMPI_Comm comm);
/** Spread parts of sendbuf to all processes in comm from root.
Collective function.
\param[in] sendbuf The send buffer for root.
\param[in] sendcount The number of items for root to send to each
thread.
\param[in] sendtype The type of the items root sends.
\param[out] recvbuf The receiving buffer for all receiving threads
(root may specify TMPI_IN_PLACE, in which case
it transmits nothing to itself).
\param[in] recvcount The number of items recvbuf can receive.
\param[in] recvtype The type of items to receive.
\param[in] root The rank of root.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Scatter(void* sendbuf, int sendcount, tMPI_Datatype sendtype,
void* recvbuf, int recvcount, tMPI_Datatype recvtype, int root,
tMPI_Comm comm);
/** Spread irregularly laid out parts of sendbuf to all processes
in comm from root.
Collective function.
\param[in] sendbuf The send buffer for root.
\param[in] sendcounts List of the number of items for root to send
to each thread.
\param[in] displs List of displacements in sendbuf from which
to start transmission to each thread.
\param[in] sendtype The type of the items root sends.
\param[out] recvbuf The receiving buffer for all receiving threads
(root may specify TMPI_IN_PLACE, in which case
it transmits nothing to itself).
\param[in] recvcount The number of items recvbuf can receive.
\param[in] recvtype The type of items to receive.
\param[in] root The rank of root.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Scatterv(void* sendbuf, int *sendcounts, int *displs,
tMPI_Datatype sendtype, void* recvbuf, int recvcount,
tMPI_Datatype recvtype, int root, tMPI_Comm comm);
/** Spread out parts of sendbuf to all processes from all processes in
comm.
Collective function.
\param[in] sendbuf The send buffer.
\param[in] sendcount The number of items for to send to each thread.
\param[in] sendtype The type of the items to send.
\param[out] recvbuf The receive buffer for all threads.
\param[in] recvcount The number of items recvbuf can receive per
thread.
\param[in] recvtype The type of items to receive.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Alltoall(void* sendbuf, int sendcount, tMPI_Datatype sendtype,
void* recvbuf, int recvcount, tMPI_Datatype recvtype,
tMPI_Comm comm);
/** Spread out irregularly laid out parts of sendbuf to all
processes from all processes in comm.
Collective function.
\param[in] sendbuf The send buffer.
\param[in] sendcounts List of the number of items for to send to
each thread.
\param[in] sdispls List of the displacements in sendbuf of items
to send to each thread.
\param[in] sendtype The type of the items to send.
\param[out] recvbuf The receive buffer for all threads.
\param[in] recvcounts List of the number of items recvbuf can
receive from each thread.
\param[in] rdispls List of the displacements in recvbuf of items
to receive from each thread.
\param[in] recvtype The type of items to receive.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Alltoallv(void* sendbuf, int *sendcounts, int *sdispls,
tMPI_Datatype sendtype, void* recvbuf, int *recvcounts,
int *rdispls, tMPI_Datatype recvtype, tMPI_Comm comm);
/*! \} */
/*! \name Reduce functions
\{ */
/** Do an operation between all locally held buffers on all items in the
buffers, and send the results to root.
Collective function.
\param[in] sendbuf The operand parameters. Root may specify
TMPI_IN_PLACE, in which case recvbuf will hold
the operand parameters.
\param[out] recvbuf The result buffer at root.
\param[in] count The number of items to do operation on.
\param[in] datatype The data type of the items.
\param[in] op The operation to perform.
\param[in] root The root thread (which is to receive the results).
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Reduce(void* sendbuf, void* recvbuf, int count,
tMPI_Datatype datatype, tMPI_Op op, int root, tMPI_Comm comm);
/** Do an operation between all locally held buffers on all items in the
buffers and broadcast the results.
Collective function.
\param[in] sendbuf The operand parameters. Any process may specify
TMPI_IN_PLACE, in which case recvbuf will hold
the operand parameters for that process.
\param[in,out] recvbuf The result buffer.
\param[in] count The number of items to do operation on.
\param[in] datatype The data type of the items.
\param[in] op The operation to perform.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Allreduce(void* sendbuf, void* recvbuf, int count,
tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm);
/** Do an tMPI_Reduce, but with the following assumption:
recvbuf points to a valid buffer in all calling threads, or
sendbuf has the value TMPI_IN_PLACE (in which case the values of
sendbuf may be changed in that thread).
This avoids unnecesary memory allocations associated with the normal
tMPI_Reduce.
Collective function.
\param[in] sendbuf The operand parameters (or TMPI_IN_PLACE,
in which case the operand parameters will
be in recvbuf).
\param[in,out] recvbuf The result buffer.
\param[in] count The number of items to do operation on.
\param[in] datatype The data type of the items.
\param[in] op The operation to perform.
\param[in] root The root thread (which is to receive
the final results).
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Reduce_fast(void* sendbuf, void* recvbuf, int count,
tMPI_Datatype datatype, tMPI_Op op, int root,
tMPI_Comm comm);
/** Do a partial reduce operation, based on rank: the results of the
reduction operation of ranks 0 - i will be put in the recvbuf of
rank i.
Collective function.
\param[in] sendbuf The operand parameters. All ranks may specify
TMPI_IN_PLACE, in which case recvbuf will hold
the operand parameters.
\param[in,out] recvbuf The result buffer.
\param[in] count The number of items to do operation on.
\param[in] datatype The data type of the items.
\param[in] op The operation to perform.
\param[in] comm The communicator.
\return TMPI_SUCCESS on success, TMPI_FAILURE on failure. */
TMPI_EXPORT
int tMPI_Scan(void* sendbuf, void* recvbuf, int count,
tMPI_Datatype datatype, tMPI_Op op, tMPI_Comm comm);
/*! \} */
#ifdef __cplusplus
} /* closing extern "C" */
#endif
#endif /* TMPI_TMPI_H_ */
|