Skip to content

Commit b083191

Browse files
authored
Merge pull request #374 from Yue-ByteDance/yzl/inline-helper
Perftest: add has_recv_comp() inline helper for verb type checks
2 parents 9dba078 + c201134 commit b083191

File tree

3 files changed

+25
-28
lines changed

3 files changed

+25
-28
lines changed

src/perftest_parameters.c

Lines changed: 8 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ static void usage(const char *argv0, VerbType verb, TestType tst, int connection
422422
printf(" Generate Cqe only after <--cq-mod> completion\n");
423423
}
424424

425-
if ((verb == SEND || verb == SEND_IMM || verb == WRITE_IMM) && tst != FS_RATE) {
425+
if (has_recv_comp(verb) && tst != FS_RATE) {
426426
printf(" -r, --rx-depth=<dep> ");
427427
printf(" Rx queue size (default %d).",DEF_RX_SEND);
428428
printf(" If using srq, rx-depth controls max-wr size of the srq\n");
@@ -1284,8 +1284,7 @@ static void force_dependecies(struct perftest_parameters *user_param)
12841284
user_param->tx_depth = user_param->iters;
12851285
}
12861286

1287-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM) &&
1288-
user_param->rx_depth > user_param->iters) {
1287+
if (has_recv_comp(user_param->verb) && user_param->rx_depth > user_param->iters) {
12891288
user_param->rx_depth = user_param->iters;
12901289
}
12911290

@@ -1781,7 +1780,7 @@ static void force_dependecies(struct perftest_parameters *user_param)
17811780
}
17821781
}
17831782

1784-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
1783+
if (has_recv_comp(user_param->verb)
17851784
&& user_param->tst == BW && user_param->machine == SERVER && !user_param->duplex ) {
17861785
if (user_param->noPeak == OFF)
17871786
printf(" WARNING: BW peak won't be measured in this run.\n");
@@ -1807,8 +1806,7 @@ static void force_dependecies(struct perftest_parameters *user_param)
18071806

18081807
}
18091808

1810-
if (user_param->duplex &&
1811-
(user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)) {
1809+
if (user_param->duplex && has_recv_comp(user_param->verb)) {
18121810
printf(RESULT_LINE);
18131811
fprintf(stderr," run_infinitely mode is not supported in SEND, SEND_IMM or WRITE_IMM "
18141812
"Bidirectional BW test\n");
@@ -2181,8 +2179,7 @@ static void force_dependecies(struct perftest_parameters *user_param)
21812179
}
21822180

21832181
/* WA for a bug when rx_depth is odd in SEND */
2184-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
2185-
&& (user_param->rx_depth % 2 == 1) && user_param->test_method == RUN_REGULAR)
2182+
if (has_recv_comp(user_param->verb) && (user_param->rx_depth % 2 == 1) && user_param->test_method == RUN_REGULAR)
21862183
user_param->rx_depth += 1;
21872184

21882185
if (user_param->test_type == ITERATIONS && user_param->iters > 20000 && user_param->noPeak == OFF && user_param->tst == BW) {
@@ -4307,8 +4304,7 @@ void ctx_print_test_info(struct perftest_parameters *user_param)
43074304
if (user_param->recv_post_list > 1)
43084305
printf(" Recv Post List : %d\n", user_param->recv_post_list);
43094306

4310-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
4311-
&& (user_param->machine == SERVER || user_param->duplex)) {
4307+
if (has_recv_comp(user_param->verb) && (user_param->machine == SERVER || user_param->duplex)) {
43124308
printf(" RX depth : %d\n",user_param->rx_depth);
43134309
}
43144310

@@ -4495,7 +4491,7 @@ void print_report_bw (struct perftest_parameters *user_param, struct bw_report_d
44954491
my_bw_rep->sl = user_param->sl;
44964492

44974493
if (!user_param->duplex
4498-
|| ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM) && user_param->test_type == DURATION)
4494+
|| (has_recv_comp(user_param->verb) && user_param->test_type == DURATION)
44994495
|| user_param->test_method == RUN_INFINITELY || user_param->connection_type == RawEth)
45004496
print_full_bw_report(user_param, my_bw_rep, NULL);
45014497

@@ -4568,8 +4564,7 @@ static void write_test_info_to_file(int out_json_fds, struct perftest_parameters
45684564
if (user_param->recv_post_list > 1)
45694565
dprintf(out_json_fds, "\"Recv_Post_List\": %d,\n", user_param->recv_post_list);
45704566

4571-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM) &&
4572-
(user_param->machine == SERVER || user_param->duplex)) {
4567+
if (has_recv_comp(user_param->verb) && (user_param->machine == SERVER || user_param->duplex)) {
45734568
dprintf(out_json_fds, "\"RX_depth\": %d,\n",user_param->rx_depth);
45744569
}
45754570

src/perftest_parameters.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,7 @@
5656
#include <infiniband/verbs.h>
5757
#include <unistd.h>
5858
#include <inttypes.h>
59+
#include <stdbool.h>
5960
#if !defined(__FreeBSD__)
6061
#include <malloc.h>
6162
#endif
@@ -980,4 +981,10 @@ int compare_ibv_device(const char *name, void* local_value, void* remote_value,
980981
int compare_mlx5dv(const char *name, void* local_value, void* remote_value, char** return_values,
981982
struct perftest_parameters* user_param, CompareType type);
982983
#endif
984+
985+
static inline bool has_recv_comp(VerbType verb)
986+
{
987+
return verb == SEND || verb == SEND_IMM || verb == WRITE_IMM;
988+
}
989+
983990
#endif /* PERFTEST_RESOURCES_H */

src/perftest_resources.c

Lines changed: 10 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -895,7 +895,7 @@ static int ctx_xrc_srq_create(struct pingpong_context *ctx,
895895
srq_init_attr.srq_type = IBV_SRQT_XRC;
896896
srq_init_attr.xrcd = ctx->xrc_domain;
897897

898-
if (user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
898+
if (has_recv_comp(user_param->verb))
899899
srq_init_attr.cq = ctx->recv_cq;
900900
else
901901
srq_init_attr.cq = ctx->send_cq;
@@ -1216,7 +1216,7 @@ int alloc_ctx(struct pingpong_context *ctx,struct perftest_parameters *user_para
12161216
memset(ctx->ccnt, 0, user_param->num_of_qps * sizeof (uint64_t));
12171217

12181218
} else if ((user_param->tst == BW || user_param->tst == LAT_BY_BW)
1219-
&& (user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
1219+
&& has_recv_comp(user_param->verb)
12201220
&& user_param->machine == SERVER) {
12211221

12221222
ALLOC(ctx->my_addr, uint64_t, user_param->num_of_qps);
@@ -1259,8 +1259,7 @@ int alloc_ctx(struct pingpong_context *ctx,struct perftest_parameters *user_para
12591259
ALLOC(ctx->ah, struct ibv_ah*, user_param->num_of_qps);
12601260
}
12611261

1262-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
1263-
&& (user_param->tst == LAT || user_param->machine == SERVER || user_param->duplex)) {
1262+
if (has_recv_comp(user_param->verb) && (user_param->tst == LAT || user_param->machine == SERVER || user_param->duplex)) {
12641263
ALLOC(ctx->recv_sge_list, struct ibv_sge,
12651264
user_param->num_of_qps * user_param->recv_post_list);
12661265
ALLOC(ctx->rwr, struct ibv_recv_wr,
@@ -1404,8 +1403,7 @@ void dealloc_ctx(struct pingpong_context *ctx,struct perftest_parameters *user_p
14041403
free(ctx->ah);
14051404
}
14061405

1407-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
1408-
&& (user_param->tst == LAT || user_param->machine == SERVER || user_param->duplex)) {
1406+
if (has_recv_comp(user_param->verb) && (user_param->tst == LAT || user_param->machine == SERVER || user_param->duplex)) {
14091407
if (ctx->recv_sge_list != NULL)
14101408
free(ctx->recv_sge_list);
14111409
if (ctx->rwr != NULL)
@@ -1507,8 +1505,7 @@ int destroy_ctx(struct pingpong_context *ctx,
15071505
test_result = 1;
15081506
}
15091507

1510-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
1511-
|| (user_param->connection_type == DC && !dct_only)){
1508+
if (has_recv_comp(user_param->verb) || (user_param->connection_type == DC && !dct_only)){
15121509
if (ibv_destroy_cq(ctx->recv_cq)) {
15131510
fprintf(stderr, "Failed to destroy CQ - %s\n", strerror(errno));
15141511
test_result = 1;
@@ -1650,7 +1647,7 @@ int destroy_ctx(struct pingpong_context *ctx,
16501647
free(ctx->wr);
16511648
}
16521649

1653-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
1650+
if (has_recv_comp(user_param->verb)
16541651
&& (user_param->tst == LAT || user_param->machine == SERVER || user_param->duplex)) {
16551652

16561653
free(ctx->rx_buffer_addr);
@@ -1907,8 +1904,7 @@ int create_cqs(struct pingpong_context *ctx, struct perftest_parameters *user_pa
19071904
if (dct_only)
19081905
tx_buffer_depth = user_param->rx_depth;
19091906

1910-
if ((user_param->connection_type == DC && !dct_only)
1911-
|| (user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM))
1907+
if ((user_param->connection_type == DC && !dct_only) || has_recv_comp(user_param->verb))
19121908
need_recv_cq = 1;
19131909

19141910
ret = create_reg_cqs(ctx, user_param, tx_buffer_depth, need_recv_cq);
@@ -2776,8 +2772,7 @@ xrcd: __attribute__((unused))
27762772
cqs:
27772773
ibv_destroy_cq(ctx->send_cq);
27782774

2779-
if ((user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM)
2780-
|| (user_param->connection_type == DC && !dct_only)){
2775+
if (has_recv_comp(user_param->verb) || (user_param->connection_type == DC && !dct_only)) {
27812776
ibv_destroy_cq(ctx->recv_cq);
27822777
}
27832778

@@ -2931,7 +2926,7 @@ struct ibv_qp* ctx_qp_create(struct pingpong_context *ctx,
29312926
#endif
29322927

29332928
attr.send_cq = ctx->send_cq;
2934-
attr.recv_cq = (user_param->verb == SEND || user_param->verb == SEND_IMM || user_param->verb == WRITE_IMM) ? ctx->recv_cq : ctx->send_cq;
2929+
attr.recv_cq = has_recv_comp(user_param->verb) ? ctx->recv_cq : ctx->send_cq;
29352930

29362931
is_dc_server_side = ((!(user_param->duplex || user_param->tst == LAT) &&
29372932
(user_param->machine == SERVER)) ||
@@ -5111,7 +5106,7 @@ int run_iter_bw_infinitely(struct pingpong_context *ctx,struct perftest_paramete
51115106
return FAILURE;
51125107
}
51135108

5114-
if (!user_param->duplex && user_param->verb != WRITE_IMM && user_param->verb != SEND && user_param->verb != SEND_IMM) {
5109+
if (!user_param->duplex && !has_recv_comp(user_param->verb)) {
51155110
signal(SIGINT, handle_sigint);
51165111
}
51175112

0 commit comments

Comments
 (0)