Skip to content

Commit 92f7236

Browse files
PERFTEST/FT Add validation mode for pingpong tests
1 parent e17f245 commit 92f7236

2 files changed

Lines changed: 78 additions & 3 deletions

File tree

src/tools/perf/lib/ucp_tests.cc

Lines changed: 41 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
#include <ucs/sys/preprocessor.h>
1818
#include <ucs/sys/string.h>
19+
#include "ucs/type/status.h"
1920
#include <limits>
2021

2122

@@ -733,6 +734,21 @@ class ucp_perf_test_runner : public ucp_perf_test_runner_base<uint8_t> {
733734
m_perf.ucp.self_recv_rkey);
734735
}
735736

737+
ucs_status_t validate_buffers(void *send_buffer, void *recv_buffer,
738+
size_t length)
739+
{
740+
if (CMD == UCX_PERF_CMD_PUT) {
741+
fence();
742+
}
743+
744+
if (memcmp(send_buffer, recv_buffer, length)) {
745+
ucs_error("data mismatch between send and receive buffers");
746+
return UCS_ERR_IO_ERROR;
747+
}
748+
749+
return UCS_OK;
750+
}
751+
736752
ucs_status_t run_pingpong()
737753
{
738754
unsigned my_index;
@@ -744,21 +760,25 @@ class ucp_perf_test_runner : public ucp_perf_test_runner_base<uint8_t> {
744760
ucp_rkey_h rkey;
745761
size_t length, send_length, recv_length;
746762
psn_t sn;
763+
bool validate;
764+
ucs_status_t status;
747765

748766
send_buffer = m_perf.send_buffer;
749767
recv_buffer = m_perf.recv_buffer;
750768
worker = m_perf.ucp.worker;
751769
ep = m_perf.ucp.ep;
752770
remote_addr = m_perf.ucp.remote_addr;
753771
rkey = m_perf.ucp.rkey;
754-
sn = 0;
772+
sn = 1;
755773

756774
ucp_perf_init_common_params(&length, &send_length, &send_datatype,
757775
&send_buffer, &recv_length, &recv_datatype,
758776
&recv_buffer);
759777

760778
reset_buffers(length, UNKNOWN_SN);
761779

780+
validate = m_perf.params.flags & UCX_PERF_TEST_FLAG_VALIDATE;
781+
762782
ucp_perf_barrier(&m_perf);
763783

764784
my_index = rte_call(&m_perf, group_index);
@@ -769,16 +789,35 @@ class ucp_perf_test_runner : public ucp_perf_test_runner_base<uint8_t> {
769789

770790
if (my_index == 0) {
771791
UCX_PERF_TEST_FOREACH(&m_perf) {
792+
793+
if (validate) {
794+
memset(send_buffer, sn, send_length);
795+
}
796+
772797
send(ep, send_buffer, send_length, send_datatype, sn, remote_addr, rkey);
773798
recv(worker, ep, recv_buffer, recv_length, recv_datatype, sn);
774799
wait_recv_window(m_max_outstanding);
800+
801+
if (validate) {
802+
status = validate_buffers(send_buffer, recv_buffer,
803+
send_length);
804+
if (status != UCS_OK) {
805+
return status;
806+
}
807+
}
808+
775809
ucx_perf_update(&m_perf, 1, 1, length);
776810
++sn;
777811
}
778812
} else if (my_index == 1) {
779813
UCX_PERF_TEST_FOREACH(&m_perf) {
780814
recv(worker, ep, recv_buffer, recv_length, recv_datatype, sn);
781815
wait_recv_window(m_max_outstanding);
816+
817+
if (validate) {
818+
memcpy(send_buffer, recv_buffer, send_length);
819+
}
820+
782821
send(ep, send_buffer, send_length, send_datatype, sn,
783822
remote_addr, rkey, m_perf.current.iters == 0);
784823
ucx_perf_update(&m_perf, 1, 1, length);
@@ -834,7 +873,7 @@ class ucp_perf_test_runner : public ucp_perf_test_runner_base<uint8_t> {
834873
if (m_perf.params.flags & UCX_PERF_TEST_FLAG_LOOPBACK) {
835874
UCX_PERF_TEST_FOREACH(&m_perf) {
836875
send(ep, send_buffer, send_length, send_datatype,
837-
sn, remote_addr, rkey);
876+
sn, remote_addr, rkey);
838877
recv(worker, ep, recv_buffer, recv_length, recv_datatype, sn);
839878
ucx_perf_update(&m_perf, 1, 1, length);
840879
++sn;

src/tools/perf/perftest_params.c

Lines changed: 37 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,10 @@
88
# include "config.h"
99
#endif
1010

11+
#include "api/libperf.h"
1112
#include "perftest.h"
1213

14+
#include "ucs/memory/memory_type.h"
1315
#include <ucs/sys/string.h>
1416
#include <ucs/sys/sys.h>
1517
#include <ucs/sys/sock.h>
@@ -173,6 +175,7 @@ static void usage(const struct perftest_context *ctx, const char *program)
173175
ctx->params.super.ucp.am_hdr_size);
174176
printf(" -y do additional memcopy to the user memory in active message receive handler\n");
175177
printf(" -z pass pre-registered memory handle\n");
178+
printf(" -V validate data correctness for pingpong tests\n");
176179
printf(" -g <IP>[:<port>], --daemon-local <IP>[:<port>]\n");
177180
printf(" IP address and port of the local daemon to offload UCP operations to\n");
178181
printf(" Port is optional, by default daemon port is (%d)\n",
@@ -771,6 +774,9 @@ ucs_status_t parse_test_params(perftest_params_t *params, char opt,
771774
case 'z':
772775
params->super.flags |= UCX_PERF_TEST_FLAG_PREREG;
773776
return UCS_OK;
777+
case 'V':
778+
params->super.flags |= UCX_PERF_TEST_FLAG_VALIDATE;
779+
return UCS_OK;
774780
default:
775781
return UCS_ERR_INVALID_PARAM;
776782
}
@@ -819,6 +825,31 @@ ucs_status_t clone_params(perftest_params_t *dest,
819825
return UCS_OK;
820826
}
821827

828+
ucs_status_t check_validation_params(const ucx_perf_params_t *params)
829+
{
830+
if (!(params->flags & UCX_PERF_TEST_FLAG_VALIDATE)) {
831+
return UCS_OK;
832+
}
833+
834+
if (params->api == UCX_PERF_API_UCT) {
835+
ucs_error("validation mode is not compatible with UCT tests");
836+
return UCS_ERR_INVALID_PARAM;
837+
}
838+
839+
if (params->test_type != UCX_PERF_TEST_TYPE_PINGPONG) {
840+
ucs_error("validation mode requires using a PingPong test");
841+
return UCS_ERR_INVALID_PARAM;
842+
}
843+
844+
if ((params->send_mem_type != UCS_MEMORY_TYPE_HOST) ||
845+
(params->recv_mem_type != UCS_MEMORY_TYPE_HOST)) {
846+
ucs_error("validation mode requires send and recv buffers to use host memory");
847+
return UCS_ERR_INVALID_PARAM;
848+
}
849+
850+
return UCS_OK;
851+
}
852+
822853
ucs_status_t check_params(const perftest_params_t *params)
823854
{
824855
ucs_status_t status;
@@ -828,6 +859,11 @@ ucs_status_t check_params(const perftest_params_t *params)
828859
return status;
829860
}
830861

862+
status = check_validation_params(&params->super);
863+
if (status != UCS_OK) {
864+
return status;
865+
}
866+
831867
switch (params->super.api) {
832868
case UCX_PERF_API_UCT:
833869
if (!strcmp(params->super.uct.dev_name, TL_RESOURCE_NAME_NONE)) {
@@ -916,7 +952,7 @@ ucs_status_t parse_opts(struct perftest_context *ctx, int mpi_initialized,
916952

917953
optind = 1;
918954
while ((c = getopt_long(argc, argv,
919-
"p:b:6NfvXc:P:hK:g:G:k" TEST_PARAMS_ARGS,
955+
"p:b:6NfvXc:P:hK:g:G:kV" TEST_PARAMS_ARGS,
920956
TEST_PARAMS_ARGS_LONG, NULL)) != -1) {
921957
switch (c) {
922958
case 'p':

0 commit comments

Comments
 (0)