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
|
/* -*- Mode: C; c-basic-offset:4 ; indent-tabs-mode:nil -*- */
/*
* Copyright (c) 2020-2022 Bull S.A.S. All rights reserved.
* Copyright (c) 2021 Triad National Security, LLC. All rights
* reserved.
* Copyright (c) 2022 IBM Corporation. All rights reserved
*
* $COPYRIGHT$
*
* Additional copyrights may follow
*
* $HEADER$
*/
/*
* @file
* This files contains all functions to dynamically select for each collective
* the coll module based on given MCA parameters, configuration file and
* messages characteristics
*/
#include "opal/class/opal_list.h"
#include "ompi/mca/coll/han/coll_han.h"
#include "ompi/mca/coll/han/coll_han_dynamic.h"
#include "ompi/mca/coll/han/coll_han_algorithms.h"
#include "ompi/mca/coll/base/coll_base_util.h"
/*
* Tests if a dynamic collective is implemented
* Useful for file reading warnings and MCA parameter generation
* When a new dynamic collective is implemented, this function must
* return true for it
*/
bool mca_coll_han_is_coll_dynamic_implemented(COLLTYPE_T coll_id)
{
switch (coll_id) {
case ALLGATHER:
case ALLGATHERV:
case ALLREDUCE:
case BARRIER:
case BCAST:
case GATHER:
case REDUCE:
case SCATTER:
return true;
default:
return false;
}
}
COMPONENT_T
mca_coll_han_component_name_to_id(const char* name)
{
if(NULL == name) {
return -1;
}
for( int i = SELF; i < COMPONENTS_COUNT ; i++ ) {
if (0 == strcmp(name, ompi_coll_han_available_components[i].component_name)) {
return i;
}
}
return -1;
}
/*
* Get all the collective modules initialized on this communicator
* This function must be called at the start of every selector implementation
* Note that han module may be not yet enabled
*/
int
mca_coll_han_get_all_coll_modules(struct ompi_communicator_t *comm,
mca_coll_han_module_t *han_module)
{
mca_coll_base_module_t *han_base_module = (mca_coll_base_module_t *) han_module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
int nb_modules = 0;
mca_coll_base_avail_coll_t *item;
/* If the modules are get yet, return success */
if(han_module->storage_initialized) {
return OMPI_SUCCESS;
}
/* This list is populated at communicator creation */
OPAL_LIST_FOREACH(item,
comm->c_coll->module_list,
mca_coll_base_avail_coll_t) {
mca_coll_base_module_t *module = item->ac_module;
const char *name = item->ac_component_name;
int id = mca_coll_han_component_name_to_id(name);
if(id >= 0 && NULL != module && module != han_base_module) {
/*
* The identifier is correct
* Store the module
*/
han_module->modules_storage.modules[id].module_handler = module;
opal_output_verbose(80, mca_coll_han_component.han_output,
"coll:han:get_all_coll_modules HAN found module %s with id %d "
"for topological level %d (%s) for communicator (%s/%s)\n",
name, id, topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
nb_modules++;
}
}
/*
* Add han_module on global communicator only
* to prevent any recursive call
*/
if(GLOBAL_COMMUNICATOR == han_module->topologic_level) {
han_module->modules_storage.modules[HAN].module_handler = han_base_module;
nb_modules++;
}
opal_output_verbose(60, mca_coll_han_component.han_output,
"coll:han:get_all_coll_modules HAN sub-communicator modules storage "
"for topological level %d (%s) gets %d modules "
"for communicator (%s/%s)\n",
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
nb_modules, ompi_comm_print_cid(comm), comm->c_name);
assert(0 != nb_modules);
/* The modules are get */
han_module->storage_initialized = true;
return OMPI_SUCCESS;
}
/*
* Find the correct rule in the dynamic rules
* Assume rules are sorted by increasing value
*/
static const msg_size_rule_t*
get_dynamic_rule(COLLTYPE_T collective,
size_t msg_size,
struct ompi_communicator_t *comm,
mca_coll_han_module_t *han_module)
{
/* Indexes of the rule */
int coll_idx, topo_idx;
int conf_idx, msg_size_idx;
/* Aliases */
const mca_coll_han_dynamic_rules_t *dynamic_rules;
const collective_rule_t *coll_rule = NULL;
const topologic_rule_t *topo_rule = NULL;
const configuration_rule_t *conf_rule = NULL;
const msg_size_rule_t *msg_size_rule = NULL;
const TOPO_LVL_T topo_lvl = han_module->topologic_level;
const int comm_size = ompi_comm_size(comm);
COMPONENT_T component;
/* Find the collective rule */
dynamic_rules = &(mca_coll_han_component.dynamic_rules);
for(coll_idx = dynamic_rules->nb_collectives-1;
coll_idx >= 0; coll_idx--) {
if(dynamic_rules->collective_rules[coll_idx].collective_id == collective) {
coll_rule = &(dynamic_rules->collective_rules[coll_idx]);
break;
}
}
if(coll_idx < 0 || NULL == coll_rule) {
/* No dynamic rules for this collective */
opal_output_verbose(60, mca_coll_han_component.han_output,
"coll:han:get_dynamic_rule HAN searched for collective %d (%s) "
"but did not find any rule for this collective\n",
collective, mca_coll_base_colltype_to_str(collective));
return NULL;
}
/* Find the topologic level rule */
for(topo_idx = coll_rule->nb_topologic_levels-1;
topo_idx >= 0; topo_idx--) {
if(coll_rule->topologic_rules[topo_idx].topologic_level == topo_lvl) {
topo_rule = &(coll_rule->topologic_rules[topo_idx]);
break;
}
}
if(topo_idx < 0 || NULL == topo_rule) {
/* No topologic level rules for this collective */
opal_output_verbose(60, mca_coll_han_component.han_output,
"coll:han:get_dynamic_rule HAN searched for topologic level %d (%s) rule "
"for collective %d (%s) but did not find any rule\n",
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
collective, mca_coll_base_colltype_to_str(collective));
return NULL;
}
/* Find the configuration rule */
for(conf_idx = topo_rule->nb_rules-1;
conf_idx >= 0; conf_idx--) {
if(topo_rule->configuration_rules[conf_idx].configuration_size <= comm_size) {
conf_rule = &(topo_rule->configuration_rules[conf_idx]);
break;
}
}
if(conf_idx < 0 || NULL == conf_rule) {
/* No corresponding configuration. Should not have happen with a correct file */
opal_output_verbose(60, mca_coll_han_component.han_output,
"coll:han:get_dynamic_rule HAN searched a rule for collective %d (%s) "
"on topological level %d (%s) for a %d configuration size "
"but did not manage to find anything. "
"This is the result of an invalid configuration file: "
"the first configuration size of each collective must be 1\n",
collective, mca_coll_base_colltype_to_str(collective),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl), comm_size);
return NULL;
}
/* Find the message size rule */
for(msg_size_idx = conf_rule->nb_msg_size-1;
msg_size_idx >= 0; msg_size_idx--) {
if(conf_rule->msg_size_rules[msg_size_idx].msg_size <= msg_size) {
msg_size_rule = &(conf_rule->msg_size_rules[msg_size_idx]);
break;
}
}
if(msg_size_idx < 0 || NULL == msg_size_rule) {
/* No corresponding message size. Should not happen with a correct file */
opal_output_verbose(60, mca_coll_han_component.han_output,
"coll:han:get_dynamic_rule HAN searched a rule for collective %d (%s) "
"on topological level %d (%s) for a %d configuration size "
"for a %" PRIsize_t " sized message but did not manage to find anything. "
"This is the result of an invalid configuration file: "
"the first message size of each configuration must be 0\n",
collective, mca_coll_base_colltype_to_str(collective),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
comm_size, msg_size);
return NULL;
}
component = msg_size_rule->component;
/*
* We have the final rule to use
* Module correctness is checked outside
*/
opal_output_verbose(80, mca_coll_han_component.han_output,
"coll:han:get_dynamic_rule HAN searched a rule for collective %d (%s) "
"on topological level %d (%s) for a %d configuration size "
"for a %" PRIsize_t " sized message. Found a rule for collective %d (%s) "
"on topological level %d (%s) for a %d configuration size "
"for a %" PRIsize_t " sized message : component %d (%s)\n",
collective, mca_coll_base_colltype_to_str(collective),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
comm_size, msg_size, msg_size_rule->collective_id,
mca_coll_base_colltype_to_str(msg_size_rule->collective_id),
msg_size_rule->topologic_level,
mca_coll_han_topo_lvl_to_str(msg_size_rule->topologic_level),
msg_size_rule->configuration_size,
msg_size_rule->msg_size, component, ompi_coll_han_available_components[component].component_name);
return msg_size_rule;
}
/*
* Return the module to use for the collective coll_id
* for a msg_size sized message on the comm communicator
* following the dynamic rules
*/
static mca_coll_base_module_t*
get_module(COLLTYPE_T coll_id,
size_t msg_size,
struct ompi_communicator_t *comm,
mca_coll_han_module_t *han_module)
{
const msg_size_rule_t *dynamic_rule;
TOPO_LVL_T topo_lvl;
COMPONENT_T mca_rule_component;
topo_lvl = han_module->topologic_level;
mca_rule_component = mca_coll_han_component.mca_sub_components[coll_id][topo_lvl];
mca_coll_han_get_all_coll_modules(comm, han_module);
/* Find the correct dynamic rule to check */
dynamic_rule = get_dynamic_rule(coll_id,
msg_size,
comm,
han_module);
if(NULL != dynamic_rule) {
/* Use dynamic rule from file */
return han_module->modules_storage.modules[dynamic_rule->component].module_handler;
}
/*
* No dynamic rule from file
* Use rule from mca parameter
*/
if(mca_rule_component < 0 || mca_rule_component >= COMPONENTS_COUNT) {
/*
* Invalid MCA parameter value
* Warn the user and return NULL
*/
opal_output_verbose(0, mca_coll_han_component.han_output,
"coll:han:get_module Invalid MCA parameter value %d "
"for collective %d (%s) on topologic level %d (%s)\n",
mca_rule_component, coll_id,
mca_coll_base_colltype_to_str(coll_id),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl));
return NULL;
}
return han_module->modules_storage.modules[mca_rule_component].module_handler;
}
/*
* whether OMPI_MCA_coll_han_use_xxx_algorithm was set by user
*/
static bool
han_algorithm_is_user_provided(COLLTYPE_T coll_id) {
const int *value = NULL;
mca_base_var_source_t source;
mca_base_var_get_value(mca_coll_han_component.use_algorithm_param[coll_id],
&value, &source, NULL);
return (MCA_BASE_VAR_SOURCE_DEFAULT != source);
}
/*
* Return the algorithm to use for the collective coll_id
* for a msg_size sized message on the comm communicator
* following the dynamic rules
*/
static int
get_algorithm(COLLTYPE_T coll_id,
size_t msg_size,
struct ompi_communicator_t *comm,
mca_coll_han_module_t *han_module)
{
int algorithm_id = -1;
int rank = ompi_comm_rank(comm);
algorithm_id = mca_coll_han_component.use_algorithm[coll_id];
if (!han_algorithm_is_user_provided(coll_id)) {
/* find the correct dynamic rule to check */
const msg_size_rule_t *dynamic_rule = get_dynamic_rule(coll_id,
msg_size,
comm,
han_module);
if(NULL != dynamic_rule && dynamic_rule->algorithm_id >= 0) {
/* Use dynamic rule from file */
algorithm_id = dynamic_rule->algorithm_id;
} else {
/*
* No dynamic rule from file
* Use default behaviour
*/
algorithm_id = 0;
}
}
if ( 0 == rank ) {
opal_output_verbose(1, mca_coll_han_component.han_output,
"coll:han:get_algorithm %s size:%ld algorithm:%d %s",
mca_coll_base_colltype_to_str(coll_id),
msg_size,
algorithm_id,
mca_coll_han_algorithm_id_to_name(coll_id, algorithm_id));
}
return algorithm_id;
}
/*
* Allgather selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_allgather_intra_dynamic(const void *sbuf, int scount,
struct ompi_datatype_t *sdtype,
void *rbuf, int rcount,
struct ompi_datatype_t *rdtype,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_allgather_fn_t allgather;
mca_coll_base_module_t *sub_module;
size_t dtype_size;
int rank, verbosity = 0;
/* Compute configuration information for dynamic rules */
if( MPI_IN_PLACE != sbuf ) {
ompi_datatype_type_size(sdtype, &dtype_size);
dtype_size = dtype_size * scount;
} else {
ompi_datatype_type_size(rdtype, &dtype_size);
dtype_size = dtype_size * rcount;
}
sub_module = get_module(ALLGATHER,
dtype_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allgather_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
ALLGATHER, mca_coll_base_colltype_to_str(ALLGATHER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/ALLGATHER: No module found for the sub-communicator. "
"Falling back to another component\n"));
allgather = han_module->previous_allgather;
sub_module = han_module->previous_allgather_module;
} else if (NULL == sub_module->coll_allgather) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allgather_intra_dynamic HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
ALLGATHER, mca_coll_base_colltype_to_str(ALLGATHER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/ALLGATHER: the module found for the sub-communicator"
" cannot handle the ALLGATHER operation. Falling back to another component\n"));
allgather = han_module->previous_allgather;
sub_module = han_module->previous_allgather_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_allgather is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(ALLGATHER,
dtype_size,
comm,
han_module);
allgather = (mca_coll_base_module_allgather_fn_t)mca_coll_han_algorithm_id_to_fn(ALLGATHER, algorithm_id);
if (NULL == allgather) { /* default behaviour */
if(mca_coll_han_component.use_simple_algorithm[ALLGATHER]) {
allgather = mca_coll_han_allgather_intra_simple;
} else {
allgather = mca_coll_han_allgather_intra;
}
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_allgather is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
allgather = sub_module->coll_allgather;
}
return allgather(sbuf, scount, sdtype,
rbuf, rcount, rdtype,
comm,
sub_module);
}
/*
* Allgatherv selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
* The allgatherv size is the size of the biggest segment
*/
int
mca_coll_han_allgatherv_intra_dynamic(const void *sbuf, int scount,
struct ompi_datatype_t *sdtype,
void *rbuf, const int *rcounts,
const int *displs,
struct ompi_datatype_t *rdtype,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_allgatherv_fn_t allgatherv;
int rank, verbosity = 0, comm_size, i;
mca_coll_base_module_t *sub_module;
size_t dtype_size, msg_size = 0;
/* Compute configuration information for dynamic rules */
comm_size = ompi_comm_size(comm);
ompi_datatype_type_size(rdtype, &dtype_size);
for(i = 0; i < comm_size; i++) {
if(dtype_size * rcounts[i] > msg_size) {
msg_size = dtype_size * rcounts[i];
}
}
sub_module = get_module(ALLGATHERV,
msg_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allgatherv_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
ALLGATHERV, mca_coll_base_colltype_to_str(ALLGATHERV),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/ALLGATHERV: No module found for the sub-communicator. "
"Falling back to another component\n"));
allgatherv = han_module->previous_allgatherv;
sub_module = han_module->previous_allgatherv_module;
} else if (NULL == sub_module->coll_allgatherv) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allgatherv_intra_dynamic "
"HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
ALLGATHERV, mca_coll_base_colltype_to_str(ALLGATHERV),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/ALLGATHERV: the module found for the sub-"
"communicator cannot handle the ALLGATHERV operation. "
"Falling back to another component\n"));
allgatherv = han_module->previous_allgatherv;
sub_module = han_module->previous_allgatherv_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_allgatherv is valid and point to this function
* Call han topological collective algorithm
*/
opal_output_verbose(30, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allgatherv_intra_dynamic "
"HAN used for collective %d (%s) with topological level %d (%s) "
"on communicator (%s/%s) but this module cannot handle "
"this collective on this topologic level\n",
ALLGATHERV, mca_coll_base_colltype_to_str(ALLGATHERV),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
allgatherv = han_module->previous_allgatherv;
sub_module = han_module->previous_allgatherv_module;
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_allgatherv is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
allgatherv = sub_module->coll_allgatherv;
}
return allgatherv(sbuf, scount, sdtype,
rbuf, rcounts, displs,
rdtype, comm,
sub_module);
}
/*
* Allreduce selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_allreduce_intra_dynamic(const void *sbuf,
void *rbuf,
int count,
struct ompi_datatype_t *dtype,
struct ompi_op_t *op,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_allreduce_fn_t allreduce;
mca_coll_base_module_t *sub_module;
size_t dtype_size;
int rank, verbosity = 0;
if (!han_module->enabled) {
return han_module->previous_allreduce(sbuf, rbuf, count, dtype, op, comm,
han_module->previous_allreduce_module);
}
/* Compute configuration information for dynamic rules */
ompi_datatype_type_size(dtype, &dtype_size);
dtype_size = dtype_size * count;
sub_module = get_module(ALLREDUCE,
dtype_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allreduce_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
ALLREDUCE, mca_coll_base_colltype_to_str(ALLREDUCE),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/ALLREDUCE: No module found for the sub-communicator. "
"Falling back to another component\n"));
allreduce = han_module->previous_allreduce;
sub_module = han_module->previous_allreduce_module;
} else if (NULL == sub_module->coll_allreduce) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_allreduce_intra_dynamic "
"HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
ALLREDUCE, mca_coll_base_colltype_to_str(ALLREDUCE),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/ALLREDUCE: the module found for the sub-"
"communicator cannot handle the ALLREDUCE operation. "
"Falling back to another component\n"));
allreduce = han_module->previous_allreduce;
sub_module = han_module->previous_allreduce_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/* Reproducibility: fallback on reproducible algorithm */
if (mca_coll_han_component.han_reproducible) {
allreduce = mca_coll_han_allreduce_reproducible;
} else {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_allreduce is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(ALLREDUCE, dtype_size, comm, han_module);
allreduce = (mca_coll_base_module_allreduce_fn_t) mca_coll_han_algorithm_id_to_fn(ALLREDUCE, algorithm_id);
if (NULL == allreduce) { /* default behaviour */
if(mca_coll_han_component.use_simple_algorithm[ALLREDUCE]) {
allreduce = mca_coll_han_allreduce_intra_simple;
} else {
allreduce = mca_coll_han_allreduce_intra;
}
}
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_allreduce is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
allreduce = sub_module->coll_allreduce;
}
return allreduce(sbuf, rbuf, count, dtype,
op, comm, sub_module);
}
/*
* Barrier selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_barrier_intra_dynamic(struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_barrier_fn_t barrier;
mca_coll_base_module_t *sub_module;
int rank, verbosity = 0;
if (!han_module->enabled) {
return han_module->previous_barrier(comm, han_module->previous_barrier_module);
}
/* Compute configuration information for dynamic rules */
sub_module = get_module(BARRIER,
0,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_barrier_intra_dynamic "
"Han did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
BARRIER, mca_coll_base_colltype_to_str(BARRIER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/BARRIER: No module found for the sub-communicator. "
"Falling back to another component\n"));
barrier = han_module->previous_barrier;
sub_module = han_module->previous_barrier_module;
} else if (NULL == sub_module->coll_barrier) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_barrier_intra_dynamic "
"Han found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
BARRIER, mca_coll_base_colltype_to_str(BARRIER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/BARRIER: the module found for the sub-"
"communicator cannot handle the BARRIER operation. "
"Falling back to another component\n"));
barrier = han_module->previous_barrier;
sub_module = han_module->previous_barrier_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_barrier is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(BARRIER, 0, comm, han_module);
barrier = (mca_coll_base_module_barrier_fn_t) mca_coll_han_algorithm_id_to_fn(BARRIER, algorithm_id);
if (NULL == barrier) { /* default behaviour*/
barrier = mca_coll_han_barrier_intra_simple;
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_barrier is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
barrier = sub_module->coll_barrier;
}
return barrier(comm, sub_module);
}
/*
* Bcast selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_bcast_intra_dynamic(void *buff,
int count,
struct ompi_datatype_t *dtype,
int root,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_bcast_fn_t bcast;
mca_coll_base_module_t *sub_module;
size_t dtype_size;
int rank, verbosity = 0;
if (!han_module->enabled) {
return han_module->previous_bcast(buff, count, dtype, root, comm,
han_module->previous_bcast_module);
}
/* Compute configuration information for dynamic rules */
ompi_datatype_type_size(dtype, &dtype_size);
dtype_size = dtype_size * count;
sub_module = get_module(BCAST,
dtype_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_bcast_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
BCAST, mca_coll_base_colltype_to_str(BCAST),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/BCAST: No module found for the sub-communicator. "
"Falling back to another component\n"));
bcast = han_module->previous_bcast;
sub_module = han_module->previous_bcast_module;
} else if (NULL == sub_module->coll_bcast) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_bcast_intra_dynamic "
"HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
BCAST, mca_coll_base_colltype_to_str(BCAST),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/BCAST: the module found for the sub-"
"communicator cannot handle the BCAST operation. "
"Falling back to another component\n"));
bcast = han_module->previous_bcast;
sub_module = han_module->previous_bcast_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_bcast is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(BCAST,
dtype_size,
comm,
han_module);
bcast = (mca_coll_base_module_bcast_fn_t)mca_coll_han_algorithm_id_to_fn(BCAST, algorithm_id);
if (NULL == bcast) { /* default behaviour */
if(mca_coll_han_component.use_simple_algorithm[BCAST]) {
bcast = mca_coll_han_bcast_intra_simple;
} else {
bcast = mca_coll_han_bcast_intra;
}
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_bcast is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
bcast = sub_module->coll_bcast;
}
return bcast(buff, count, dtype,
root, comm, sub_module);
}
/*
* Gather selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_gather_intra_dynamic(const void *sbuf, int scount,
struct ompi_datatype_t *sdtype,
void *rbuf, int rcount,
struct ompi_datatype_t *rdtype,
int root,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_gather_fn_t gather;
mca_coll_base_module_t *sub_module;
size_t dtype_size;
int rank, verbosity = 0;
if (!han_module->enabled) {
return han_module->previous_gather(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm,
han_module->previous_gather_module);
}
/* Compute configuration information for dynamic rules */
if( MPI_IN_PLACE != sbuf ) {
ompi_datatype_type_size(sdtype, &dtype_size);
dtype_size = dtype_size * scount;
} else {
ompi_datatype_type_size(rdtype, &dtype_size);
dtype_size = dtype_size * rcount;
}
sub_module = get_module(GATHER,
dtype_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_gather_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
GATHER, mca_coll_base_colltype_to_str(GATHER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/GATHER: No module found for the sub-communicator. "
"Falling back to another component\n"));
gather = han_module->previous_gather;
sub_module = han_module->previous_gather_module;
} else if (NULL == sub_module->coll_gather) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_gather_intra_dynamic "
"HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
GATHER, mca_coll_base_colltype_to_str(GATHER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/GATHER: the module found for the sub-"
"communicator cannot handle the GATHER operation. "
"Falling back to another component\n"));
gather = han_module->previous_gather;
sub_module = han_module->previous_gather_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_gather is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(GATHER,
dtype_size,
comm,
han_module);
gather = (mca_coll_base_module_gather_fn_t) mca_coll_han_algorithm_id_to_fn(GATHER, algorithm_id);
if (NULL == gather) { /* default behaviour */
if(mca_coll_han_component.use_simple_algorithm[GATHER]) {
gather = mca_coll_han_gather_intra_simple;
} else {
gather = mca_coll_han_gather_intra;
}
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_gather is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
gather = sub_module->coll_gather;
}
return gather(sbuf, scount, sdtype,
rbuf, rcount, rdtype,
root, comm,
sub_module);
}
/*
* Reduce selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_reduce_intra_dynamic(const void *sbuf,
void *rbuf,
int count,
struct ompi_datatype_t *dtype,
struct ompi_op_t *op,
int root,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_reduce_fn_t reduce;
mca_coll_base_module_t *sub_module;
size_t dtype_size;
int rank, verbosity = 0;
if (!han_module->enabled) {
return han_module->previous_reduce(sbuf, rbuf, count, dtype, op, root, comm,
han_module->previous_reduce_module);
}
/* Compute configuration information for dynamic rules */
ompi_datatype_type_size(dtype, &dtype_size);
dtype_size = dtype_size * count;
sub_module = get_module(REDUCE,
dtype_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_reduce_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
REDUCE, mca_coll_base_colltype_to_str(REDUCE),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/REDUCE: No module found for the sub-communicator. "
"Falling back to another component\n"));
reduce = han_module->previous_reduce;
sub_module = han_module->previous_reduce_module;
} else if (NULL == sub_module->coll_reduce) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_reduce_intra_dynamic "
"HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
REDUCE, mca_coll_base_colltype_to_str(REDUCE),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/REDUCE: the module found for the sub-"
"communicator cannot handle the REDUCE operation. "
"Falling back to another component\n"));
reduce = han_module->previous_reduce;
sub_module = han_module->previous_reduce_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/* Reproducibility: fallback on reproducible algorithm */
if (mca_coll_han_component.han_reproducible) {
reduce = mca_coll_han_reduce_reproducible;
} else {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_reduce is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(REDUCE,
dtype_size,
comm,
han_module);
reduce = (mca_coll_base_module_reduce_fn_t)mca_coll_han_algorithm_id_to_fn(REDUCE, algorithm_id);
if (NULL == reduce) { /* default behaviour */
if(mca_coll_han_component.use_simple_algorithm[REDUCE]) {
reduce = mca_coll_han_reduce_intra_simple;
} else {
reduce = mca_coll_han_reduce_intra;
}
}
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_reduce is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
reduce = sub_module->coll_reduce;
}
return reduce(sbuf, rbuf, count, dtype,
op, root, comm, sub_module);
}
/*
* Scatter selector:
* On a sub-communicator, checks the stored rules to find the module to use
* On the global communicator, calls the han collective implementation, or
* calls the correct module if fallback mechanism is activated
*/
int
mca_coll_han_scatter_intra_dynamic(const void *sbuf, int scount,
struct ompi_datatype_t *sdtype,
void *rbuf, int rcount,
struct ompi_datatype_t *rdtype,
int root,
struct ompi_communicator_t *comm,
mca_coll_base_module_t *module)
{
mca_coll_han_module_t *han_module = (mca_coll_han_module_t*) module;
TOPO_LVL_T topo_lvl = han_module->topologic_level;
mca_coll_base_module_scatter_fn_t scatter;
mca_coll_base_module_t *sub_module;
size_t dtype_size;
int rank, verbosity = 0;
if (!han_module->enabled) {
return han_module->previous_scatter(sbuf, scount, sdtype, rbuf, rcount, rdtype, root, comm,
han_module->previous_scatter_module);
}
/* Compute configuration information for dynamic rules */
if( MPI_IN_PLACE != rbuf ) {
ompi_datatype_type_size(rdtype, &dtype_size);
dtype_size = dtype_size * rcount;
} else {
ompi_datatype_type_size(sdtype, &dtype_size);
dtype_size = dtype_size * scount;
}
sub_module = get_module(SCATTER,
dtype_size,
comm,
han_module);
/* First errors are always printed by rank 0 */
rank = ompi_comm_rank(comm);
if( (0 == rank) && (han_module->dynamic_errors < mca_coll_han_component.max_dynamic_errors) ) {
verbosity = 30;
}
if(NULL == sub_module) {
/*
* No valid collective module from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_scatter_intra_dynamic "
"HAN did not find any valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s). "
"Please check dynamic file/mca parameters\n",
SCATTER, mca_coll_base_colltype_to_str(SCATTER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/SCATTER: No module found for the sub-communicator. "
"Falling back to another component\n"));
scatter = han_module->previous_scatter;
sub_module = han_module->previous_scatter_module;
} else if (NULL == sub_module->coll_scatter) {
/*
* No valid collective from dynamic rules
* nor from mca parameter
*/
han_module->dynamic_errors++;
opal_output_verbose(verbosity, mca_coll_han_component.han_output,
"coll:han:mca_coll_han_scatter_intra_dynamic "
"HAN found valid module for collective %d (%s) "
"with topological level %d (%s) on communicator (%s/%s) "
"but this module cannot handle this collective. "
"Please check dynamic file/mca parameters\n",
SCATTER, mca_coll_base_colltype_to_str(SCATTER),
topo_lvl, mca_coll_han_topo_lvl_to_str(topo_lvl),
ompi_comm_print_cid(comm), comm->c_name);
OPAL_OUTPUT_VERBOSE((30, mca_coll_han_component.han_output,
"HAN/SCATTER: the module found for the sub-"
"communicator cannot handle the SCATTER operation. "
"Falling back to another component\n"));
scatter = han_module->previous_scatter;
sub_module = han_module->previous_scatter_module;
} else if (GLOBAL_COMMUNICATOR == topo_lvl && sub_module == module) {
/*
* No fallback mechanism activated for this configuration
* sub_module is valid
* sub_module->coll_scatter is valid and point to this function
* Call han topological collective algorithm
*/
int algorithm_id = get_algorithm(SCATTER,
dtype_size,
comm,
han_module);
scatter = (mca_coll_base_module_scatter_fn_t)mca_coll_han_algorithm_id_to_fn(SCATTER, algorithm_id);
if (NULL == scatter) { /* default behaviour */
if(mca_coll_han_component.use_simple_algorithm[SCATTER]) {
scatter = mca_coll_han_scatter_intra_simple;
} else {
scatter = mca_coll_han_scatter_intra;
}
}
} else {
/*
* If we get here:
* sub_module is valid
* sub_module->coll_scatter is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
scatter = sub_module->coll_scatter;
}
/*
* If we get here:
* sub_module is valid
* sub_module->coll_scatter is valid
* They points to the collective to use, according to the dynamic rules
* Selector's job is done, call the collective
*/
return scatter(sbuf, scount, sdtype,
rbuf, rcount, rdtype,
root, comm,
sub_module);
}
|