Skip to content

Commit

Permalink
NA Test: add -T/--tclass option to select trafic class
Browse files Browse the repository at this point in the history
  • Loading branch information
soumagne committed Dec 19, 2023
1 parent 3e255cc commit 36d4650
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
42 changes: 42 additions & 0 deletions Testing/common/na_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,9 @@ na_test_parse_options(
static size_t
na_test_parse_size(const char *str);

static enum na_traffic_class
na_test_tclass(const char *str);

static char *
na_test_gen_config(struct na_test_info *na_test_info, unsigned int i);

Expand Down Expand Up @@ -95,6 +98,7 @@ na_test_usage(const char *execname)
" Default: any\n");
printf(" -S, --self_send Send to self\n");
printf(" -k, --key Pass auth key\n");
printf(" -T, --tclass Traffic class to use\n");
printf(" -l, --loop Number of loops (default: 1)\n");
printf(" -b, --busy Busy wait\n");
printf(" -y --buf_size_min Min buffer size (in bytes)\n");
Expand Down Expand Up @@ -203,6 +207,9 @@ na_test_parse_options(int argc, char *argv[], struct na_test_info *na_test_info)
case 'f': /* hostfile */
na_test_info->hostfile = strdup(na_test_opt_arg_g);
break;
case 'T': /* tclass */
na_test_info->tclass = strdup(na_test_opt_arg_g);
break;
default:
break;
}
Expand Down Expand Up @@ -245,6 +252,30 @@ na_test_parse_size(const char *str)
return 0;
}

/*---------------------------------------------------------------------------*/
static enum na_traffic_class
na_test_tclass(const char *str)
{
if (strcmp(str, "best_effort") == 0)
return NA_TC_BEST_EFFORT;
else if (strcmp(str, "low_latency") == 0)
return NA_TC_LOW_LATENCY;
else if (strcmp(str, "bulk_data") == 0)
return NA_TC_BULK_DATA;
else if (strcmp(str, "dedicated_access") == 0)
return NA_TC_DEDICATED_ACCESS;
else if (strcmp(str, "scavenger") == 0)
return NA_TC_SCAVENGER;
else if (strcmp(str, "network_ctrl") == 0)
return NA_TC_NETWORK_CTRL;
else {
fprintf(stderr,
"Traffic class does not match: best_effort, low_latency, "
"bulk_data, dedicated_access, scavenger, network_ctrl\n");
return NA_TC_UNSPEC;
}
}

/*---------------------------------------------------------------------------*/
static char *
na_test_gen_config(struct na_test_info *na_test_info, unsigned int i)
Expand Down Expand Up @@ -480,6 +511,13 @@ NA_Test_init(int argc, char *argv[], struct na_test_info *na_test_info)
na_init_info.max_expected_size = (size_t) na_test_info->max_msg_size;
na_init_info.thread_mode =
na_test_info->use_threads ? 0 : NA_THREAD_MODE_SINGLE;
if (na_test_info->tclass != NULL) {
na_init_info.traffic_class = na_test_tclass(na_test_info->tclass);
NA_TEST_CHECK_ERROR(na_init_info.traffic_class == NA_TC_UNSPEC, error,
ret, NA_PROTONOSUPPORT, "Unsupported traffic class");
if (na_test_info->mpi_info.rank == 0)
printf("# Using traffic class: %s\n", na_test_info->tclass);
}

na_test_info->na_classes = (na_class_t **) malloc(
sizeof(na_class_t *) * na_test_info->max_classes);
Expand Down Expand Up @@ -649,6 +687,10 @@ NA_Test_finalize(struct na_test_info *na_test_info)
free(na_test_info->hostfile);
na_test_info->hostfile = NULL;
}
if (na_test_info->tclass != NULL) {
free(na_test_info->tclass);
na_test_info->tclass = NULL;
}

na_test_mpi_finalize(&na_test_info->mpi_info);

Expand Down
1 change: 1 addition & 0 deletions Testing/common/na_test.h
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ struct na_test_info {
bool mpi_static; /* MPI static comm */
bool self_send; /* Self send */
char *key; /* Auth key */
char *tclass; /* Traffic class */
int loop; /* Number of loops */
bool busy_wait; /* Busy wait */
size_t max_classes; /* Max classes */
Expand Down
4 changes: 3 additions & 1 deletion Testing/common/na_test_getopt.c
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@

int na_test_opt_ind_g = 1; /* token pointer */
const char *na_test_opt_arg_g = NULL; /* flag argument (or value) */
const char *na_test_short_opt_g = "hc:d:p:H:P:sSk:l:bC:X:VZ:y:z:w:x:mt:BRvMUf:";
const char *na_test_short_opt_g =
"hc:d:p:H:P:sSk:l:bC:X:VZ:y:z:w:x:mt:BRvMUf:T:";
/* clang-format off */
const struct na_test_opt na_test_opt_g[] = {
{"help", no_arg, 'h'},
Expand Down Expand Up @@ -44,6 +45,7 @@ const struct na_test_opt na_test_opt_g[] = {
{"millionbps", no_arg, 'M'},
{"no-multi-recv", no_arg, 'U'},
{"hostfile", require_arg, 'f'},
{"tclass", require_arg, 'T'},
{NULL, 0, '\0'} /* Must add this at the end */
};
/* clang-format on */
Expand Down

0 comments on commit 36d4650

Please sign in to comment.