Skip to content

Commit

Permalink
fabtests: Define common run pingpong function
Browse files Browse the repository at this point in the history
The run() logic in rdm_pingpong and rdm_tagged_pingpong is the same.
Consolidate this logic into a single run_pingpong() function.

Signed-off-by: Ian Ziemba <ian.ziemba@hpe.com>
  • Loading branch information
iziemba authored and j-xiong committed Sep 24, 2024
1 parent b359d1b commit 8e8a920
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 60 deletions.
28 changes: 28 additions & 0 deletions fabtests/benchmarks/benchmark_shared.c
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,34 @@ int pingpong(void)
return 0;
}

int run_pingpong(void)
{
int i, ret = 0;

ret = ft_init_fabric();
if (ret)
return ret;

if (!(opts.options & FT_OPT_SIZE)) {
for (i = 0; i < TEST_CNT; i++) {
if (!ft_use_size(i, opts.sizes_enabled))
continue;
opts.transfer_size = test_size[i].size;
init_test(&opts, test_name, sizeof(test_name));
ret = pingpong();
if (ret)
return ret;
}
} else {
init_test(&opts, test_name, sizeof(test_name));
ret = pingpong();
if (ret)
return ret;
}

return ft_finalize();
}

int pingpong_rma(enum ft_rma_opcodes rma_op, struct fi_rma_iov *remote)
{
int ret, i;
Expand Down
1 change: 1 addition & 0 deletions fabtests/benchmarks/benchmark_shared.h
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@ extern "C" {
void ft_parse_benchmark_opts(int op, char *optarg);
void ft_benchmark_usage(void);
int pingpong(void);
int run_pingpong(void);
int bandwidth(void);
int pingpong_rma(enum ft_rma_opcodes rma_op, struct fi_rma_iov *remote);
int bandwidth_rma(enum ft_rma_opcodes op, struct fi_rma_iov *remote);
Expand Down
30 changes: 1 addition & 29 deletions fabtests/benchmarks/rdm_pingpong.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,34 +36,6 @@
#include "shared.h"
#include "benchmark_shared.h"

static int run(void)
{
int i, ret = 0;

ret = ft_init_fabric();
if (ret)
return ret;

if (!(opts.options & FT_OPT_SIZE)) {
for (i = 0; i < TEST_CNT; i++) {
if (!ft_use_size(i, opts.sizes_enabled))
continue;
opts.transfer_size = test_size[i].size;
init_test(&opts, test_name, sizeof(test_name));
ret = pingpong();
if (ret)
return ret;
}
} else {
init_test(&opts, test_name, sizeof(test_name));
ret = pingpong();
if (ret)
return ret;
}

return ft_finalize();
}

int main(int argc, char **argv)
{
int op, ret;
Expand Down Expand Up @@ -106,7 +78,7 @@ int main(int argc, char **argv)
hints->tx_attr->tclass = FI_TC_LOW_LATENCY;
hints->addr_format = opts.address_format;

ret = run();
ret = run_pingpong();

ft_free_res();
return ft_exit_code(ret);
Expand Down
32 changes: 1 addition & 31 deletions fabtests/benchmarks/rdm_tagged_pingpong.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,36 +36,6 @@
#include <shared.h>
#include "benchmark_shared.h"

static int run(void)
{
int i, ret = 0;

ret = ft_init_fabric();
if (ret)
return ret;

if (!(opts.options & FT_OPT_SIZE)) {
for (i = 0; i < TEST_CNT; i++) {
if (!ft_use_size(i, opts.sizes_enabled))
continue;
opts.transfer_size = test_size[i].size;
init_test(&opts, test_name, sizeof(test_name));
ret = pingpong();
if (ret)
goto out;
}
} else {
init_test(&opts, test_name, sizeof(test_name));
ret = pingpong();
if (ret)
goto out;
}

ft_finalize();
out:
return ret;
}

int main(int argc, char **argv)
{
int op, ret;
Expand Down Expand Up @@ -108,7 +78,7 @@ int main(int argc, char **argv)
hints->tx_attr->tclass = FI_TC_LOW_LATENCY;
hints->addr_format = opts.address_format;

ret = run();
ret = run_pingpong();

ft_free_res();
return ft_exit_code(ret);
Expand Down

0 comments on commit 8e8a920

Please sign in to comment.