Skip to content

Commit

Permalink
HG perf: fix tests to be run in parallel with any comm size
Browse files Browse the repository at this point in the history
  • Loading branch information
soumagne committed Oct 3, 2023
1 parent 9aadd3b commit bfc807f
Show file tree
Hide file tree
Showing 5 changed files with 120 additions and 88 deletions.
20 changes: 11 additions & 9 deletions Testing/perf/hg/hg_bw_read.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ static hg_return_t
hg_perf_run(const struct hg_test_info *hg_test_info,
struct hg_perf_class_info *info, size_t buf_size, size_t skip)
{
size_t comm_rank = (size_t) hg_test_info->na_test_info.mpi_comm_rank,
comm_size = (size_t) hg_test_info->na_test_info.mpi_comm_size,
loop = (size_t) hg_test_info->na_test_info.loop;
hg_time_t t1, t2;
hg_return_t ret;
size_t i;

/* Warm up for RPC */
for (i = 0; i < skip + (size_t) hg_test_info->na_test_info.loop; i++) {
for (i = 0; i < skip + loop; i++) {
struct hg_perf_request args = {
.expected_count = (int32_t) info->handle_max,
.complete_count = 0,
.request = info->request};
unsigned int j;
size_t j;

if (i == skip) {
if (hg_test_info->na_test_info.mpi_comm_size > 1)
if (comm_size > 1)
NA_Test_barrier(&hg_test_info->na_test_info);
hg_time_get_current(&t1);
}
Expand All @@ -55,9 +58,8 @@ hg_perf_run(const struct hg_test_info *hg_test_info,

for (j = 0; j < info->handle_max; j++) {
struct hg_perf_bulk_info in_struct = {
.comm_rank =
(uint32_t) hg_test_info->na_test_info.mpi_comm_rank,
.handle_id = (uint32_t) (j / info->target_addr_max),
.handle_id = (uint32_t) ((comm_rank + j * comm_size) /
info->target_addr_max),
.size = (uint32_t) buf_size};

ret = HG_Forward(
Expand All @@ -83,12 +85,12 @@ hg_perf_run(const struct hg_test_info *hg_test_info,
}
}

if (hg_test_info->na_test_info.mpi_comm_size > 1)
if (comm_size > 1)
NA_Test_barrier(&hg_test_info->na_test_info);

hg_time_get_current(&t2);

if (hg_test_info->na_test_info.mpi_comm_rank == 0)
if (comm_rank == 0)
hg_perf_print_bw(
hg_test_info, info, buf_size, hg_time_subtract(t2, t1));

Expand Down Expand Up @@ -121,7 +123,7 @@ main(int argc, char *argv[])
HG_Error_to_string(hg_ret));

/* Set HG handles */
hg_ret = hg_perf_set_handles(info, HG_PERF_BW_READ);
hg_ret = hg_perf_set_handles(hg_test_info, info, HG_PERF_BW_READ);
HG_TEST_CHECK_HG_ERROR(error, hg_ret, "hg_perf_set_handles() failed (%s)",
HG_Error_to_string(hg_ret));

Expand Down
20 changes: 11 additions & 9 deletions Testing/perf/hg/hg_bw_write.c
Original file line number Diff line number Diff line change
Expand Up @@ -33,20 +33,23 @@ static hg_return_t
hg_perf_run(const struct hg_test_info *hg_test_info,
struct hg_perf_class_info *info, size_t buf_size, size_t skip)
{
size_t comm_rank = (size_t) hg_test_info->na_test_info.mpi_comm_rank,
comm_size = (size_t) hg_test_info->na_test_info.mpi_comm_size,
loop = (size_t) hg_test_info->na_test_info.loop;
hg_time_t t1, t2;
hg_return_t ret;
size_t i;

/* Warm up for RPC */
for (i = 0; i < skip + (size_t) hg_test_info->na_test_info.loop; i++) {
for (i = 0; i < skip + loop; i++) {
struct hg_perf_request args = {
.expected_count = (int32_t) info->handle_max,
.complete_count = 0,
.request = info->request};
unsigned int j;
size_t j;

if (i == skip) {
if (hg_test_info->na_test_info.mpi_comm_size > 1)
if (comm_size > 1)
NA_Test_barrier(&hg_test_info->na_test_info);
hg_time_get_current(&t1);
}
Expand All @@ -55,9 +58,8 @@ hg_perf_run(const struct hg_test_info *hg_test_info,

for (j = 0; j < info->handle_max; j++) {
struct hg_perf_bulk_info in_struct = {
.comm_rank =
(uint32_t) hg_test_info->na_test_info.mpi_comm_rank,
.handle_id = (uint32_t) (j / info->target_addr_max),
.handle_id = (uint32_t) ((comm_rank + j * comm_size) /
info->target_addr_max),
.size = (uint32_t) buf_size};

ret = HG_Forward(
Expand All @@ -69,12 +71,12 @@ hg_perf_run(const struct hg_test_info *hg_test_info,
hg_request_wait(info->request, HG_MAX_IDLE_TIME, NULL);
}

if (hg_test_info->na_test_info.mpi_comm_size > 1)
if (comm_size > 1)
NA_Test_barrier(&hg_test_info->na_test_info);

hg_time_get_current(&t2);

if (hg_test_info->na_test_info.mpi_comm_rank == 0)
if (comm_rank == 0)
hg_perf_print_bw(
hg_test_info, info, buf_size, hg_time_subtract(t2, t1));

Expand Down Expand Up @@ -107,7 +109,7 @@ main(int argc, char *argv[])
HG_Error_to_string(hg_ret));

/* Set HG handles */
hg_ret = hg_perf_set_handles(info, HG_PERF_BW_WRITE);
hg_ret = hg_perf_set_handles(hg_test_info, info, HG_PERF_BW_WRITE);
HG_TEST_CHECK_HG_ERROR(error, hg_ret, "hg_perf_set_handles() failed (%s)",
HG_Error_to_string(hg_ret));

Expand Down
4 changes: 2 additions & 2 deletions Testing/perf/hg/hg_rate.c
Original file line number Diff line number Diff line change
Expand Up @@ -126,12 +126,12 @@ main(int argc, char *argv[])
info = &perf_info.class_info[0];

/* Allocate RPC buffers */
hg_ret = hg_perf_rpc_buf_init(info);
hg_ret = hg_perf_rpc_buf_init(hg_test_info, info);
HG_TEST_CHECK_HG_ERROR(error, hg_ret, "hg_perf_init_rpc_buf() failed (%s)",
HG_Error_to_string(hg_ret));

/* Set HG handles */
hg_ret = hg_perf_set_handles(info, HG_PERF_RATE);
hg_ret = hg_perf_set_handles(hg_test_info, info, HG_PERF_RATE);
HG_TEST_CHECK_HG_ERROR(error, hg_ret, "hg_perf_set_handles() failed (%s)",
HG_Error_to_string(hg_ret));

Expand Down
Loading

0 comments on commit bfc807f

Please sign in to comment.