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
|
/*
* Copyright (C) by Argonne National Laboratory
* See COPYRIGHT in top-level directory
*/
#include "mpi.h"
#include "mpitestconf.h"
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
#include <stdio.h>
#include <stdlib.h>
#include "mpitest.h"
static int verbose = 0;
/* tests */
int builtin_float_test(void);
int vector_of_vectors_test(void);
int optimizable_vector_of_basics_test(void);
int indexed_of_basics_test(void);
int indexed_of_vectors_test(void);
int struct_of_basics_test(void);
/* helper functions */
char *combiner_to_string(int combiner);
int parse_args(int argc, char **argv);
int main(int argc, char **argv)
{
int err, errs = 0;
MTest_Init(&argc, &argv);
parse_args(argc, argv);
/* To improve reporting of problems about operations, we
* change the error handler to errors return */
MPI_Comm_set_errhandler(MPI_COMM_WORLD, MPI_ERRORS_RETURN);
/* perform some tests */
err = builtin_float_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in builtin float test.\n", err);
}
err = vector_of_vectors_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in vector of vectors test.\n", err);
}
err = optimizable_vector_of_basics_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in vector of basics test.\n", err);
}
err = indexed_of_basics_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in indexed of basics test.\n", err);
}
err = indexed_of_vectors_test();
errs += err;
if (err) {
fprintf(stderr, "Found %d errors in indexed of vectors test.\n", err);
}
#ifdef HAVE_MPI_TYPE_CREATE_STRUCT
err = struct_of_basics_test();
errs += err;
#endif
MTest_Finalize(errs);
return MTestReturnValue(errs);
}
/* builtin_float_test()
*
* Tests functionality of get_envelope() and get_contents() on a MPI_FLOAT.
*
* Returns the number of errors encountered.
*/
int builtin_float_test(void)
{
int nints, nadds, ntypes, combiner;
int errs = 0;
MPI_Type_get_envelope(MPI_FLOAT, &nints, &nadds, &ntypes, &combiner);
if (combiner != MPI_COMBINER_NAMED)
errs++;
if (verbose && combiner != MPI_COMBINER_NAMED)
fprintf(stderr, "combiner = %s; should be named\n", combiner_to_string(combiner));
/* Note: it is erroneous to call MPI_Type_get_contents() on a basic. */
return errs;
}
/* vector_of_vectors_test()
*
* Builds a vector of a vector of ints. Assuming an int array of size 9
* integers, and treating the array as a 3x3 2D array, this will grab the
* corners.
*
* Returns the number of errors encountered.
*/
int vector_of_vectors_test(void)
{
MPI_Datatype inner_vector, inner_vector_copy;
MPI_Datatype outer_vector;
int nints, nadds, ntypes, combiner, *ints;
MPI_Aint *adds = NULL;
MPI_Datatype *types;
int err, errs = 0;
/* set up type */
err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
err = MPI_Type_vector(2, 1, 2, inner_vector, &outer_vector);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
/* decode outer vector (get envelope, then contents) */
err = MPI_Type_get_envelope(outer_vector, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
if (nints != 3)
errs++;
if (nadds != 0)
errs++;
if (ntypes != 1)
errs++;
if (combiner != MPI_COMBINER_VECTOR)
errs++;
if (verbose) {
if (nints != 3)
fprintf(stderr, "outer vector nints = %d; should be 3\n", nints);
if (nadds != 0)
fprintf(stderr, "outer vector nadds = %d; should be 0\n", nadds);
if (ntypes != 1)
fprintf(stderr, "outer vector ntypes = %d; should be 1\n", ntypes);
if (combiner != MPI_COMBINER_VECTOR)
fprintf(stderr, "outer vector combiner = %s; should be vector\n",
combiner_to_string(combiner));
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
ints = malloc(nints * sizeof(*ints));
if (nadds)
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
/* get contents of outer vector */
err = MPI_Type_get_contents(outer_vector, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != 2)
errs++;
if (ints[1] != 1)
errs++;
if (ints[2] != 2)
errs++;
if (verbose) {
if (ints[0] != 2)
fprintf(stderr, "outer vector count = %d; should be 2\n", ints[0]);
if (ints[1] != 1)
fprintf(stderr, "outer vector blocklength = %d; should be 1\n", ints[1]);
if (ints[2] != 2)
fprintf(stderr, "outer vector stride = %d; should be 2\n", ints[2]);
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
inner_vector_copy = types[0];
free(ints);
if (nadds)
free(adds);
free(types);
/* decode inner vector */
err = MPI_Type_get_envelope(inner_vector_copy, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
if (nints != 3)
errs++;
if (nadds != 0)
errs++;
if (ntypes != 1)
errs++;
if (combiner != MPI_COMBINER_VECTOR)
errs++;
if (verbose) {
if (nints != 3)
fprintf(stderr, "inner vector nints = %d; should be 3\n", nints);
if (nadds != 0)
fprintf(stderr, "inner vector nadds = %d; should be 0\n", nadds);
if (ntypes != 1)
fprintf(stderr, "inner vector ntypes = %d; should be 1\n", ntypes);
if (combiner != MPI_COMBINER_VECTOR)
fprintf(stderr, "inner vector combiner = %s; should be vector\n",
combiner_to_string(combiner));
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
ints = malloc(nints * sizeof(*ints));
if (nadds)
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
err = MPI_Type_get_contents(inner_vector_copy, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != 2)
errs++;
if (ints[1] != 1)
errs++;
if (ints[2] != 2)
errs++;
if (verbose) {
if (ints[0] != 2)
fprintf(stderr, "inner vector count = %d; should be 2\n", ints[0]);
if (ints[1] != 1)
fprintf(stderr, "inner vector blocklength = %d; should be 1\n", ints[1]);
if (ints[2] != 2)
fprintf(stderr, "inner vector stride = %d; should be 2\n", ints[2]);
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
free(ints);
if (nadds)
free(adds);
free(types);
MPI_Type_free(&inner_vector_copy);
MPI_Type_free(&inner_vector);
MPI_Type_free(&outer_vector);
return MTestReturnValue(errs);
}
/* optimizable_vector_of_basics_test()
*
* Builds a vector of ints. Count is 10, blocksize is 2, stride is 2, so this
* is equivalent to a contig of 20. But remember...we should get back our
* suboptimal values under MPI-2.
*
* Returns the number of errors encountered.
*/
int optimizable_vector_of_basics_test(void)
{
MPI_Datatype parent_type;
int nints, nadds, ntypes, combiner, *ints;
MPI_Aint *adds = NULL;
MPI_Datatype *types;
int errs = 0;
/* set up type */
MPI_Type_vector(10, 2, 2, MPI_INT, &parent_type);
/* decode */
MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
if (nints != 3)
errs++;
if (nadds != 0)
errs++;
if (ntypes != 1)
errs++;
if (combiner != MPI_COMBINER_VECTOR)
errs++;
if (verbose) {
if (nints != 3)
fprintf(stderr, "nints = %d; should be 3\n", nints);
if (nadds != 0)
fprintf(stderr, "nadds = %d; should be 0\n", nadds);
if (ntypes != 1)
fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
if (combiner != MPI_COMBINER_VECTOR)
fprintf(stderr, "combiner = %s; should be vector\n", combiner_to_string(combiner));
}
ints = malloc(nints * sizeof(*ints));
if (nadds)
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != 10)
errs++;
if (ints[1] != 2)
errs++;
if (ints[2] != 2)
errs++;
if (types[0] != MPI_INT)
errs++;
if (verbose) {
if (ints[0] != 10)
fprintf(stderr, "count = %d; should be 10\n", ints[0]);
if (ints[1] != 2)
fprintf(stderr, "blocklength = %d; should be 2\n", ints[1]);
if (ints[2] != 2)
fprintf(stderr, "stride = %d; should be 2\n", ints[2]);
if (types[0] != MPI_INT)
fprintf(stderr, "type is not MPI_INT\n");
}
free(ints);
if (nadds)
free(adds);
free(types);
MPI_Type_free(&parent_type);
return errs;
}
/* indexed_of_basics_test(void)
*
* Simple indexed type.
*
* Returns number of errors encountered.
*/
int indexed_of_basics_test(void)
{
MPI_Datatype parent_type;
int s_count = 3, s_blocklengths[3] = { 3, 2, 1 };
int s_displacements[3] = { 10, 20, 30 };
int nints, nadds, ntypes, combiner, *ints;
MPI_Aint *adds = NULL;
MPI_Datatype *types;
int errs = 0;
/* set up type */
MPI_Type_indexed(s_count, s_blocklengths, s_displacements, MPI_INT, &parent_type);
/* decode */
MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
if (nints != 7)
errs++;
if (nadds != 0)
errs++;
if (ntypes != 1)
errs++;
if (combiner != MPI_COMBINER_INDEXED)
errs++;
if (verbose) {
if (nints != 7)
fprintf(stderr, "nints = %d; should be 7\n", nints);
if (nadds != 0)
fprintf(stderr, "nadds = %d; should be 0\n", nadds);
if (ntypes != 1)
fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
if (combiner != MPI_COMBINER_INDEXED)
fprintf(stderr, "combiner = %s; should be indexed\n", combiner_to_string(combiner));
}
ints = malloc(nints * sizeof(*ints));
if (nadds)
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != s_count)
errs++;
if (ints[1] != s_blocklengths[0])
errs++;
if (ints[2] != s_blocklengths[1])
errs++;
if (ints[3] != s_blocklengths[2])
errs++;
if (ints[4] != s_displacements[0])
errs++;
if (ints[5] != s_displacements[1])
errs++;
if (ints[6] != s_displacements[2])
errs++;
if (types[0] != MPI_INT)
errs++;
if (verbose) {
if (ints[0] != s_count)
fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
if (ints[1] != s_blocklengths[0])
fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
if (ints[2] != s_blocklengths[1])
fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
if (ints[3] != s_blocklengths[2])
fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
if (ints[4] != s_displacements[0])
fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], s_displacements[0]);
if (ints[5] != s_displacements[1])
fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], s_displacements[1]);
if (ints[6] != s_displacements[2])
fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], s_displacements[2]);
if (types[0] != MPI_INT)
fprintf(stderr, "type[0] does not match\n");
}
free(ints);
if (nadds)
free(adds);
free(types);
MPI_Type_free(&parent_type);
return errs;
}
/* indexed_of_vectors_test()
*
* Builds an indexed type of vectors of ints.
*
* Returns the number of errors encountered.
*/
int indexed_of_vectors_test(void)
{
MPI_Datatype inner_vector, inner_vector_copy;
MPI_Datatype outer_indexed;
int i_count = 3, i_blocklengths[3] = { 3, 2, 1 };
int i_displacements[3] = { 10, 20, 30 };
int nints, nadds, ntypes, combiner, *ints;
MPI_Aint *adds = NULL;
MPI_Datatype *types;
int err, errs = 0;
/* set up type */
err = MPI_Type_vector(2, 1, 2, MPI_INT, &inner_vector);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
err = MPI_Type_indexed(i_count, i_blocklengths, i_displacements, inner_vector, &outer_indexed);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
/* decode outer vector (get envelope, then contents) */
err = MPI_Type_get_envelope(outer_indexed, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
if (nints != 7)
errs++;
if (nadds != 0)
errs++;
if (ntypes != 1)
errs++;
if (combiner != MPI_COMBINER_INDEXED)
errs++;
if (verbose) {
if (nints != 7)
fprintf(stderr, "nints = %d; should be 7\n", nints);
if (nadds != 0)
fprintf(stderr, "nadds = %d; should be 0\n", nadds);
if (ntypes != 1)
fprintf(stderr, "ntypes = %d; should be 1\n", ntypes);
if (combiner != MPI_COMBINER_INDEXED)
fprintf(stderr, "combiner = %s; should be indexed\n", combiner_to_string(combiner));
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
ints = malloc(nints * sizeof(*ints));
if (nadds)
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
/* get contents of outer vector */
err = MPI_Type_get_contents(outer_indexed, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != i_count)
errs++;
if (ints[1] != i_blocklengths[0])
errs++;
if (ints[2] != i_blocklengths[1])
errs++;
if (ints[3] != i_blocklengths[2])
errs++;
if (ints[4] != i_displacements[0])
errs++;
if (ints[5] != i_displacements[1])
errs++;
if (ints[6] != i_displacements[2])
errs++;
if (verbose) {
if (ints[0] != i_count)
fprintf(stderr, "count = %d; should be %d\n", ints[0], i_count);
if (ints[1] != i_blocklengths[0])
fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], i_blocklengths[0]);
if (ints[2] != i_blocklengths[1])
fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], i_blocklengths[1]);
if (ints[3] != i_blocklengths[2])
fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], i_blocklengths[2]);
if (ints[4] != i_displacements[0])
fprintf(stderr, "displacement[0] = %d; should be %d\n", ints[4], i_displacements[0]);
if (ints[5] != i_displacements[1])
fprintf(stderr, "displacement[1] = %d; should be %d\n", ints[5], i_displacements[1]);
if (ints[6] != i_displacements[2])
fprintf(stderr, "displacement[2] = %d; should be %d\n", ints[6], i_displacements[2]);
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
inner_vector_copy = types[0];
free(ints);
if (nadds)
free(adds);
free(types);
/* decode inner vector */
err = MPI_Type_get_envelope(inner_vector_copy, &nints, &nadds, &ntypes, &combiner);
if (err != MPI_SUCCESS) {
if (verbose)
fprintf(stderr, "error in MPI call; aborting after %d errors\n", errs + 1);
return errs + 1;
}
if (nints != 3)
errs++;
if (nadds != 0)
errs++;
if (ntypes != 1)
errs++;
if (combiner != MPI_COMBINER_VECTOR)
errs++;
if (verbose) {
if (nints != 3)
fprintf(stderr, "inner vector nints = %d; should be 3\n", nints);
if (nadds != 0)
fprintf(stderr, "inner vector nadds = %d; should be 0\n", nadds);
if (ntypes != 1)
fprintf(stderr, "inner vector ntypes = %d; should be 1\n", ntypes);
if (combiner != MPI_COMBINER_VECTOR)
fprintf(stderr, "inner vector combiner = %s; should be vector\n",
combiner_to_string(combiner));
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
ints = malloc(nints * sizeof(*ints));
if (nadds)
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
err = MPI_Type_get_contents(inner_vector_copy, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != 2)
errs++;
if (ints[1] != 1)
errs++;
if (ints[2] != 2)
errs++;
if (verbose) {
if (ints[0] != 2)
fprintf(stderr, "inner vector count = %d; should be 2\n", ints[0]);
if (ints[1] != 1)
fprintf(stderr, "inner vector blocklength = %d; should be 1\n", ints[1]);
if (ints[2] != 2)
fprintf(stderr, "inner vector stride = %d; should be 2\n", ints[2]);
}
if (errs) {
if (verbose)
fprintf(stderr, "aborting after %d errors\n", errs);
return errs;
}
free(ints);
if (nadds)
free(adds);
free(types);
MPI_Type_free(&inner_vector_copy);
MPI_Type_free(&inner_vector);
MPI_Type_free(&outer_indexed);
return MTestReturnValue(errs);
}
#ifdef HAVE_MPI_TYPE_CREATE_STRUCT
/* struct_of_basics_test(void)
*
* There's nothing simple about structs :). Although this is an easy one.
*
* Returns number of errors encountered.
*
* NOT TESTED.
*/
int struct_of_basics_test(void)
{
MPI_Datatype parent_type;
int s_count = 3, s_blocklengths[3] = { 3, 2, 1 };
MPI_Aint s_displacements[3] = { 10, 20, 30 };
MPI_Datatype s_types[3] = { MPI_CHAR, MPI_INT, MPI_FLOAT };
int nints, nadds, ntypes, combiner, *ints;
MPI_Aint *adds = NULL;
MPI_Datatype *types;
int err, errs = 0;
/* set up type */
err = MPI_Type_create_struct(s_count, s_blocklengths, s_displacements, s_types, &parent_type);
/* decode */
err = MPI_Type_get_envelope(parent_type, &nints, &nadds, &ntypes, &combiner);
if (nints != 4)
errs++;
if (nadds != 3)
errs++;
if (ntypes != 3)
errs++;
if (combiner != MPI_COMBINER_STRUCT)
errs++;
if (verbose) {
if (nints != 4)
fprintf(stderr, "nints = %d; should be 3\n", nints);
if (nadds != 3)
fprintf(stderr, "nadds = %d; should be 0\n", nadds);
if (ntypes != 3)
fprintf(stderr, "ntypes = %d; should be 3\n", ntypes);
if (combiner != MPI_COMBINER_STRUCT)
fprintf(stderr, "combiner = %s; should be struct\n", combiner_to_string(combiner));
}
ints = malloc(nints * sizeof(*ints));
adds = malloc(nadds * sizeof(*adds));
types = malloc(ntypes * sizeof(*types));
err = MPI_Type_get_contents(parent_type, nints, nadds, ntypes, ints, adds, types);
if (ints[0] != s_count)
errs++;
if (ints[1] != s_blocklengths[0])
errs++;
if (ints[2] != s_blocklengths[1])
errs++;
if (ints[3] != s_blocklengths[2])
errs++;
if (adds[0] != s_displacements[0])
errs++;
if (adds[1] != s_displacements[1])
errs++;
if (adds[2] != s_displacements[2])
errs++;
if (types[0] != s_types[0])
errs++;
if (types[1] != s_types[1])
errs++;
if (types[2] != s_types[2])
errs++;
if (verbose) {
if (ints[0] != s_count)
fprintf(stderr, "count = %d; should be %d\n", ints[0], s_count);
if (ints[1] != s_blocklengths[0])
fprintf(stderr, "blocklength[0] = %d; should be %d\n", ints[1], s_blocklengths[0]);
if (ints[2] != s_blocklengths[1])
fprintf(stderr, "blocklength[1] = %d; should be %d\n", ints[2], s_blocklengths[1]);
if (ints[3] != s_blocklengths[2])
fprintf(stderr, "blocklength[2] = %d; should be %d\n", ints[3], s_blocklengths[2]);
if (adds[0] != s_displacements[0])
fprintf(stderr, "displacement[0] = %d; should be %d\n", adds[0], s_displacements[0]);
if (adds[1] != s_displacements[1])
fprintf(stderr, "displacement[1] = %d; should be %d\n", adds[1], s_displacements[1]);
if (adds[2] != s_displacements[2])
fprintf(stderr, "displacement[2] = %d; should be %d\n", adds[2], s_displacements[2]);
if (types[0] != s_types[0])
fprintf(stderr, "type[0] does not match\n");
if (types[1] != s_types[1])
fprintf(stderr, "type[1] does not match\n");
if (types[2] != s_types[2])
fprintf(stderr, "type[2] does not match\n");
}
free(ints);
free(adds);
free(types);
MPI_Type_free(&parent_type);
return errs;
}
#endif
/* combiner_to_string(combiner)
*
* Converts a numeric combiner into a pointer to a string used for printing.
*/
char *combiner_to_string(int combiner)
{
static char c_named[] = "named";
static char c_contig[] = "contig";
static char c_vector[] = "vector";
static char c_hvector[] = "hvector";
static char c_indexed[] = "indexed";
static char c_hindexed[] = "hindexed";
static char c_struct[] = "struct";
#ifdef HAVE_MPI2_COMBINERS
static char c_dup[] = "dup";
static char c_hvector_integer[] = "hvector_integer";
static char c_hindexed_integer[] = "hindexed_integer";
static char c_indexed_block[] = "indexed_block";
static char c_struct_integer[] = "struct_integer";
static char c_subarray[] = "subarray";
static char c_darray[] = "darray";
static char c_f90_real[] = "f90_real";
static char c_f90_complex[] = "f90_complex";
static char c_f90_integer[] = "f90_integer";
static char c_resized[] = "resized";
#endif
if (combiner == MPI_COMBINER_NAMED)
return c_named;
if (combiner == MPI_COMBINER_CONTIGUOUS)
return c_contig;
if (combiner == MPI_COMBINER_VECTOR)
return c_vector;
if (combiner == MPI_COMBINER_HVECTOR)
return c_hvector;
if (combiner == MPI_COMBINER_INDEXED)
return c_indexed;
if (combiner == MPI_COMBINER_HINDEXED)
return c_hindexed;
if (combiner == MPI_COMBINER_STRUCT)
return c_struct;
#ifdef HAVE_MPI2_COMBINERS
if (combiner == MPI_COMBINER_DUP)
return c_dup;
if (combiner == MPI_COMBINER_HVECTOR_INTEGER)
return c_hvector_integer;
if (combiner == MPI_COMBINER_HINDEXED_INTEGER)
return c_hindexed_integer;
if (combiner == MPI_COMBINER_INDEXED_BLOCK)
return c_indexed_block;
if (combiner == MPI_COMBINER_STRUCT_INTEGER)
return c_struct_integer;
if (combiner == MPI_COMBINER_SUBARRAY)
return c_subarray;
if (combiner == MPI_COMBINER_DARRAY)
return c_darray;
if (combiner == MPI_COMBINER_F90_REAL)
return c_f90_real;
if (combiner == MPI_COMBINER_F90_COMPLEX)
return c_f90_complex;
if (combiner == MPI_COMBINER_F90_INTEGER)
return c_f90_integer;
if (combiner == MPI_COMBINER_RESIZED)
return c_resized;
#endif
return NULL;
}
int parse_args(int argc, char **argv)
{
#ifdef HAVE_GET_OPT
int ret;
while ((ret = getopt(argc, argv, "v")) >= 0) {
switch (ret) {
case 'v':
verbose = 1;
break;
}
}
#else
#endif
return 0;
}
|