Skip to content

Commit 69b8931

Browse files
author
Luke Robison
committed
alltoallv_ddt: extend to alltoall testing as well
Signed-off-by: Luke Robison <[email protected]>
1 parent cf174c2 commit 69b8931

File tree

1 file changed

+49
-14
lines changed

1 file changed

+49
-14
lines changed

alltoallv_validation/src/alltoallv_ddt.cpp

Lines changed: 49 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,8 @@ int execute_test(struct run_config *run);
3434
#define VERBOSE_LEVEL_LOUD (user.verbose >= 2)
3535
#define VERBOSE_LEVEL_VERY_LOUD (user.verbose >= 3)
3636

37+
enum test_coll { TEST_ALLTOALL, TEST_ALLTOALLV };
38+
3739
struct user_config
3840
{
3941
int seed = 0;
@@ -50,6 +52,9 @@ struct user_config
5052
int verbose = 0;
5153
int only_high = 0;
5254
int only_low = 0;
55+
56+
/* collective */
57+
int test_coll = TEST_ALLTOALLV;
5358
};
5459

5560
static struct user_config user;
@@ -71,6 +76,11 @@ void dump_user_config(struct user_config *conf) {
7176
std::cout << "prob-rank: " << conf->prob_rank << "\n";
7277
std::cout << "prob-world: " << conf->prob_world << "\n";
7378
std::cout << "verbose: " << conf->verbose << "\n";
79+
if ( conf->test_coll == TEST_ALLTOALL ) {
80+
std::cout << "collective: MPI_Alltoall" << "\n";
81+
} else if ( conf->test_coll == TEST_ALLTOALLV ) {
82+
std::cout << "collective: MPI_Alltoallv" << "\n";
83+
}
7484
}
7585

7686
void dump_type_info(MPI_Datatype dtype, const char *label) {
@@ -104,26 +114,29 @@ struct run_config
104114
MPI_Datatype rdtype;
105115
int sdcount_mult;
106116
int rdcount_mult;
117+
const char* coll;
107118
};
108119

109120
void print_help()
110121
{
111-
printf("Test alltoallv using various ddt's and validate results.\n");
122+
printf("Test alltoall/alltoallv using various ddt's and validate results.\n");
112123
printf("This test uses pseudo-random sequences from C++'s mt19937 generator.\n");
113124
printf("The test (but not necessarily the implementation) is deterministic\n");
114125
printf("when the options and number of ranks remain the same.\n");
115126
printf("Options:\n");
116-
printf("\t [-s|--seed <seed>] Change the seed to shuffle which datapoints are exchanged\n");
117-
printf("\t [-c|--item-count <citems>] Each rank will create <citems> to consider for exchange (default=10).\n");
118-
printf("\t [-i|--prob-item <prob>] Probability that rank r will send item k to rank q. (0.50)\n");
119-
printf("\t [-r|--prob-rank <prob>] Probability that rank r will send anything to rank q. (0.90)\n");
120-
printf("\t [-w|--prob-world <prob>] Probability that rank r will do anything at all. (0.95)\n");
127+
printf("\t [-A|--coll alltoall|alltoallv Pick which collective to test.\n");
121128
printf("\t [-t|--iters <iters>] The number of iterations to test each dtype.\n");
122129
printf("\t [-o|--only <high,low>] Only execute a specific test signified by the pair high,low.\n");
123130
printf("\t low=0 means run all tests in that high level\n");
124-
printf("\t [-v|--verbose=level ] Set verbosity during execution (0=quiet (default). 1,2,3: loud).\n");
131+
printf("\t [-v|--verbose <level> ] Set verbosity during execution (0=quiet (default). 1,2,3: loud).\n");
125132
printf("\t [-h|--help] Print this help and exit.\n");
126133
printf("\t [-z|--verbose-rank] Only the provided rank will print. Default=0. ALL = -1.\n");
134+
printf("\t [-c|--item-count <citems>] Each rank will create <citems> to consider for exchange (default=10).\n");
135+
printf("\nThe following options only have an effect when using alltoallv:\n");
136+
printf("\t [-s|--seed <seed>] Change the seed to shuffle which datapoints are exchanged\n");
137+
printf("\t [-i|--prob-item <prob>] Probability that rank r will send item k to rank q. (0.50)\n");
138+
printf("\t [-r|--prob-rank <prob>] Probability that rank r will send anything to rank q. (0.90)\n");
139+
printf("\t [-w|--prob-world <prob>] Probability that rank r will do anything at all. (0.95)\n");
127140

128141
printf("\n");
129142
}
@@ -748,11 +761,19 @@ int execute_test(struct run_config *run) {
748761
ERROR_CHECK(err, on_error);
749762

750763
/* exchange data */
751-
err = MPI_Alltoallv(
752-
smsg_buf+lbs_shift, sendcounts, sdispls, run->sdtype,
753-
rmsg_buf+lbr_shift, recvcounts, rdispls, run->rdtype,
754-
MPI_COMM_WORLD
755-
);
764+
if (TEST_ALLTOALLV == run->user->test_coll) {
765+
err = MPI_Alltoallv(
766+
smsg_buf+lbs_shift, sendcounts, sdispls, run->sdtype,
767+
rmsg_buf+lbr_shift, recvcounts, rdispls, run->rdtype,
768+
MPI_COMM_WORLD
769+
);
770+
} else {
771+
err = MPI_Alltoall(
772+
smsg_buf+lbs_shift, sendcounts[0], run->sdtype,
773+
rmsg_buf+lbr_shift, recvcounts[0], run->rdtype,
774+
MPI_COMM_WORLD
775+
);
776+
}
756777
ERROR_CHECK(err, on_error);
757778
err = check_guard_bytes( msg_guards, guard_len, 127, "message buffer3" );
758779
err |= check_guard_bytes( valb_guards, guard_len, 128, "validation buffer" );
@@ -831,7 +852,8 @@ int main(int argc, char *argv[]) {
831852
{ "only", required_argument, 0, 'o' },
832853
{ "verbose", required_argument, 0, 'v' },
833854
{ "verbose-rank", required_argument, 0, 'z' },
834-
{ "help", no_argument, 0, 'h' }
855+
{ "help", no_argument, 0, 'h' },
856+
{ "coll", required_argument, 0, 'A' }
835857
};
836858

837859
int opt;
@@ -842,7 +864,7 @@ int main(int argc, char *argv[]) {
842864
while (1)
843865
{
844866
char *s1, *s2;
845-
opt = getopt_long(argc, argv, "s:c:i:r:w:t:v:hz:", long_options, &option_index);
867+
opt = getopt_long(argc, argv, "s:c:i:r:w:t:v:hz:A:", long_options, &option_index);
846868
if (opt == -1) break;
847869
switch(opt) {
848870
case 's':
@@ -876,6 +898,13 @@ int main(int argc, char *argv[]) {
876898
case 'v':
877899
user.verbose = atoi(optarg);
878900
break;
901+
case 'A':
902+
if (strcmp(optarg, "alltoall") == 0 ) {
903+
user.test_coll = TEST_ALLTOALL;
904+
} else {
905+
user.test_coll = TEST_ALLTOALLV;
906+
}
907+
break;
879908
case 'h':
880909
if (rank==0) {
881910
print_help();
@@ -902,6 +931,12 @@ int main(int argc, char *argv[]) {
902931
printf("Requested only test %d,%d\n",user.only_high,user.only_low);
903932
}
904933

934+
if (TEST_ALLTOALL == user.test_coll) {
935+
user.prob_item = 1.001;
936+
user.prob_rank = 1.001;
937+
user.prob_world = 1.001;
938+
}
939+
905940
if (VERBOSE_LEVEL_LOUD) {
906941
dump_user_config(&user);
907942
printf("-----------\n");

0 commit comments

Comments
 (0)