|
1 diff -r -u /tmp/perftest-1.3.0/Makefile perftest-1.3.0/Makefile |
|
2 --- /tmp/perftest-1.3.0/Makefile Thu Jan 20 01:37:35 2011 |
|
3 +++ perftest-1.3.0/Makefile Fri Feb 11 04:12:45 2011 |
|
4 @@ -2,6 +2,7 @@ |
|
5 MCAST_TESTS = send_bw send_lat |
|
6 TESTS = write_bw_postlist write_lat write_bw read_lat read_bw |
|
7 UTILS = clock_test |
|
8 +BINS = ib_write_bw_postlist rdma_lat rdma_bw ib_send_lat ib_send_bw ib_write_lat ib_write_bw ib_read_lat ib_read_bw ib_clock_test |
|
9 |
|
10 all: ${RDMACM_TESTS} ${MCAST_TESTS} ${TESTS} ${UTILS} |
|
11 |
|
12 @@ -12,13 +13,14 @@ |
|
13 BASIC_HEADERS = get_clock.h |
|
14 EXTRA_HEADERS = perftest_resources.h |
|
15 MCAST_HEADERS = multicast_resources.h |
|
16 +CC=gcc |
|
17 #The following seems to help GNU make on some platforms |
|
18 LOADLIBES += |
|
19 LDFLAGS += |
|
20 |
|
21 -${RDMACM_TESTS}: LOADLIBES += -libverbs -lrdmacm |
|
22 -${MCAST_TESTS}: LOADLIBES += -libverbs -libumad -lm |
|
23 -${TESTS} ${UTILS}: LOADLIBES += -libverbs |
|
24 +${RDMACM_TESTS}: LOADLIBES += -lsocket -libverbs -lrdmacm -lrt |
|
25 +${MCAST_TESTS}: LOADLIBES += -lsocket -libverbs -lrdmacm -lrt -libumad -lm |
|
26 +${TESTS} ${UTILS}: LOADLIBES += -lsocket -lrt -libverbs |
|
27 |
|
28 ${RDMACM_TESTS}: %: %.c ${BASIC_FILES} ${BASIC_HEADERS} |
|
29 $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< ${BASIC_FILES} $(LOADLIBES) $(LDLIBS) -o $@ |
|
30 @@ -27,6 +29,10 @@ |
|
31 ${TESTS} ${UTILS}: %: %.c ${BASIC_FILES} ${EXTRA_FILES} ${BASIC_HEADERS} ${EXTRA_HEADERS} |
|
32 $(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< ${BASIC_FILES} ${EXTRA_FILES} $(LOADLIBES) $(LDLIBS) -o ib_$@ |
|
33 |
|
34 +install: all |
|
35 + $(INSTALL) -d $(DESTDIR)$(BINDIR) |
|
36 + $(INSTALL) -m 755 -s $(BINS) $(DESTDIR)$(BINDIR) |
|
37 + |
|
38 clean: |
|
39 $(foreach fname,${RDMACM_TESTS}, rm -f ${fname}) |
|
40 $(foreach fname,${MCAST_TESTS}, rm -f ib_${fname}) |
|
41 diff -r -u /tmp/perftest-1.3.0/get_clock.c perftest-1.3.0/get_clock.c |
|
42 --- /tmp/perftest-1.3.0/get_clock.c Sun Dec 19 06:36:26 2010 |
|
43 +++ perftest-1.3.0/get_clock.c Fri Feb 11 04:12:46 2011 |
|
44 @@ -45,6 +45,9 @@ |
|
45 #include <unistd.h> |
|
46 #include <stdio.h> |
|
47 #include "get_clock.h" |
|
48 +#if defined(__SVR4) && defined(__sun) |
|
49 +#include <infiniband/ofa_solaris.h> |
|
50 +#endif |
|
51 |
|
52 #ifndef DEBUG |
|
53 #define DEBUG 0 |
|
54 @@ -137,7 +140,11 @@ |
|
55 FILE* f; |
|
56 char buf[256]; |
|
57 double mhz = 0.0; |
|
58 +#if defined(__SVR4) && defined(__sun) |
|
59 + sol_cpu_info_t info; |
|
60 +#endif |
|
61 |
|
62 +#if !(defined(__SVR4) && defined(__sun)) |
|
63 f = fopen("/proc/cpuinfo","r"); |
|
64 if (!f) |
|
65 return 0.0; |
|
66 @@ -174,6 +181,12 @@ |
|
67 } |
|
68 } |
|
69 fclose(f); |
|
70 +#else |
|
71 + if (!sol_get_cpu_info(&info)) |
|
72 + mhz = info.cpu_mhz; |
|
73 + else |
|
74 + return (0.0); |
|
75 +#endif |
|
76 return mhz; |
|
77 } |
|
78 |
|
79 @@ -184,9 +197,6 @@ |
|
80 sample = sample_get_cpu_mhz(); |
|
81 proc = proc_get_cpu_mhz(no_cpu_freq_fail); |
|
82 |
|
83 - if (!proc || !sample) |
|
84 - return 0; |
|
85 - |
|
86 delta = proc > sample ? proc - sample : sample - proc; |
|
87 if (delta / proc > 0.01) { |
|
88 fprintf(stderr, "Warning: measured timestamp frequency " |
|
89 diff -r -u /tmp/perftest-1.3.0/get_clock.h perftest-1.3.0/get_clock.h |
|
90 --- /tmp/perftest-1.3.0/get_clock.h Sun Nov 1 03:09:16 2009 |
|
91 +++ perftest-1.3.0/get_clock.h Fri Feb 11 04:12:46 2011 |
|
92 @@ -71,6 +71,23 @@ |
|
93 return ret; |
|
94 } |
|
95 |
|
96 +#elif defined(__sparc) |
|
97 +#include <sys/times.h> |
|
98 +#include <limits.h> |
|
99 +typedef long cycles_t; |
|
100 + |
|
101 +static inline cycles_t get_cycles() |
|
102 +{ |
|
103 + struct timespec tp; |
|
104 + long time; |
|
105 + |
|
106 + if (clock_gettime(CLOCK_HIGHRES, &tp)) |
|
107 + return -1; |
|
108 + |
|
109 + time = (tp.tv_sec * 1000000) + (tp.tv_nsec / 1000); |
|
110 + return time; |
|
111 +} |
|
112 + |
|
113 #else |
|
114 #warning get_cycles not implemented for this architecture: attempt asm/timex.h |
|
115 #include <asm/timex.h> |
|
116 diff -r -u /tmp/perftest-1.3.0/rdma_bw.c perftest-1.3.0/rdma_bw.c |
|
117 --- /tmp/perftest-1.3.0/rdma_bw.c Wed Apr 7 09:44:56 2010 |
|
118 +++ perftest-1.3.0/rdma_bw.c Fri Feb 11 04:12:46 2011 |
|
119 @@ -50,8 +50,11 @@ |
|
120 #include <malloc.h> |
|
121 #include <getopt.h> |
|
122 #include <arpa/inet.h> |
|
123 +#if !(defined(__SVR4) && defined(__sun)) |
|
124 #include <byteswap.h> |
|
125 +#endif |
|
126 #include <time.h> |
|
127 +#include <inttypes.h> |
|
128 |
|
129 #include <infiniband/verbs.h> |
|
130 #include <rdma/rdma_cma.h> |
|
131 @@ -144,7 +147,7 @@ |
|
132 |
|
133 if (n < 0) { |
|
134 fprintf(stderr, "%d:%s: %s for %s:%d\n", |
|
135 - pid, __func__, gai_strerror(n), |
|
136 + (int)pid, __func__, gai_strerror(n), |
|
137 data->servername, data->port); |
|
138 goto err4; |
|
139 } |
|
140 @@ -157,7 +160,7 @@ |
|
141 if (rdma_resolve_addr(data->cm_id, NULL, |
|
142 (struct sockaddr *)&sin, 2000)) { |
|
143 fprintf(stderr, "%d:%s: rdma_resolve_addr failed\n", |
|
144 - pid, __func__ ); |
|
145 + (int)pid, __func__ ); |
|
146 goto err2; |
|
147 } |
|
148 |
|
149 @@ -172,7 +175,7 @@ |
|
150 |
|
151 if (event->event != RDMA_CM_EVENT_ADDR_RESOLVED) { |
|
152 fprintf(stderr, "%d:%s: unexpected CM event %d\n", |
|
153 - pid, __func__, event->event); |
|
154 + (int)pid, __func__, event->event); |
|
155 goto err1; |
|
156 } |
|
157 rdma_ack_cm_event(event); |
|
158 @@ -180,7 +183,7 @@ |
|
159 retry_route: |
|
160 if (rdma_resolve_route(data->cm_id, 2000)) { |
|
161 fprintf(stderr, "%d:%s: rdma_resolve_route failed\n", |
|
162 - pid, __func__); |
|
163 + (int)pid, __func__); |
|
164 goto err2; |
|
165 } |
|
166 |
|
167 @@ -195,7 +198,7 @@ |
|
168 |
|
169 if (event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) { |
|
170 fprintf(stderr, "%d:%s: unexpected CM event %d\n", |
|
171 - pid, __func__, event->event); |
|
172 + (int)pid, __func__, event->event); |
|
173 rdma_ack_cm_event(event); |
|
174 goto err1; |
|
175 } |
|
176 @@ -202,7 +205,7 @@ |
|
177 rdma_ack_cm_event(event); |
|
178 ctx = pp_init_ctx(data->cm_id, data); |
|
179 if (!ctx) { |
|
180 - fprintf(stderr, "%d:%s: pp_init_ctx failed\n", pid, __func__); |
|
181 + fprintf(stderr, "%d:%s: pp_init_ctx failed\n", (int)pid, __func__); |
|
182 goto err2; |
|
183 } |
|
184 data->my_dest.psn = lrand48() & 0xffffff; |
|
185 @@ -218,7 +221,7 @@ |
|
186 conn_param.private_data_len = sizeof(data->my_dest); |
|
187 |
|
188 if (rdma_connect(data->cm_id, &conn_param)) { |
|
189 - fprintf(stderr, "%d:%s: rdma_connect failure\n", pid, __func__); |
|
190 + fprintf(stderr, "%d:%s: rdma_connect failure\n", (int)pid, __func__); |
|
191 goto err2; |
|
192 } |
|
193 |
|
194 @@ -227,13 +230,13 @@ |
|
195 |
|
196 if (event->event != RDMA_CM_EVENT_ESTABLISHED) { |
|
197 fprintf(stderr, "%d:%s: unexpected CM event %d\n", |
|
198 - pid, __func__, event->event); |
|
199 + (int)pid, __func__, event->event); |
|
200 goto err1; |
|
201 } |
|
202 if (!event->param.conn.private_data || |
|
203 (event->param.conn.private_data_len < sizeof(*data->rem_dest))) { |
|
204 fprintf(stderr, "%d:%s: bad private data ptr %p len %d\n", |
|
205 - pid, __func__, event->param.conn.private_data, |
|
206 + (int)pid, __func__, event->param.conn.private_data, |
|
207 event->param.conn.private_data_len); |
|
208 goto err1; |
|
209 } |
|
210 @@ -257,7 +260,7 @@ |
|
211 } |
|
212 if (sockfd < 0) { |
|
213 fprintf(stderr, "%d:%s: Couldn't connect to %s:%d\n", |
|
214 - pid, __func__, data->servername, data->port); |
|
215 + (int)pid, __func__, data->servername, data->port); |
|
216 goto err3; |
|
217 } |
|
218 ctx = pp_init_ctx(data->ib_dev, data); |
|
219 @@ -287,13 +290,13 @@ |
|
220 int parsed; |
|
221 |
|
222 if (!data->use_cma) { |
|
223 - sprintf(msg, "%04x:%06x:%06x:%08x:%016Lx", data->my_dest.lid, |
|
224 + sprintf(msg, "%04x:%06x:%06x:%08x:%016llx", data->my_dest.lid, |
|
225 data->my_dest.qpn, data->my_dest.psn, |
|
226 data->my_dest.rkey, data->my_dest.vaddr); |
|
227 if (write(data->sockfd, msg, sizeof msg) != sizeof msg) { |
|
228 perror("client write"); |
|
229 fprintf(stderr, "%d:%s: Couldn't send local address\n", |
|
230 - pid, __func__); |
|
231 + (int)pid, __func__); |
|
232 goto err; |
|
233 } |
|
234 |
|
235 @@ -300,7 +303,7 @@ |
|
236 if (read(data->sockfd, msg, sizeof msg) != sizeof msg) { |
|
237 perror("client read"); |
|
238 fprintf(stderr, "%d:%s: Couldn't read remote address\n", |
|
239 - pid, __func__); |
|
240 + (int)pid, __func__); |
|
241 goto err; |
|
242 } |
|
243 |
|
244 @@ -310,7 +313,7 @@ |
|
245 if (!data->rem_dest) |
|
246 goto err; |
|
247 |
|
248 - parsed = sscanf(msg, "%x:%x:%x:%x:%Lx", &data->rem_dest->lid, |
|
249 + parsed = sscanf(msg, "%x:%x:%x:%x:%llx", &data->rem_dest->lid, |
|
250 &data->rem_dest->qpn, &data->rem_dest->psn, |
|
251 &data->rem_dest->rkey, &data->rem_dest->vaddr); |
|
252 |
|
253 @@ -347,7 +350,7 @@ |
|
254 goto err5; |
|
255 |
|
256 if ( (n = getaddrinfo(NULL, service, &hints, &res)) < 0 ) { |
|
257 - fprintf(stderr, "%d:%s: %s for port %d\n", pid, __func__, |
|
258 + fprintf(stderr, "%d:%s: %s for port %d\n", (int)pid, __func__, |
|
259 gai_strerror(n), data->port); |
|
260 goto err5; |
|
261 } |
|
262 @@ -357,12 +360,12 @@ |
|
263 sin.sin_family = AF_INET; |
|
264 sin.sin_port = htons(data->port); |
|
265 if (rdma_bind_addr(data->cm_id, (struct sockaddr *)&sin)) { |
|
266 - fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", pid, __func__); |
|
267 + fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", (int)pid, __func__); |
|
268 goto err3; |
|
269 } |
|
270 |
|
271 if (rdma_listen(data->cm_id, 0)) { |
|
272 - fprintf(stderr, "%d:%s: rdma_listen failed\n", pid, __func__); |
|
273 + fprintf(stderr, "%d:%s: rdma_listen failed\n", (int)pid, __func__); |
|
274 goto err3; |
|
275 } |
|
276 |
|
277 @@ -371,13 +374,13 @@ |
|
278 |
|
279 if (event->event != RDMA_CM_EVENT_CONNECT_REQUEST) { |
|
280 fprintf(stderr, "%d:%s: bad event waiting for connect request %d\n", |
|
281 - pid, __func__, event->event); |
|
282 + (int)pid, __func__, event->event); |
|
283 goto err2; |
|
284 } |
|
285 |
|
286 if (!event->param.conn.private_data || |
|
287 (event->param.conn.private_data_len < sizeof(*data->rem_dest))) { |
|
288 - fprintf(stderr, "%d:%s: bad private data len %d\n", pid, |
|
289 + fprintf(stderr, "%d:%s: bad private data len %d\n", (int)pid, |
|
290 __func__, event->param.conn.private_data_len); |
|
291 goto err2; |
|
292 } |
|
293 @@ -405,18 +408,18 @@ |
|
294 conn_param.private_data = &data->my_dest; |
|
295 conn_param.private_data_len = sizeof(data->my_dest); |
|
296 if (rdma_accept(child_cm_id, &conn_param)) { |
|
297 - fprintf(stderr, "%d:%s: rdma_accept failed\n", pid, __func__); |
|
298 + fprintf(stderr, "%d:%s: rdma_accept failed\n", (int)pid, __func__); |
|
299 goto err1; |
|
300 } |
|
301 rdma_ack_cm_event(event); |
|
302 if (rdma_get_cm_event(data->cm_channel, &event)) { |
|
303 - fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", pid, __func__); |
|
304 + fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", (int)pid, __func__); |
|
305 rdma_destroy_id(child_cm_id); |
|
306 goto err3; |
|
307 } |
|
308 if (event->event != RDMA_CM_EVENT_ESTABLISHED) { |
|
309 fprintf(stderr, "%d:%s: bad event waiting for established %d\n", |
|
310 - pid, __func__, event->event); |
|
311 + (int)pid, __func__, event->event); |
|
312 goto err1; |
|
313 } |
|
314 rdma_ack_cm_event(event); |
|
315 @@ -436,7 +439,7 @@ |
|
316 } |
|
317 |
|
318 if (sockfd < 0) { |
|
319 - fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", pid, |
|
320 + fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", (int)pid, |
|
321 __func__, data->port); |
|
322 goto err4; |
|
323 } |
|
324 @@ -445,7 +448,7 @@ |
|
325 connfd = accept(sockfd, NULL, 0); |
|
326 if (connfd < 0) { |
|
327 perror("server accept"); |
|
328 - fprintf(stderr, "%d:%s: accept() failed\n", pid, __func__); |
|
329 + fprintf(stderr, "%d:%s: accept() failed\n", (int)pid, __func__); |
|
330 close(sockfd); |
|
331 goto err4; |
|
332 } |
|
333 @@ -485,7 +488,7 @@ |
|
334 if (n != sizeof msg) { |
|
335 perror("server read"); |
|
336 fprintf(stderr, "%d:%s: %d/%d Couldn't read remote address\n", |
|
337 - pid, __func__, n, (int) sizeof msg); |
|
338 + (int)pid, __func__, n, (int) sizeof msg); |
|
339 goto err; |
|
340 } |
|
341 |
|
342 @@ -495,23 +498,23 @@ |
|
343 if (!data->rem_dest) |
|
344 goto err; |
|
345 |
|
346 - parsed = sscanf(msg, "%x:%x:%x:%x:%Lx", &data->rem_dest->lid, |
|
347 + parsed = sscanf(msg, "%x:%x:%x:%x:%llx", &data->rem_dest->lid, |
|
348 &data->rem_dest->qpn, &data->rem_dest->psn, |
|
349 &data->rem_dest->rkey, &data->rem_dest->vaddr); |
|
350 if (parsed != 5) { |
|
351 - fprintf(stderr, "%d:%s: Couldn't parse line <%.*s>\n", pid, |
|
352 + fprintf(stderr, "%d:%s: Couldn't parse line <%.*s>\n", (int)pid, |
|
353 __func__, (int)sizeof msg, msg); |
|
354 free(data->rem_dest); |
|
355 goto err; |
|
356 } |
|
357 |
|
358 - sprintf(msg, "%04x:%06x:%06x:%08x:%016Lx", data->my_dest.lid, |
|
359 + sprintf(msg, "%04x:%06x:%06x:%08x:%016llx", data->my_dest.lid, |
|
360 data->my_dest.qpn, data->my_dest.psn, |
|
361 data->my_dest.rkey, data->my_dest.vaddr); |
|
362 if (write(data->sockfd, msg, sizeof msg) != sizeof msg) { |
|
363 perror("server write"); |
|
364 fprintf(stderr, "%d:%s: Couldn't send local address\n", |
|
365 - pid, __func__); |
|
366 + (int)pid, __func__); |
|
367 free(data->rem_dest); |
|
368 goto err; |
|
369 } |
|
370 @@ -538,7 +541,7 @@ |
|
371 ctx->buf = memalign(page_size, ctx->size * 2); |
|
372 if (!ctx->buf) { |
|
373 fprintf(stderr, "%d:%s: Couldn't allocate work buf.\n", |
|
374 - pid, __func__); |
|
375 + (int)pid, __func__); |
|
376 return NULL; |
|
377 } |
|
378 |
|
379 @@ -548,7 +551,7 @@ |
|
380 cm_id = (struct rdma_cm_id *)ptr; |
|
381 ctx->context = cm_id->verbs; |
|
382 if (!ctx->context) { |
|
383 - fprintf(stderr, "%d:%s: Unbound cm_id!!\n", pid, |
|
384 + fprintf(stderr, "%d:%s: Unbound cm_id!!\n", (int)pid, |
|
385 __func__); |
|
386 return NULL; |
|
387 } |
|
388 @@ -558,7 +561,7 @@ |
|
389 ctx->context = ibv_open_device(ib_dev); |
|
390 if (!ctx->context) { |
|
391 fprintf(stderr, "%d:%s: Couldn't get context for %s\n", |
|
392 - pid, __func__, ibv_get_device_name(ib_dev)); |
|
393 + (int)pid, __func__, ibv_get_device_name(ib_dev)); |
|
394 return NULL; |
|
395 } |
|
396 } |
|
397 @@ -565,7 +568,7 @@ |
|
398 |
|
399 ctx->pd = ibv_alloc_pd(ctx->context); |
|
400 if (!ctx->pd) { |
|
401 - fprintf(stderr, "%d:%s: Couldn't allocate PD\n", pid, __func__); |
|
402 + fprintf(stderr, "%d:%s: Couldn't allocate PD\n", (int)pid, __func__); |
|
403 return NULL; |
|
404 } |
|
405 |
|
406 @@ -575,7 +578,7 @@ |
|
407 ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, ctx->size * 2, |
|
408 IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_LOCAL_WRITE); |
|
409 if (!ctx->mr) { |
|
410 - fprintf(stderr, "%d:%s: Couldn't allocate MR\n", pid, __func__); |
|
411 + fprintf(stderr, "%d:%s: Couldn't allocate MR\n", (int)pid, __func__); |
|
412 return NULL; |
|
413 } |
|
414 |
|
415 @@ -582,7 +585,7 @@ |
|
416 |
|
417 ctx->ch = ibv_create_comp_channel(ctx->context); |
|
418 if (!ctx->ch) { |
|
419 - fprintf(stderr, "%d:%s: Couldn't create comp channel\n", pid, |
|
420 + fprintf(stderr, "%d:%s: Couldn't create comp channel\n", (int)pid, |
|
421 __func__); |
|
422 return NULL; |
|
423 } |
|
424 @@ -589,7 +592,7 @@ |
|
425 |
|
426 ctx->rcq = ibv_create_cq(ctx->context, 1, NULL, NULL, 0); |
|
427 if (!ctx->rcq) { |
|
428 - fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", pid, |
|
429 + fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", (int)pid, |
|
430 __func__); |
|
431 return NULL; |
|
432 } |
|
433 @@ -596,7 +599,7 @@ |
|
434 |
|
435 ctx->scq = ibv_create_cq(ctx->context, ctx->tx_depth, ctx, ctx->ch, 0); |
|
436 if (!ctx->scq) { |
|
437 - fprintf(stderr, "%d:%s: Couldn't create send CQ\n", pid, |
|
438 + fprintf(stderr, "%d:%s: Couldn't create send CQ\n", (int)pid, |
|
439 __func__); |
|
440 return NULL; |
|
441 } |
|
442 @@ -619,7 +622,7 @@ |
|
443 |
|
444 if (data->use_cma) { |
|
445 if (rdma_create_qp(cm_id, ctx->pd, &attr)) { |
|
446 - fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__); |
|
447 + fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__); |
|
448 return NULL; |
|
449 } |
|
450 ctx->qp = cm_id->qp; |
|
451 @@ -628,7 +631,7 @@ |
|
452 } else { |
|
453 ctx->qp = ibv_create_qp(ctx->pd, &attr); |
|
454 if (!ctx->qp) { |
|
455 - fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__); |
|
456 + fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__); |
|
457 return NULL; |
|
458 } |
|
459 { |
|
460 @@ -645,7 +648,7 @@ |
|
461 IBV_QP_PORT | |
|
462 IBV_QP_ACCESS_FLAGS)) { |
|
463 fprintf(stderr, "%d:%s: Failed to modify QP to INIT\n", |
|
464 - pid, __func__); |
|
465 + (int)pid, __func__); |
|
466 return NULL; |
|
467 } |
|
468 } |
|
469 @@ -679,7 +682,7 @@ |
|
470 IBV_QP_RQ_PSN | |
|
471 IBV_QP_MAX_DEST_RD_ATOMIC | |
|
472 IBV_QP_MIN_RNR_TIMER)) { |
|
473 - fprintf(stderr, "%d:%s: Failed to modify QP to RTR\n", pid, __func__); |
|
474 + fprintf(stderr, "%d:%s: Failed to modify QP to RTR\n", (int)pid, __func__); |
|
475 return 1; |
|
476 } |
|
477 |
|
478 @@ -696,7 +699,7 @@ |
|
479 IBV_QP_RNR_RETRY | |
|
480 IBV_QP_SQ_PSN | |
|
481 IBV_QP_MAX_QP_RD_ATOMIC)) { |
|
482 - fprintf(stderr, "%d:%s: Failed to modify QP to RTS\n", pid, __func__); |
|
483 + fprintf(stderr, "%d:%s: Failed to modify QP to RTS\n", (int)pid, __func__); |
|
484 return 1; |
|
485 } |
|
486 |
|
487 @@ -720,7 +723,7 @@ |
|
488 rc = ibv_post_recv(ctx->qp, &wr, &bad_wr); |
|
489 if (rc) { |
|
490 perror("ibv_post_recv"); |
|
491 - fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", pid, |
|
492 + fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", (int)pid, |
|
493 __func__, rc); |
|
494 } |
|
495 } |
|
496 @@ -736,13 +739,13 @@ |
|
497 } while (ne == 0); |
|
498 |
|
499 if (wc.status) |
|
500 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
501 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
502 wc.status); |
|
503 if (!(wc.opcode & IBV_WC_RECV)) |
|
504 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
505 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
506 wc.opcode); |
|
507 if (wc.wr_id != 0xdeadbeef) |
|
508 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
509 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
510 (int)wc.wr_id); |
|
511 } |
|
512 |
|
513 @@ -762,7 +765,7 @@ |
|
514 ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
515 ctx->wr.next = NULL; |
|
516 if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) { |
|
517 - fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__); |
|
518 + fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__); |
|
519 return; |
|
520 } |
|
521 do { |
|
522 @@ -771,13 +774,13 @@ |
|
523 } while (ne == 0); |
|
524 |
|
525 if (wc.status) |
|
526 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
527 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
528 wc.status); |
|
529 if (wc.opcode != IBV_WC_SEND) |
|
530 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
531 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
532 wc.opcode); |
|
533 if (wc.wr_id != 0xcafebabe) |
|
534 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
535 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
536 (int)wc.wr_id); |
|
537 } |
|
538 |
|
539 @@ -792,13 +795,13 @@ |
|
540 } while (ne == 0); |
|
541 |
|
542 if (wc.status) |
|
543 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
544 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
545 wc.status); |
|
546 if (!(wc.opcode & IBV_WC_RECV)) |
|
547 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
548 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
549 wc.opcode); |
|
550 if (wc.wr_id != 0xdeadbeef) |
|
551 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
552 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
553 (int)wc.wr_id); |
|
554 pp_post_recv(ctx); |
|
555 } |
|
556 @@ -819,7 +822,7 @@ |
|
557 ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
558 ctx->wr.next = NULL; |
|
559 if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) { |
|
560 - fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__); |
|
561 + fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__); |
|
562 return; |
|
563 } |
|
564 do { |
|
565 @@ -828,13 +831,13 @@ |
|
566 } while (ne == 0); |
|
567 |
|
568 if (wc.status) |
|
569 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
570 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
571 wc.status); |
|
572 if (wc.opcode != IBV_WC_SEND) |
|
573 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
574 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
575 wc.opcode); |
|
576 if (wc.wr_id != 0xabbaabba) |
|
577 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
578 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
579 (int)wc.wr_id); |
|
580 } |
|
581 |
|
582 @@ -847,7 +850,7 @@ |
|
583 rc = rdma_disconnect(data.cm_id); |
|
584 if (rc) { |
|
585 perror("rdma_disconnect"); |
|
586 - fprintf(stderr, "%d:%s: rdma disconnect error\n", pid, |
|
587 + fprintf(stderr, "%d:%s: rdma disconnect error\n", (int)pid, |
|
588 __func__); |
|
589 return; |
|
590 } |
|
591 @@ -856,7 +859,7 @@ |
|
592 rdma_get_cm_event(data.cm_channel, &event); |
|
593 if (event->event != RDMA_CM_EVENT_DISCONNECTED) |
|
594 fprintf(stderr, "%d:%s: unexpected event during disconnect %d\n", |
|
595 - pid, __func__, event->event); |
|
596 + (int)pid, __func__, event->event); |
|
597 rdma_ack_cm_event(event); |
|
598 rdma_destroy_id(data.cm_id); |
|
599 rdma_destroy_event_channel(data.cm_channel); |
|
600 @@ -909,17 +912,17 @@ |
|
601 tsize = duplex ? 2 : 1; |
|
602 tsize = tsize * size; |
|
603 |
|
604 - printf("\n%d: Bandwidth peak (#%d to #%d): %g MB/sec\n", pid, |
|
605 + printf("\n%d: Bandwidth peak (#%d to #%d): %g MB/sec\n", (int)pid, |
|
606 opt_posted, opt_completed, |
|
607 tsize * cycles_to_units / opt_delta / 0x100000); |
|
608 - printf("%d: Bandwidth average: %g MB/sec\n", pid, |
|
609 + printf("%d: Bandwidth average: %g MB/sec\n", (int)pid, |
|
610 tsize * iters * cycles_to_units / |
|
611 (tcompleted[iters - 1] - tposted[0]) / 0x100000); |
|
612 |
|
613 - printf("%d: Service Demand peak (#%d to #%d): %ld cycles/KB\n", pid, |
|
614 + printf("%d: Service Demand peak (#%d to #%d): %ld cycles/KB\n", (int)pid, |
|
615 opt_posted, opt_completed, |
|
616 (unsigned long)opt_delta * 1024 / tsize); |
|
617 - printf("%d: Service Demand Avg : %ld cycles/KB\n", pid, |
|
618 + printf("%d: Service Demand Avg : %ld cycles/KB\n", (int)pid, |
|
619 (unsigned long)(tcompleted[iters - 1] - tposted[0]) * |
|
620 1024 / (tsize * iters)); |
|
621 } |
|
622 @@ -1046,7 +1049,7 @@ |
|
623 pid = getpid(); |
|
624 |
|
625 printf("%d: | port=%d | ib_port=%d | size=%d | tx_depth=%d | sl=%d | iters=%d | duplex=%d | cma=%d |\n", |
|
626 - pid, data.port, data.ib_port, data.size, data.tx_depth, |
|
627 + (int)pid, data.port, data.ib_port, data.size, data.tx_depth, |
|
628 sl, iters, duplex, data.use_cma); |
|
629 |
|
630 /* Done with parameter parsing. Perform setup. */ |
|
631 @@ -1059,12 +1062,12 @@ |
|
632 data.cm_channel = rdma_create_event_channel(); |
|
633 if (!data.cm_channel) { |
|
634 fprintf(stderr, "%d:%s: rdma_create_event_channel failed\n", |
|
635 - pid, __func__); |
|
636 + (int)pid, __func__); |
|
637 return 1; |
|
638 } |
|
639 if (rdma_create_id(data.cm_channel, &data.cm_id, NULL, RDMA_PS_TCP)) { |
|
640 fprintf(stderr, "%d:%s: rdma_create_id failed\n", |
|
641 - pid, __func__); |
|
642 + (int)pid, __func__); |
|
643 return 1; |
|
644 } |
|
645 |
|
646 @@ -1084,7 +1087,7 @@ |
|
647 data.ib_dev = dev_list[0]; |
|
648 if (!data.ib_dev) { |
|
649 fprintf(stderr, "%d:%s: No IB devices found\n", |
|
650 - pid, __func__); |
|
651 + (int)pid, __func__); |
|
652 return 1; |
|
653 } |
|
654 } else { |
|
655 @@ -1093,7 +1096,7 @@ |
|
656 break; |
|
657 if (!data.ib_dev) { |
|
658 fprintf(stderr, "%d:%s: IB device %s not found\n", |
|
659 - pid, __func__, ib_devname); |
|
660 + (int)pid, __func__, ib_devname); |
|
661 return 1; |
|
662 } |
|
663 } |
|
664 @@ -1109,7 +1112,7 @@ |
|
665 data.my_dest.lid = pp_get_local_lid(ctx, data.ib_port); |
|
666 if (!data.my_dest.lid) { |
|
667 fprintf(stderr, "%d:%s: Local lid 0x0 detected. Is an SM running?\n", |
|
668 - pid, __func__); |
|
669 + (int)pid, __func__); |
|
670 return 1; |
|
671 } |
|
672 data.my_dest.qpn = ctx->qp->qp_num; |
|
673 @@ -1129,12 +1132,12 @@ |
|
674 } |
|
675 |
|
676 printf("%d: Local address: LID %#04x, QPN %#06x, PSN %#06x " |
|
677 - "RKey %#08x VAddr %#016Lx\n", pid, |
|
678 + "RKey %#08x VAddr %#016llx\n", (int)pid, |
|
679 data.my_dest.lid, data.my_dest.qpn, data.my_dest.psn, |
|
680 data.my_dest.rkey, data.my_dest.vaddr); |
|
681 |
|
682 printf("%d: Remote address: LID %#04x, QPN %#06x, PSN %#06x, " |
|
683 - "RKey %#08x VAddr %#016Lx\n\n", pid, |
|
684 + "RKey %#08x VAddr %#016llx\n\n", (int)pid, |
|
685 data.rem_dest->lid, data.rem_dest->qpn, data.rem_dest->psn, |
|
686 data.rem_dest->rkey, data.rem_dest->vaddr); |
|
687 |
|
688 @@ -1219,7 +1222,7 @@ |
|
689 |
|
690 if (ibv_post_send(qp, &ctx->wr, &bad_wr)) { |
|
691 fprintf(stderr, "%d:%s: Couldn't post send: scnt=%d\n", |
|
692 - pid, __func__, scnt); |
|
693 + (int)pid, __func__, scnt); |
|
694 return 1; |
|
695 } |
|
696 ++scnt; |
|
697 @@ -1235,17 +1238,17 @@ |
|
698 tcompleted[ccnt] = get_cycles(); |
|
699 |
|
700 if (ne < 0) { |
|
701 - fprintf(stderr, "%d:%s: poll CQ failed %d\n", pid, |
|
702 + fprintf(stderr, "%d:%s: poll CQ failed %d\n", (int)pid, |
|
703 __func__, ne); |
|
704 return 1; |
|
705 } |
|
706 if (wc.status != IBV_WC_SUCCESS) { |
|
707 fprintf(stderr, "%d:%s: Completion with error at %s:\n", |
|
708 - pid, __func__, data.servername ? "client" : "server"); |
|
709 + (int)pid, __func__, data.servername ? "client" : "server"); |
|
710 fprintf(stderr, "%d:%s: Failed status %d: wr_id %d\n", |
|
711 - pid, __func__, wc.status, (int) wc.wr_id); |
|
712 + (int)pid, __func__, wc.status, (int) wc.wr_id); |
|
713 fprintf(stderr, "%d:%s: scnt=%d, ccnt=%d\n", |
|
714 - pid, __func__, scnt, ccnt); |
|
715 + (int)pid, __func__, scnt, ccnt); |
|
716 return 1; |
|
717 } |
|
718 ccnt += 1; |
|
719 diff -r -u /tmp/perftest-1.3.0/rdma_lat.c perftest-1.3.0/rdma_lat.c |
|
720 --- /tmp/perftest-1.3.0/rdma_lat.c Wed Apr 7 09:44:33 2010 |
|
721 +++ perftest-1.3.0/rdma_lat.c Fri Feb 11 04:12:46 2011 |
|
722 @@ -50,8 +50,11 @@ |
|
723 #include <malloc.h> |
|
724 #include <getopt.h> |
|
725 #include <arpa/inet.h> |
|
726 +#if !(defined(__SVR4) && defined(__sun)) |
|
727 #include <byteswap.h> |
|
728 +#endif |
|
729 #include <time.h> |
|
730 +#include <inttypes.h> |
|
731 |
|
732 #include <infiniband/verbs.h> |
|
733 #include <rdma/rdma_cma.h> |
|
734 @@ -59,7 +62,11 @@ |
|
735 #include "get_clock.h" |
|
736 |
|
737 #define PINGPONG_RDMA_WRID 3 |
|
738 +#if defined(__SVR4) && defined(__sun) |
|
739 +#define MAX_INLINE 372 |
|
740 +#else |
|
741 #define MAX_INLINE 400 |
|
742 +#endif |
|
743 |
|
744 static int inline_size = MAX_INLINE; |
|
745 static int sl = 0; |
|
746 @@ -155,7 +162,8 @@ |
|
747 } |
|
748 |
|
749 #define KEY_MSG_SIZE (sizeof "0000:000000:000000:00000000:0000000000000000") |
|
750 -#define KEY_PRINT_FMT "%04x:%06x:%06x:%08x:%016Lx" |
|
751 +#define KEY_PRINT_FMT "%04x:%06x:%06x:%08x:%016" "llx" |
|
752 +#define KEY_SCAN_FMT "%04x:%06x:%06x:%08x:%016" "llx" |
|
753 |
|
754 static int pp_write_keys(int sockfd, const struct pingpong_dest *my_dest) |
|
755 { |
|
756 @@ -185,7 +193,7 @@ |
|
757 return -1; |
|
758 } |
|
759 |
|
760 - parsed = sscanf(msg, KEY_PRINT_FMT, &rem_dest->lid, &rem_dest->qpn, |
|
761 + parsed = sscanf(msg, KEY_SCAN_FMT, &rem_dest->lid, &rem_dest->qpn, |
|
762 &rem_dest->psn, &rem_dest->rkey, &rem_dest->vaddr); |
|
763 |
|
764 if (parsed != 5) { |
|
765 @@ -220,7 +228,7 @@ |
|
766 |
|
767 if (n < 0) { |
|
768 fprintf(stderr, "%d:%s: %s for %s:%d\n", |
|
769 - pid, __func__, gai_strerror(n), |
|
770 + (int)pid, __func__, gai_strerror(n), |
|
771 data->servername, data->port); |
|
772 goto err4; |
|
773 } |
|
774 @@ -233,7 +241,7 @@ |
|
775 if (rdma_resolve_addr(data->cm_id, NULL, |
|
776 (struct sockaddr *)&sin, 2000)) { |
|
777 fprintf(stderr, "%d:%s: rdma_resolve_addr failed\n", |
|
778 - pid, __func__ ); |
|
779 + (int)pid, __func__ ); |
|
780 goto err2; |
|
781 } |
|
782 |
|
783 @@ -248,7 +256,7 @@ |
|
784 |
|
785 if (event->event != RDMA_CM_EVENT_ADDR_RESOLVED) { |
|
786 fprintf(stderr, "%d:%s: unexpected CM event %d\n", |
|
787 - pid, __func__, event->event); |
|
788 + (int)pid, __func__, event->event); |
|
789 goto err1; |
|
790 } |
|
791 rdma_ack_cm_event(event); |
|
792 @@ -256,7 +264,7 @@ |
|
793 retry_route: |
|
794 if (rdma_resolve_route(data->cm_id, 2000)) { |
|
795 fprintf(stderr, "%d:%s: rdma_resolve_route failed\n", |
|
796 - pid, __func__); |
|
797 + (int)pid, __func__); |
|
798 goto err2; |
|
799 } |
|
800 |
|
801 @@ -271,7 +279,7 @@ |
|
802 |
|
803 if (event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) { |
|
804 fprintf(stderr, "%d:%s: unexpected CM event %d\n", |
|
805 - pid, __func__, event->event); |
|
806 + (int)pid, __func__, event->event); |
|
807 rdma_ack_cm_event(event); |
|
808 goto err1; |
|
809 } |
|
810 @@ -278,7 +286,7 @@ |
|
811 rdma_ack_cm_event(event); |
|
812 ctx = pp_init_ctx(data->cm_id, data); |
|
813 if (!ctx) { |
|
814 - fprintf(stderr, "%d:%s: pp_init_ctx failed\n", pid, __func__); |
|
815 + fprintf(stderr, "%d:%s: pp_init_ctx failed\n", (int)pid, __func__); |
|
816 goto err2; |
|
817 } |
|
818 data->my_dest.psn = lrand48() & 0xffffff; |
|
819 @@ -294,7 +302,7 @@ |
|
820 conn_param.private_data_len = sizeof(data->my_dest); |
|
821 |
|
822 if (rdma_connect(data->cm_id, &conn_param)) { |
|
823 - fprintf(stderr, "%d:%s: rdma_connect failure\n", pid, __func__); |
|
824 + fprintf(stderr, "%d:%s: rdma_connect failure\n", (int)pid, __func__); |
|
825 goto err2; |
|
826 } |
|
827 |
|
828 @@ -303,13 +311,13 @@ |
|
829 |
|
830 if (event->event != RDMA_CM_EVENT_ESTABLISHED) { |
|
831 fprintf(stderr, "%d:%s: unexpected CM event %d\n", |
|
832 - pid, __func__, event->event); |
|
833 + (int)pid, __func__, event->event); |
|
834 goto err1; |
|
835 } |
|
836 if (!event->param.conn.private_data || |
|
837 (event->param.conn.private_data_len < sizeof(*data->rem_dest))) { |
|
838 fprintf(stderr, "%d:%s: bad private data ptr %p len %d\n", |
|
839 - pid, __func__, event->param.conn.private_data, |
|
840 + (int)pid, __func__, event->param.conn.private_data, |
|
841 event->param.conn.private_data_len); |
|
842 goto err1; |
|
843 } |
|
844 @@ -332,7 +340,7 @@ |
|
845 } |
|
846 if (sockfd < 0) { |
|
847 fprintf(stderr, "%d:%s: Couldn't connect to %s:%d\n", |
|
848 - pid, __func__, data->servername, data->port); |
|
849 + (int)pid, __func__, data->servername, data->port); |
|
850 goto err3; |
|
851 } |
|
852 ctx = pp_init_ctx(data->ib_dev, data); |
|
853 @@ -393,7 +401,7 @@ |
|
854 goto err5; |
|
855 |
|
856 if ( (n = getaddrinfo(NULL, service, &hints, &res)) < 0 ) { |
|
857 - fprintf(stderr, "%d:%s: %s for port %d\n", pid, __func__, |
|
858 + fprintf(stderr, "%d:%s: %s for port %d\n", (int)pid, __func__, |
|
859 gai_strerror(n), data->port); |
|
860 goto err5; |
|
861 } |
|
862 @@ -403,12 +411,12 @@ |
|
863 sin.sin_family = AF_INET; |
|
864 sin.sin_port = htons(data->port); |
|
865 if (rdma_bind_addr(data->cm_id, (struct sockaddr *)&sin)) { |
|
866 - fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", pid, __func__); |
|
867 + fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", (int)pid, __func__); |
|
868 goto err3; |
|
869 } |
|
870 |
|
871 if (rdma_listen(data->cm_id, 0)) { |
|
872 - fprintf(stderr, "%d:%s: rdma_listen failed\n", pid, __func__); |
|
873 + fprintf(stderr, "%d:%s: rdma_listen failed\n", (int)pid, __func__); |
|
874 goto err3; |
|
875 } |
|
876 |
|
877 @@ -417,13 +425,13 @@ |
|
878 |
|
879 if (event->event != RDMA_CM_EVENT_CONNECT_REQUEST) { |
|
880 fprintf(stderr, "%d:%s: bad event waiting for connect request %d\n", |
|
881 - pid, __func__, event->event); |
|
882 + (int)pid, __func__, event->event); |
|
883 goto err2; |
|
884 } |
|
885 |
|
886 if (!event->param.conn.private_data || |
|
887 (event->param.conn.private_data_len < sizeof(*data->rem_dest))) { |
|
888 - fprintf(stderr, "%d:%s: bad private data len %d\n", pid, |
|
889 + fprintf(stderr, "%d:%s: bad private data len %d\n", (int)pid, |
|
890 __func__, event->param.conn.private_data_len); |
|
891 goto err2; |
|
892 } |
|
893 @@ -451,18 +459,18 @@ |
|
894 conn_param.private_data = &data->my_dest; |
|
895 conn_param.private_data_len = sizeof(data->my_dest); |
|
896 if (rdma_accept(child_cm_id, &conn_param)) { |
|
897 - fprintf(stderr, "%d:%s: rdma_accept failed\n", pid, __func__); |
|
898 + fprintf(stderr, "%d:%s: rdma_accept failed\n", (int)pid, __func__); |
|
899 goto err1; |
|
900 } |
|
901 rdma_ack_cm_event(event); |
|
902 if (rdma_get_cm_event(data->cm_channel, &event)) { |
|
903 - fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", pid, __func__); |
|
904 + fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", (int)pid, __func__); |
|
905 rdma_destroy_id(child_cm_id); |
|
906 goto err3; |
|
907 } |
|
908 if (event->event != RDMA_CM_EVENT_ESTABLISHED) { |
|
909 fprintf(stderr, "%d:%s: bad event waiting for established %d\n", |
|
910 - pid, __func__, event->event); |
|
911 + (int)pid, __func__, event->event); |
|
912 goto err1; |
|
913 } |
|
914 rdma_ack_cm_event(event); |
|
915 @@ -482,7 +490,7 @@ |
|
916 } |
|
917 |
|
918 if (sockfd < 0) { |
|
919 - fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", pid, |
|
920 + fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", (int)pid, |
|
921 __func__, data->port); |
|
922 goto err4; |
|
923 } |
|
924 @@ -491,7 +499,7 @@ |
|
925 connfd = accept(sockfd, NULL, 0); |
|
926 if (connfd < 0) { |
|
927 perror("server accept"); |
|
928 - fprintf(stderr, "%d:%s: accept() failed\n", pid, __func__); |
|
929 + fprintf(stderr, "%d:%s: accept() failed\n", (int)pid, __func__); |
|
930 close(sockfd); |
|
931 goto err4; |
|
932 } |
|
933 @@ -551,7 +559,7 @@ |
|
934 ctx->buf = memalign(page_size, ctx->size * 2); |
|
935 if (!ctx->buf) { |
|
936 fprintf(stderr, "%d:%s: Couldn't allocate work buf.\n", |
|
937 - pid, __func__); |
|
938 + (int)pid, __func__); |
|
939 return NULL; |
|
940 } |
|
941 |
|
942 @@ -565,7 +573,7 @@ |
|
943 cm_id = (struct rdma_cm_id *)ptr; |
|
944 ctx->context = cm_id->verbs; |
|
945 if (!ctx->context) { |
|
946 - fprintf(stderr, "%d:%s: Unbound cm_id!!\n", pid, |
|
947 + fprintf(stderr, "%d:%s: Unbound cm_id!!\n", (int)pid, |
|
948 __func__); |
|
949 return NULL; |
|
950 } |
|
951 @@ -575,7 +583,7 @@ |
|
952 ctx->context = ibv_open_device(ib_dev); |
|
953 if (!ctx->context) { |
|
954 fprintf(stderr, "%d:%s: Couldn't get context for %s\n", |
|
955 - pid, __func__, ibv_get_device_name(ib_dev)); |
|
956 + (int)pid, __func__, ibv_get_device_name(ib_dev)); |
|
957 return NULL; |
|
958 } |
|
959 } |
|
960 @@ -582,7 +590,7 @@ |
|
961 |
|
962 ctx->pd = ibv_alloc_pd(ctx->context); |
|
963 if (!ctx->pd) { |
|
964 - fprintf(stderr, "%d:%s: Couldn't allocate PD\n", pid, __func__); |
|
965 + fprintf(stderr, "%d:%s: Couldn't allocate PD\n", (int)pid, __func__); |
|
966 return NULL; |
|
967 } |
|
968 |
|
969 @@ -592,13 +600,13 @@ |
|
970 ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, ctx->size * 2, |
|
971 IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_LOCAL_WRITE); |
|
972 if (!ctx->mr) { |
|
973 - fprintf(stderr, "%d:%s: Couldn't allocate MR\n", pid, __func__); |
|
974 + fprintf(stderr, "%d:%s: Couldn't allocate MR\n", (int)pid, __func__); |
|
975 return NULL; |
|
976 } |
|
977 |
|
978 ctx->rcq = ibv_create_cq(ctx->context, 1, NULL, NULL, 0); |
|
979 if (!ctx->rcq) { |
|
980 - fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", pid, |
|
981 + fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", (int)pid, |
|
982 __func__); |
|
983 return NULL; |
|
984 } |
|
985 @@ -605,7 +613,7 @@ |
|
986 |
|
987 ctx->scq = ibv_create_cq(ctx->context, ctx->tx_depth, ctx, NULL, 0); |
|
988 if (!ctx->scq) { |
|
989 - fprintf(stderr, "%d:%s: Couldn't create send CQ\n", pid, |
|
990 + fprintf(stderr, "%d:%s: Couldn't create send CQ\n", (int)pid, |
|
991 __func__); |
|
992 return NULL; |
|
993 } |
|
994 @@ -628,7 +636,7 @@ |
|
995 |
|
996 if (data->use_cma) { |
|
997 if (rdma_create_qp(cm_id, ctx->pd, &attr)) { |
|
998 - fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__); |
|
999 + fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__); |
|
1000 return NULL; |
|
1001 } |
|
1002 ctx->qp = cm_id->qp; |
|
1003 @@ -636,7 +644,7 @@ |
|
1004 } else { |
|
1005 ctx->qp = ibv_create_qp(ctx->pd, &attr); |
|
1006 if (!ctx->qp) { |
|
1007 - fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__); |
|
1008 + fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__); |
|
1009 return NULL; |
|
1010 } |
|
1011 { |
|
1012 @@ -653,7 +661,7 @@ |
|
1013 IBV_QP_PORT | |
|
1014 IBV_QP_ACCESS_FLAGS)) { |
|
1015 fprintf(stderr, "%d:%s: Failed to modify QP to INIT\n", |
|
1016 - pid, __func__); |
|
1017 + (int)pid, __func__); |
|
1018 return NULL; |
|
1019 } |
|
1020 } |
|
1021 @@ -710,10 +718,10 @@ |
|
1022 return 0; |
|
1023 } |
|
1024 |
|
1025 +#define ADDR_FMT "%8s address: LID %#04x QPN %#06x PSN %#06x RKey %#08x VAddr %#016" "llx" "\n" |
|
1026 + |
|
1027 static int pp_open_port(struct pingpong_context *ctx, struct pp_data *data ) |
|
1028 { |
|
1029 - char addr_fmt[] = "%8s address: LID %#04x QPN %#06x PSN %#06x RKey %#08x VAddr %#016Lx\n"; |
|
1030 - |
|
1031 /* Create connection between client and server. |
|
1032 * We do it by exchanging data over a TCP socket connection. */ |
|
1033 |
|
1034 @@ -727,7 +735,7 @@ |
|
1035 data->my_dest.rkey = ctx->mr->rkey; |
|
1036 data->my_dest.vaddr = (uintptr_t)ctx->buf + ctx->size; |
|
1037 |
|
1038 - printf(addr_fmt, "local", data->my_dest.lid, data->my_dest.qpn, data->my_dest.psn, |
|
1039 + printf(ADDR_FMT, "local", data->my_dest.lid, data->my_dest.qpn, data->my_dest.psn, |
|
1040 data->my_dest.rkey, data->my_dest.vaddr); |
|
1041 |
|
1042 if (data->servername) { |
|
1043 @@ -738,7 +746,7 @@ |
|
1044 return 1; |
|
1045 } |
|
1046 |
|
1047 - printf(addr_fmt, "remote", data->rem_dest->lid, data->rem_dest->qpn, |
|
1048 + printf(ADDR_FMT, "remote", data->rem_dest->lid, data->rem_dest->qpn, |
|
1049 data->rem_dest->psn, data->rem_dest->rkey, |
|
1050 data->rem_dest->vaddr); |
|
1051 |
|
1052 @@ -783,7 +791,7 @@ |
|
1053 rc = ibv_post_recv(ctx->qp, &wr, &bad_wr); |
|
1054 if (rc) { |
|
1055 perror("ibv_post_recv"); |
|
1056 - fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", pid, |
|
1057 + fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", (int)pid, |
|
1058 __func__, rc); |
|
1059 } |
|
1060 } |
|
1061 @@ -799,13 +807,13 @@ |
|
1062 } while (ne == 0); |
|
1063 |
|
1064 if (wc.status) |
|
1065 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
1066 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
1067 wc.status); |
|
1068 if (!(wc.opcode & IBV_WC_RECV)) |
|
1069 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
1070 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
1071 wc.opcode); |
|
1072 if (wc.wr_id != 0xdeadbeef) |
|
1073 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
1074 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
1075 (int)wc.wr_id); |
|
1076 } |
|
1077 |
|
1078 @@ -825,7 +833,7 @@ |
|
1079 ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
1080 ctx->wr.next = NULL; |
|
1081 if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) { |
|
1082 - fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__); |
|
1083 + fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__); |
|
1084 return; |
|
1085 } |
|
1086 do { |
|
1087 @@ -834,13 +842,13 @@ |
|
1088 } while (ne == 0); |
|
1089 |
|
1090 if (wc.status) |
|
1091 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
1092 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
1093 wc.status); |
|
1094 if (wc.opcode != IBV_WC_SEND) |
|
1095 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
1096 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
1097 wc.opcode); |
|
1098 if (wc.wr_id != 0xcafebabe) |
|
1099 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
1100 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
1101 (int)wc.wr_id); |
|
1102 } |
|
1103 |
|
1104 @@ -855,13 +863,13 @@ |
|
1105 } while (ne == 0); |
|
1106 |
|
1107 if (wc.status) |
|
1108 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
1109 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
1110 wc.status); |
|
1111 if (!(wc.opcode & IBV_WC_RECV)) |
|
1112 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
1113 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
1114 wc.opcode); |
|
1115 if (wc.wr_id != 0xdeadbeef) |
|
1116 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
1117 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
1118 (int)wc.wr_id); |
|
1119 pp_post_recv(ctx); |
|
1120 } |
|
1121 @@ -882,7 +890,7 @@ |
|
1122 ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
1123 ctx->wr.next = NULL; |
|
1124 if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) { |
|
1125 - fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__); |
|
1126 + fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__); |
|
1127 return; |
|
1128 } |
|
1129 do { |
|
1130 @@ -891,13 +899,13 @@ |
|
1131 } while (ne == 0); |
|
1132 |
|
1133 if (wc.status) |
|
1134 - fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__, |
|
1135 + fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__, |
|
1136 wc.status); |
|
1137 if (wc.opcode != IBV_WC_SEND) |
|
1138 - fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__, |
|
1139 + fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__, |
|
1140 wc.opcode); |
|
1141 if (wc.wr_id != 0xabbaabba) |
|
1142 - fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__, |
|
1143 + fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__, |
|
1144 (int)wc.wr_id); |
|
1145 } |
|
1146 |
|
1147 @@ -910,7 +918,7 @@ |
|
1148 rc = rdma_disconnect(data.cm_id); |
|
1149 if (rc) { |
|
1150 perror("rdma_disconnect"); |
|
1151 - fprintf(stderr, "%d:%s: rdma disconnect error\n", pid, |
|
1152 + fprintf(stderr, "%d:%s: rdma disconnect error\n", (int)pid, |
|
1153 __func__); |
|
1154 return; |
|
1155 } |
|
1156 @@ -919,7 +927,7 @@ |
|
1157 rdma_get_cm_event(data.cm_channel, &event); |
|
1158 if (event->event != RDMA_CM_EVENT_DISCONNECTED) |
|
1159 fprintf(stderr, "%d:%s: unexpected event during disconnect %d\n", |
|
1160 - pid, __func__, event->event); |
|
1161 + (int)pid, __func__, event->event); |
|
1162 rdma_ack_cm_event(event); |
|
1163 rdma_destroy_id(data.cm_id); |
|
1164 rdma_destroy_event_channel(data.cm_channel); |
|
1165 @@ -1164,12 +1172,12 @@ |
|
1166 data.cm_channel = rdma_create_event_channel(); |
|
1167 if (!data.cm_channel) { |
|
1168 fprintf(stderr, "%d:%s: rdma_create_event_channel failed\n", |
|
1169 - pid, __func__); |
|
1170 + (int)pid, __func__); |
|
1171 return 1; |
|
1172 } |
|
1173 if (rdma_create_id(data.cm_channel, &data.cm_id, NULL, RDMA_PS_TCP)) { |
|
1174 fprintf(stderr, "%d:%s: rdma_create_id failed\n", |
|
1175 - pid, __func__); |
|
1176 + (int)pid, __func__); |
|
1177 return 1; |
|
1178 } |
|
1179 |
|
1180 @@ -1184,12 +1192,12 @@ |
|
1181 } |
|
1182 |
|
1183 printf("%d: Local address: LID %#04x, QPN %#06x, PSN %#06x " |
|
1184 - "RKey %#08x VAddr %#016Lx\n", pid, |
|
1185 + "RKey %#08x VAddr %#016llx\n", (int)pid, |
|
1186 data.my_dest.lid, data.my_dest.qpn, data.my_dest.psn, |
|
1187 data.my_dest.rkey, data.my_dest.vaddr); |
|
1188 |
|
1189 printf("%d: Remote address: LID %#04x, QPN %#06x, PSN %#06x, " |
|
1190 - "RKey %#08x VAddr %#016Lx\n\n", pid, |
|
1191 + "RKey %#08x VAddr %#016llx\n\n", (int)pid, |
|
1192 data.rem_dest->lid, data.rem_dest->qpn, data.rem_dest->psn, |
|
1193 data.rem_dest->rkey, data.rem_dest->vaddr); |
|
1194 |
|
1195 diff -r -u /tmp/perftest-1.3.0/perftest_resources.c perftest-1.3.0/perftest_resources.c |
|
1196 --- /tmp/perftest-1.3.0/perftest_resources.c Tue Jan 25 23:31:57 2011 |
|
1197 +++ perftest-1.3.0/perftest_resources.c Fri Feb 11 04:12:48 2011 |
|
1198 @@ -11,7 +11,9 @@ |
|
1199 #include <sys/socket.h> |
|
1200 #include <netdb.h> |
|
1201 #include <math.h> |
|
1202 +#if !(defined(__SVR4) && defined(__sun)) |
|
1203 // #include <byteswap.h> |
|
1204 +#endif |
|
1205 #include "perftest_resources.h" |
|
1206 |
|
1207 |
|
1208 @@ -566,8 +568,22 @@ |
|
1209 |
|
1210 // User did not ask for specific mtu. |
|
1211 if (params->mtu == 0) { |
|
1212 +#if !(defined(__SVR4) && defined(__sun)) |
|
1213 params->curr_mtu = port_attr.active_mtu; |
|
1214 +#else |
|
1215 + struct ibv_device_attr device_attr; |
|
1216 |
|
1217 + if (ibv_query_device(context, &device_attr)) { |
|
1218 + fprintf(stderr, "Failed to query device props"); |
|
1219 + return -1; |
|
1220 + } |
|
1221 + |
|
1222 + if (device_attr.vendor_part_id == 23108) { |
|
1223 + params->curr_mtu = IBV_MTU_1024; |
|
1224 + } else { |
|
1225 + params->curr_mtu = IBV_MTU_2048; |
|
1226 + } |
|
1227 +#endif |
|
1228 } else { |
|
1229 |
|
1230 switch (params->mtu) { |
|
1231 diff -r -u /tmp/perftest-1.3.0/perftest_resources.h perftest-1.3.0/perftest_resources.h |
|
1232 --- /tmp/perftest-1.3.0/perftest_resources.h Tue Jan 25 23:31:57 2011 |
|
1233 +++ perftest-1.3.0/perftest_resources.h Fri Feb 11 04:12:48 2011 |
|
1234 @@ -78,7 +78,11 @@ |
|
1235 #define DEF_GID_INDEX (-1) |
|
1236 #define DEF_NUM_QPS (1) |
|
1237 #define DEF_INLINE_BW (0) |
|
1238 +#if defined(__SVR4) && defined(__sun) |
|
1239 +#define DEF_INLINE_LT (372) |
|
1240 +#else |
|
1241 #define DEF_INLINE_LT (400) |
|
1242 +#endif |
|
1243 #define DEF_RX_RDMA (1) |
|
1244 #define DEF_RX_SEND (600) |
|
1245 |
|
1246 @@ -96,7 +100,11 @@ |
|
1247 #define MIN_QP_NUM (1) |
|
1248 #define MAX_QP_NUM (8) |
|
1249 #define MIN_INLINE (0) |
|
1250 +#if defined(__SVR4) && defined(__sun) |
|
1251 +#define MAX_INLINE (372) |
|
1252 +#else |
|
1253 #define MAX_INLINE (400) |
|
1254 +#endif |
|
1255 #define MIN_QP_MCAST (1) |
|
1256 #define MAX_QP_MCAST (56) |
|
1257 #define MIN_RX (1) |
|
1258 @@ -128,10 +136,10 @@ |
|
1259 #define KEY_MSG_SIZE_GID 98 // Message size with gid (MGID as well). |
|
1260 |
|
1261 // The Format of the message we pass through sockets , without passing Gid. |
|
1262 -#define KEY_PRINT_FMT "%04x:%04x:%06x:%06x:%08x:%016Lx" |
|
1263 +#define KEY_PRINT_FMT "%04x:%04x:%06x:%06x:%08x:%016llx" |
|
1264 |
|
1265 // The Format of the message we pass through sockets (With Gid). |
|
1266 -#define KEY_PRINT_FMT_GID "%04x:%04x:%06x:%06x:%08x:%016Lx:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" |
|
1267 +#define KEY_PRINT_FMT_GID "%04x:%04x:%06x:%06x:%08x:%016llx:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x:%02x" |
|
1268 |
|
1269 // The Basic print format for all verbs. |
|
1270 #define BASIC_ADDR_FMT " %s address: LID %#04x QPN %#06x PSN %#06x" |
|
1271 @@ -140,7 +148,7 @@ |
|
1272 #define READ_FMT " OUT %#04x" |
|
1273 |
|
1274 // The print format of the pingpong_dest element for RDMA verbs. |
|
1275 -#define RDMA_FMT " RKey %#08x VAddr %#016Lx" |
|
1276 +#define RDMA_FMT " RKey %#08x VAddr %#016llx" |
|
1277 |
|
1278 // The print format of a global address or a multicast address. |
|
1279 #define GID_FMT " %s: %02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d\n" |
|
1280 @@ -154,10 +162,10 @@ |
|
1281 #define RESULT_FMT_LAT " #bytes #iterations t_min[usec] t_max[usec] t_typical[usec]\n" |
|
1282 |
|
1283 // Result print format |
|
1284 -#define REPORT_FMT " %-7lu %d %-7.2f %-7.2f\n" |
|
1285 +#define REPORT_FMT " %-7"PRIu64" %d %-7.2f %-7.2f\n" |
|
1286 |
|
1287 // Result print format for latency tests. |
|
1288 -#define REPORT_FMT_LAT " %-7lu %d %-7.2f %-7.2f %-7.2f\n" |
|
1289 +#define REPORT_FMT_LAT " %-7"PRIu64" %d %-7.2f %-7.2f %-7.2f\n" |
|
1290 |
|
1291 // Macro for allocating. |
|
1292 #define ALLOCATE(var,type,size) \ |
|
1293 diff -r -u /tmp/perftest-1.3.0/read_bw.c perftest-1.3.0/read_bw.c |
|
1294 --- /tmp/perftest-1.3.0/read_bw.c Tue Jan 25 23:31:57 2011 |
|
1295 +++ perftest-1.3.0/read_bw.c Fri Feb 11 04:12:47 2011 |
|
1296 @@ -44,6 +44,7 @@ |
|
1297 // #include <limits.h> |
|
1298 #include <malloc.h> |
|
1299 // #include <getopt.h> |
|
1300 +#include <inttypes.h> |
|
1301 #include <time.h> |
|
1302 #include <infiniband/verbs.h> |
|
1303 |
|
1304 diff -r -u /tmp/perftest-1.3.0/read_lat.c perftest-1.3.0/read_lat.c |
|
1305 --- /tmp/perftest-1.3.0/read_lat.c Tue Jan 25 23:31:57 2011 |
|
1306 +++ perftest-1.3.0/read_lat.c Fri Feb 11 04:12:47 2011 |
|
1307 @@ -46,6 +46,7 @@ |
|
1308 #include <malloc.h> |
|
1309 #include <getopt.h> |
|
1310 #include <time.h> |
|
1311 +#include <inttypes.h> |
|
1312 #include <infiniband/verbs.h> |
|
1313 |
|
1314 #include "get_clock.h" |
|
1315 diff -r -u /tmp/perftest-1.3.0/send_bw.c perftest-1.3.0/send_bw.c |
|
1316 --- /tmp/perftest-1.3.0/send_bw.c Thu Jan 20 07:37:18 2011 |
|
1317 +++ perftest-1.3.0/send_bw.c Fri Feb 11 04:12:47 2011 |
|
1318 @@ -1,1162 +1,1162 @@ |
|
1319 -/* |
|
1320 - * Copyright (c) 2005 Topspin Communications. All rights reserved. |
|
1321 - * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. |
|
1322 - * Copyright (c) 2009 HNR Consulting. All rights reserved. |
|
1323 - * |
|
1324 - * This software is available to you under a choice of one of two |
|
1325 - * licenses. You may choose to be licensed under the terms of the GNU |
|
1326 - * General Public License (GPL) Version 2, available from the file |
|
1327 - * COPYING in the main directory of this source tree, or the |
|
1328 - * OpenIB.org BSD license below: |
|
1329 - * |
|
1330 - * Redistribution and use in source and binary forms, with or |
|
1331 - * without modification, are permitted provided that the following |
|
1332 - * conditions are met: |
|
1333 - * |
|
1334 - * - Redistributions of source code must retain the above |
|
1335 - * copyright notice, this list of conditions and the following |
|
1336 - * disclaimer. |
|
1337 - * |
|
1338 - * - Redistributions in binary form must reproduce the above |
|
1339 - * copyright notice, this list of conditions and the following |
|
1340 - * disclaimer in the documentation and/or other materials |
|
1341 - * provided with the distribution. |
|
1342 - * |
|
1343 - * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
1344 - * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
1345 - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
1346 - * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
|
1347 - * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
1348 - * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
1349 - * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
1350 - * SOFTWARE. |
|
1351 - * |
|
1352 - * $Id$ |
|
1353 - */ |
|
1354 - |
|
1355 -#if HAVE_CONFIG_H |
|
1356 -# include <config.h> |
|
1357 -#endif /* HAVE_CONFIG_H */ |
|
1358 - |
|
1359 -#include <stdio.h> |
|
1360 -#include <stdlib.h> |
|
1361 -#include <unistd.h> |
|
1362 -#include <string.h> |
|
1363 -#include <limits.h> |
|
1364 -#include <malloc.h> |
|
1365 -#include <getopt.h> |
|
1366 -#include <time.h> |
|
1367 -#include <errno.h> |
|
1368 -#include <infiniband/verbs.h> |
|
1369 - |
|
1370 -#include "get_clock.h" |
|
1371 -#include "multicast_resources.h" |
|
1372 -#include "perftest_resources.h" |
|
1373 - |
|
1374 -#define VERSION 2.1 |
|
1375 - |
|
1376 -static int page_size; |
|
1377 -cycles_t *tposted; |
|
1378 -cycles_t *tcompleted; |
|
1379 - |
|
1380 -struct pingpong_context { |
|
1381 - struct ibv_context *context; |
|
1382 - struct ibv_comp_channel *channel; |
|
1383 - struct ibv_pd *pd; |
|
1384 - struct ibv_mr **mr; |
|
1385 - struct ibv_cq *cq; |
|
1386 - struct ibv_qp **qp; |
|
1387 - struct ibv_sge list; |
|
1388 - struct ibv_send_wr wr; |
|
1389 - struct ibv_sge *sge_list; |
|
1390 - struct ibv_recv_wr *rwr; |
|
1391 - struct ibv_ah *ah; |
|
1392 - void **buf; |
|
1393 - unsigned size; |
|
1394 - uint64_t *my_addr; |
|
1395 -}; |
|
1396 - |
|
1397 -/****************************************************************************** |
|
1398 - * |
|
1399 - ******************************************************************************/ |
|
1400 -static int set_mcast_group(struct pingpong_context *ctx, |
|
1401 - struct perftest_parameters *user_parm, |
|
1402 - struct mcast_parameters *mcg_params) { |
|
1403 - |
|
1404 - struct ibv_port_attr port_attr; |
|
1405 - |
|
1406 - if (ibv_query_gid(ctx->context,user_parm->ib_port,user_parm->gid_index,&mcg_params->port_gid)) { |
|
1407 - return 1; |
|
1408 - } |
|
1409 - |
|
1410 - if (ibv_query_pkey(ctx->context,user_parm->ib_port,DEF_PKEY_IDX,&mcg_params->pkey)) { |
|
1411 - return 1; |
|
1412 - } |
|
1413 - |
|
1414 - if (ibv_query_port(ctx->context,user_parm->ib_port,&port_attr)) { |
|
1415 - return 1; |
|
1416 - } |
|
1417 - mcg_params->sm_lid = port_attr.sm_lid; |
|
1418 - mcg_params->sm_sl = port_attr.sm_sl; |
|
1419 - mcg_params->ib_port = user_parm->ib_port; |
|
1420 - |
|
1421 - if (!strcmp(link_layer_str(user_parm->link_type),"IB")) { |
|
1422 - // Request for Mcast group create registery in SM. |
|
1423 - if (join_multicast_group(SUBN_ADM_METHOD_SET,mcg_params)) { |
|
1424 - fprintf(stderr,"Couldn't Register the Mcast group on the SM\n"); |
|
1425 - return 1; |
|
1426 - } |
|
1427 - } |
|
1428 - return 0; |
|
1429 -} |
|
1430 - |
|
1431 -/****************************************************************************** |
|
1432 - * |
|
1433 - ******************************************************************************/ |
|
1434 -static int set_up_connection(struct pingpong_context *ctx, |
|
1435 - struct perftest_parameters *user_parm, |
|
1436 - struct pingpong_dest *my_dest, |
|
1437 - struct mcast_parameters *mcg_params) { |
|
1438 - |
|
1439 - int i = (user_parm->duplex) ? 1 : 0; |
|
1440 - |
|
1441 - if (user_parm->use_mcg && (user_parm->duplex || user_parm->machine == SERVER)) { |
|
1442 - |
|
1443 - set_multicast_gid(mcg_params,ctx->qp[0]->qp_num,(int)user_parm->machine); |
|
1444 - if (set_mcast_group(ctx,user_parm,mcg_params)) { |
|
1445 - return 1; |
|
1446 - } |
|
1447 - |
|
1448 - while (i < user_parm->num_of_qps) { |
|
1449 - if (ibv_attach_mcast(ctx->qp[i],&mcg_params->mgid,mcg_params->mlid)) { |
|
1450 - fprintf(stderr, "Couldn't attach QP to MultiCast group"); |
|
1451 - return 1; |
|
1452 - } |
|
1453 - i++; |
|
1454 - } |
|
1455 - |
|
1456 - mcg_params->mcast_state |= MCAST_IS_ATTACHED; |
|
1457 - my_dest->gid = mcg_params->mgid; |
|
1458 - my_dest->lid = mcg_params->mlid; |
|
1459 - my_dest->qpn = QPNUM_MCAST; |
|
1460 - |
|
1461 - } else { |
|
1462 - if (user_parm->gid_index != -1) { |
|
1463 - if (ibv_query_gid(ctx->context,user_parm->ib_port,user_parm->gid_index,&my_dest->gid)) { |
|
1464 - return -1; |
|
1465 - } |
|
1466 - } |
|
1467 - my_dest->lid = ctx_get_local_lid(ctx->context,user_parm->ib_port); |
|
1468 - my_dest->qpn = ctx->qp[0]->qp_num; |
|
1469 - } |
|
1470 - my_dest->psn = lrand48() & 0xffffff; |
|
1471 - |
|
1472 - // We do not fail test upon lid above RoCE. |
|
1473 - |
|
1474 - if (user_parm->gid_index < 0) { |
|
1475 - if (!my_dest->lid) { |
|
1476 - fprintf(stderr," Local lid 0x0 detected,without any use of gid. Is SM running?\n"); |
|
1477 - return -1; |
|
1478 - } |
|
1479 - } |
|
1480 - return 0; |
|
1481 -} |
|
1482 - |
|
1483 -/****************************************************************************** |
|
1484 - * |
|
1485 - ******************************************************************************/ |
|
1486 -static int init_connection(struct perftest_parameters *params, |
|
1487 - struct pingpong_dest *my_dest) { |
|
1488 - |
|
1489 - params->side = LOCAL; |
|
1490 - ctx_print_pingpong_data(my_dest,params); |
|
1491 - |
|
1492 - if (params->machine == CLIENT) |
|
1493 - params->sockfd = ctx_client_connect(params->servername,params->port); |
|
1494 - else |
|
1495 - params->sockfd = ctx_server_connect(params->port); |
|
1496 - |
|
1497 - |
|
1498 - if(params->sockfd < 0) { |
|
1499 - fprintf(stderr,"Unable to open file descriptor for socket connection"); |
|
1500 - return 1; |
|
1501 - } |
|
1502 - return 0; |
|
1503 -} |
|
1504 - |
|
1505 -/****************************************************************************** |
|
1506 - * |
|
1507 - ******************************************************************************/ |
|
1508 -static int destroy_ctx_resources(struct pingpong_context *ctx, |
|
1509 - struct perftest_parameters *user_parm, |
|
1510 - struct pingpong_dest *my_dest, |
|
1511 - struct pingpong_dest *rem_dest, |
|
1512 - struct mcast_parameters *mcg_params) { |
|
1513 - |
|
1514 - int test_result = 0; |
|
1515 - int i = (user_parm->duplex) ? 1 : 0; |
|
1516 - |
|
1517 - if (user_parm->use_mcg) { |
|
1518 - |
|
1519 - if (user_parm->machine == SERVER || user_parm->duplex) { |
|
1520 - |
|
1521 - while (i < user_parm->num_of_qps) { |
|
1522 - if (ibv_detach_mcast(ctx->qp[i],&my_dest->gid,my_dest->lid)) { |
|
1523 - fprintf(stderr, "Couldn't deattach QP from MultiCast group\n"); |
|
1524 - return 1; |
|
1525 - } |
|
1526 - i++; |
|
1527 - } |
|
1528 - mcg_params->mgid = my_dest->gid; |
|
1529 - if (!strcmp(link_layer_str(user_parm->link_type),"IB")) { |
|
1530 - if (join_multicast_group(SUBN_ADM_METHOD_DELETE,mcg_params)) { |
|
1531 - fprintf(stderr,"Couldn't Unregister the Mcast group on the SM\n"); |
|
1532 - return 1; |
|
1533 - } |
|
1534 - } |
|
1535 - } |
|
1536 - |
|
1537 - if (user_parm->machine == CLIENT || user_parm->duplex) { |
|
1538 - |
|
1539 - mcg_params->mgid = rem_dest->gid; |
|
1540 - if (!strcmp(link_layer_str(user_parm->link_type),"IB")) { |
|
1541 - if (join_multicast_group(SUBN_ADM_METHOD_DELETE,mcg_params)) { |
|
1542 - fprintf(stderr,"Couldn't Unregister the Mcast group on the SM\n"); |
|
1543 - return 1; |
|
1544 - } |
|
1545 - } |
|
1546 - |
|
1547 - } |
|
1548 - } |
|
1549 - |
|
1550 - if (ctx->ah) { |
|
1551 - if (ibv_destroy_ah(ctx->ah)) { |
|
1552 - fprintf(stderr, "failed to destroy AH\n"); |
|
1553 - test_result = 1; |
|
1554 - } |
|
1555 - } |
|
1556 - |
|
1557 - for(i = 0; i < user_parm->num_of_qps; i++) { |
|
1558 - if (ibv_destroy_qp(ctx->qp[i])) { |
|
1559 - test_result = 1; |
|
1560 - } |
|
1561 - } |
|
1562 - free(ctx->qp); |
|
1563 - |
|
1564 - if (ibv_destroy_cq(ctx->cq)) { |
|
1565 - test_result = 1; |
|
1566 - } |
|
1567 - |
|
1568 - for(i = 0; i < user_parm->num_of_qps; i++) { |
|
1569 - |
|
1570 - if (ibv_dereg_mr(ctx->mr[i])) { |
|
1571 - test_result = 1; |
|
1572 - } |
|
1573 - free(ctx->buf[i]); |
|
1574 - } |
|
1575 - |
|
1576 - if (ibv_dealloc_pd(ctx->pd)) { |
|
1577 - test_result = 1; |
|
1578 - } |
|
1579 - |
|
1580 - if (ctx->channel) { |
|
1581 - if (ibv_destroy_comp_channel(ctx->channel)) { |
|
1582 - test_result = 1; |
|
1583 - } |
|
1584 - } |
|
1585 - |
|
1586 - if (ibv_close_device(ctx->context)) { |
|
1587 - test_result = 1; |
|
1588 - } |
|
1589 - |
|
1590 - if (user_parm->machine == SERVER || user_parm->duplex) { |
|
1591 - free(ctx->rwr); |
|
1592 - free(ctx->sge_list); |
|
1593 - free(ctx->my_addr); |
|
1594 - } |
|
1595 - |
|
1596 - free(ctx->mr); |
|
1597 - free(ctx->buf); |
|
1598 - free(ctx); |
|
1599 - free(tposted); |
|
1600 - free(tcompleted); |
|
1601 - return test_result; |
|
1602 -} |
|
1603 - |
|
1604 -/****************************************************************************** |
|
1605 - * |
|
1606 - ******************************************************************************/ |
|
1607 -static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, |
|
1608 - struct perftest_parameters *user_parm) { |
|
1609 - |
|
1610 - int i,m_size; |
|
1611 - int duplex_ind; |
|
1612 - struct pingpong_context *ctx; |
|
1613 - |
|
1614 - ALLOCATE(ctx,struct pingpong_context,1); |
|
1615 - ALLOCATE(ctx->buf,void*,user_parm->num_of_qps); |
|
1616 - ALLOCATE(ctx->mr,struct ibv_mr*,user_parm->num_of_qps); |
|
1617 - |
|
1618 - ctx->ah = NULL; |
|
1619 - ctx->channel = NULL; |
|
1620 - |
|
1621 - duplex_ind = (user_parm->duplex && !user_parm->use_mcg) ? 2 : 1; |
|
1622 - |
|
1623 - ctx->context = ibv_open_device(ib_dev); |
|
1624 - if (!ctx->context) { |
|
1625 - fprintf(stderr, "Couldn't get context for %s\n", |
|
1626 - ibv_get_device_name(ib_dev)); |
|
1627 - return NULL; |
|
1628 - } |
|
1629 - |
|
1630 - // Configure the Link MTU acoording to the user or the active mtu. |
|
1631 - if (ctx_set_mtu(ctx->context,user_parm)) { |
|
1632 - fprintf(stderr, "Couldn't set the link layer\n"); |
|
1633 - return NULL; |
|
1634 - } |
|
1635 - |
|
1636 - if (user_parm->connection_type == UD && user_parm->size > MTU_SIZE(user_parm->curr_mtu)) { |
|
1637 - printf(" Max msg size in UD is MTU - %d . changing to MTU\n",MTU_SIZE(user_parm->curr_mtu)); |
|
1638 - user_parm->size = MTU_SIZE(user_parm->curr_mtu); |
|
1639 - } |
|
1640 - |
|
1641 - if (is_dev_hermon(ctx->context) != NOT_HERMON && user_parm->inline_size != 0) |
|
1642 - user_parm->inline_size = 0; |
|
1643 - |
|
1644 - printf(" Inline data is used up to %d bytes message\n", user_parm->inline_size); |
|
1645 - |
|
1646 - ctx->size = user_parm->size; |
|
1647 - |
|
1648 - // Finds the link type and configure the HCA accordingly. |
|
1649 - if (ctx_set_link_layer(ctx->context,user_parm)) { |
|
1650 - fprintf(stderr, " Couldn't set the link layer\n"); |
|
1651 - return NULL; |
|
1652 - } |
|
1653 - |
|
1654 - if (user_parm->use_event) { |
|
1655 - ctx->channel = ibv_create_comp_channel(ctx->context); |
|
1656 - if (!ctx->channel) { |
|
1657 - fprintf(stderr, "Couldn't create completion channel\n"); |
|
1658 - return NULL; |
|
1659 - } |
|
1660 - } else |
|
1661 - ctx->channel = NULL; |
|
1662 - |
|
1663 - ctx->pd = ibv_alloc_pd(ctx->context); |
|
1664 - if (!ctx->pd) { |
|
1665 - fprintf(stderr, "Couldn't allocate PD\n"); |
|
1666 - return NULL; |
|
1667 - } |
|
1668 - |
|
1669 - for (i = 0; i < user_parm->num_of_qps; i++) { |
|
1670 - |
|
1671 - m_size = (BUFF_SIZE(user_parm->size) + IF_UD_ADD(user_parm->connection_type))*duplex_ind; |
|
1672 - ctx->buf[i] = memalign(page_size,m_size); |
|
1673 - if (!ctx->buf[i]) { |
|
1674 - fprintf(stderr, "Couldn't allocate work buf.\n"); |
|
1675 - return NULL; |
|
1676 - } |
|
1677 - memset(ctx->buf[i],0,m_size); |
|
1678 - |
|
1679 - // We dont really want IBV_ACCESS_LOCAL_WRITE, but IB spec says : |
|
1680 - // The Consumer is not allowed to assign Remote Write or Remote Atomic to |
|
1681 - // a Memory Region that has not been assigned Local Write. |
|
1682 - ctx->mr[i] = ibv_reg_mr(ctx->pd, |
|
1683 - ctx->buf[i], |
|
1684 - m_size, |
|
1685 - IBV_ACCESS_REMOTE_WRITE | |
|
1686 - IBV_ACCESS_LOCAL_WRITE); |
|
1687 - |
|
1688 - if (!ctx->mr[i]) { |
|
1689 - fprintf(stderr, "Couldn't allocate MR\n"); |
|
1690 - return NULL; |
|
1691 - } |
|
1692 - } |
|
1693 - |
|
1694 - // Create the CQ according to Client/Server or Duplex setting. |
|
1695 - ctx->cq = ctx_cq_create(ctx->context,ctx->channel,user_parm); |
|
1696 - if (ctx->cq == NULL) { |
|
1697 - fprintf(stderr, "Couldn't create CQ \n"); |
|
1698 - return NULL; |
|
1699 - } |
|
1700 - |
|
1701 - ALLOCATE(ctx->qp,struct ibv_qp*,user_parm->num_of_qps); |
|
1702 - |
|
1703 - for(i=0; i < user_parm->num_of_qps; i++) { |
|
1704 - ctx->qp[i] = ctx_qp_create(ctx->pd,ctx->cq,ctx->cq,user_parm); |
|
1705 - if (ctx->qp[i] == NULL) { |
|
1706 - return NULL; |
|
1707 - } |
|
1708 - |
|
1709 - if(ctx_modify_qp_to_init(ctx->qp[i],user_parm)) { |
|
1710 - return NULL; |
|
1711 - } |
|
1712 - } |
|
1713 - |
|
1714 - return ctx; |
|
1715 -} |
|
1716 - |
|
1717 -/****************************************************************************** |
|
1718 - * |
|
1719 - ******************************************************************************/ |
|
1720 -static int pp_connect_ctx(struct pingpong_context *ctx,int my_psn, |
|
1721 - struct pingpong_dest *dest, |
|
1722 - struct perftest_parameters *user_parm) |
|
1723 -{ |
|
1724 - struct ibv_qp_attr attr; |
|
1725 - memset(&attr, 0, sizeof attr); |
|
1726 - int i; |
|
1727 - |
|
1728 - attr.qp_state = IBV_QPS_RTR; |
|
1729 - attr.path_mtu = user_parm->curr_mtu; |
|
1730 - attr.dest_qp_num = dest->qpn; |
|
1731 - attr.rq_psn = dest->psn; |
|
1732 - attr.ah_attr.dlid = dest->lid; |
|
1733 - if (user_parm->connection_type == RC) { |
|
1734 - attr.max_dest_rd_atomic = 1; |
|
1735 - attr.min_rnr_timer = 12; |
|
1736 - } |
|
1737 - if (user_parm->gid_index < 0) { |
|
1738 - attr.ah_attr.is_global = 0; |
|
1739 - attr.ah_attr.sl = user_parm->sl; |
|
1740 - } else { |
|
1741 - attr.ah_attr.is_global = 1; |
|
1742 - attr.ah_attr.grh.dgid = dest->gid; |
|
1743 - attr.ah_attr.grh.sgid_index = user_parm->gid_index; |
|
1744 - attr.ah_attr.grh.hop_limit = 1; |
|
1745 - attr.ah_attr.sl = 0; |
|
1746 - } |
|
1747 - attr.ah_attr.src_path_bits = 0; |
|
1748 - attr.ah_attr.port_num = user_parm->ib_port; |
|
1749 - |
|
1750 - if (user_parm->connection_type == RC) { |
|
1751 - if (ibv_modify_qp(ctx->qp[0], &attr, |
|
1752 - IBV_QP_STATE | |
|
1753 - IBV_QP_AV | |
|
1754 - IBV_QP_PATH_MTU | |
|
1755 - IBV_QP_DEST_QPN | |
|
1756 - IBV_QP_RQ_PSN | |
|
1757 - IBV_QP_MIN_RNR_TIMER | |
|
1758 - IBV_QP_MAX_DEST_RD_ATOMIC)) { |
|
1759 - fprintf(stderr, "Failed to modify RC QP to RTR\n"); |
|
1760 - return 1; |
|
1761 - } |
|
1762 - attr.timeout = user_parm->qp_timeout; |
|
1763 - attr.retry_cnt = 7; |
|
1764 - attr.rnr_retry = 7; |
|
1765 - } else if (user_parm->connection_type == UC) { |
|
1766 - if (ibv_modify_qp(ctx->qp[0], &attr, |
|
1767 - IBV_QP_STATE | |
|
1768 - IBV_QP_AV | |
|
1769 - IBV_QP_PATH_MTU | |
|
1770 - IBV_QP_DEST_QPN | |
|
1771 - IBV_QP_RQ_PSN)) { |
|
1772 - fprintf(stderr, "Failed to modify UC QP to RTR\n"); |
|
1773 - return 1; |
|
1774 - } |
|
1775 - } |
|
1776 - |
|
1777 - else { |
|
1778 - for (i = 0; i < user_parm->num_of_qps; i++) { |
|
1779 - if (ibv_modify_qp(ctx->qp[i],&attr,IBV_QP_STATE )) { |
|
1780 - fprintf(stderr, "Failed to modify UD QP to RTR\n"); |
|
1781 - return 1; |
|
1782 - } |
|
1783 - } |
|
1784 - if (user_parm->machine == CLIENT || user_parm->duplex) { |
|
1785 - ctx->ah = ibv_create_ah(ctx->pd,&attr.ah_attr); |
|
1786 - if (!ctx->ah) { |
|
1787 - fprintf(stderr, "Failed to create AH for UD\n"); |
|
1788 - return 1; |
|
1789 - } |
|
1790 - } |
|
1791 - } |
|
1792 - |
|
1793 - if (user_parm->machine == CLIENT || user_parm->duplex) { |
|
1794 - |
|
1795 - attr.qp_state = IBV_QPS_RTS; |
|
1796 - attr.sq_psn = my_psn; |
|
1797 - if (user_parm->connection_type == RC) { |
|
1798 - attr.max_rd_atomic = 1; |
|
1799 - if (ibv_modify_qp(ctx->qp[0], &attr, |
|
1800 - IBV_QP_STATE | |
|
1801 - IBV_QP_SQ_PSN | |
|
1802 - IBV_QP_TIMEOUT | |
|
1803 - IBV_QP_RETRY_CNT | |
|
1804 - IBV_QP_RNR_RETRY | |
|
1805 - IBV_QP_MAX_QP_RD_ATOMIC)) { |
|
1806 - fprintf(stderr, "Failed to modify RC QP to RTS\n"); |
|
1807 - return 1; |
|
1808 - } |
|
1809 - |
|
1810 - } else { |
|
1811 - if(ibv_modify_qp(ctx->qp[0],&attr,IBV_QP_STATE |IBV_QP_SQ_PSN)) { |
|
1812 - fprintf(stderr, "Failed to modify UC QP to RTS\n"); |
|
1813 - return 1; |
|
1814 - } |
|
1815 - } |
|
1816 - } |
|
1817 - |
|
1818 - return 0; |
|
1819 -} |
|
1820 - |
|
1821 -/****************************************************************************** |
|
1822 - * |
|
1823 - ******************************************************************************/ |
|
1824 -static int set_recv_wqes(struct pingpong_context *ctx, |
|
1825 - struct perftest_parameters *user_param) { |
|
1826 - |
|
1827 - int i,j,buff_size; |
|
1828 - int duplex_ind; |
|
1829 - struct ibv_recv_wr *bad_wr_recv; |
|
1830 - |
|
1831 - i = (user_param->duplex && user_param->use_mcg) ? 1 : 0; |
|
1832 - duplex_ind = (user_param->duplex && !user_param->use_mcg) ? 1 : 0; |
|
1833 - |
|
1834 - buff_size = BUFF_SIZE(ctx->size) + IF_UD_ADD(user_param->connection_type); |
|
1835 - |
|
1836 - while (i < user_param->num_of_qps) { |
|
1837 - |
|
1838 - ctx->sge_list[i].addr = (uintptr_t)ctx->buf[i] + duplex_ind*buff_size; |
|
1839 - |
|
1840 - if (user_param->connection_type == UD) |
|
1841 - ctx->sge_list[i].addr += (CACHE_LINE_SIZE - UD_ADDITION); |
|
1842 - |
|
1843 - ctx->sge_list[i].length = SIZE(user_param->connection_type,user_param->size); |
|
1844 - ctx->sge_list[i].lkey = ctx->mr[i]->lkey; |
|
1845 - ctx->rwr[i].sg_list = &ctx->sge_list[i]; |
|
1846 - ctx->rwr[i].wr_id = i; |
|
1847 - ctx->rwr[i].next = NULL; |
|
1848 - ctx->rwr[i].num_sge = MAX_RECV_SGE; |
|
1849 - ctx->my_addr[i] = (uintptr_t)ctx->buf[i] + duplex_ind*buff_size; |
|
1850 - |
|
1851 - for (j = 0; j < user_param->rx_depth; ++j) { |
|
1852 - |
|
1853 - if (ibv_post_recv(ctx->qp[i],&ctx->rwr[i],&bad_wr_recv)) { |
|
1854 - fprintf(stderr, "Couldn't post recv Qp = %d: counter=%d\n",i,j); |
|
1855 - return 1; |
|
1856 - } |
|
1857 - |
|
1858 - if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
1859 - increase_loc_addr(&ctx->sge_list[i],user_param->size,j,ctx->my_addr[i],user_param->connection_type); |
|
1860 - } |
|
1861 - i++; |
|
1862 - } |
|
1863 - return 0; |
|
1864 -} |
|
1865 - |
|
1866 -/****************************************************************************** |
|
1867 - * |
|
1868 - ******************************************************************************/ |
|
1869 -static void set_send_wqe(struct pingpong_context *ctx,int rem_qpn, |
|
1870 - struct perftest_parameters *user_param) { |
|
1871 - |
|
1872 - ctx->list.addr = (uintptr_t)ctx->buf[0]; |
|
1873 - ctx->list.lkey = ctx->mr[0]->lkey; |
|
1874 - |
|
1875 - ctx->wr.sg_list = &ctx->list; |
|
1876 - ctx->wr.num_sge = 1; |
|
1877 - ctx->wr.opcode = IBV_WR_SEND; |
|
1878 - ctx->wr.next = NULL; |
|
1879 - ctx->wr.wr_id = PINGPONG_SEND_WRID; |
|
1880 - ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
1881 - |
|
1882 - if (user_param->connection_type == UD) { |
|
1883 - ctx->wr.wr.ud.ah = ctx->ah; |
|
1884 - ctx->wr.wr.ud.remote_qkey = DEF_QKEY; |
|
1885 - ctx->wr.wr.ud.remote_qpn = rem_qpn; |
|
1886 - } |
|
1887 -} |
|
1888 - |
|
1889 -/****************************************************************************** |
|
1890 - * |
|
1891 - ******************************************************************************/ |
|
1892 -static int pp_drain_qp(struct pingpong_context *ctx, |
|
1893 - struct perftest_parameters *user_param, |
|
1894 - int psn,struct pingpong_dest *dest, |
|
1895 - struct mcast_parameters *mcg_params) { |
|
1896 - |
|
1897 - struct ibv_qp_attr attr; |
|
1898 - struct ibv_wc wc; |
|
1899 - int i; |
|
1900 - |
|
1901 - memset(&attr, 0, sizeof attr); |
|
1902 - attr.qp_state = IBV_QPS_ERR; |
|
1903 - |
|
1904 - for (i = 0; i < user_param->num_of_qps; i++) { |
|
1905 - |
|
1906 - if (ibv_modify_qp(ctx->qp[i],&attr,IBV_QP_STATE)) { |
|
1907 - fprintf(stderr, "Failed to modify RC QP to ERR\n"); |
|
1908 - return 1; |
|
1909 - } |
|
1910 - |
|
1911 - while (ibv_poll_cq(ctx->cq,1,&wc)); |
|
1912 - |
|
1913 - attr.qp_state = IBV_QPS_RESET; |
|
1914 - |
|
1915 - if (ibv_modify_qp(ctx->qp[i],&attr,IBV_QP_STATE)) { |
|
1916 - fprintf(stderr, "Failed to modify RC QP to RESET\n"); |
|
1917 - return 1; |
|
1918 - } |
|
1919 - |
|
1920 - if(ctx_modify_qp_to_init(ctx->qp[i],user_param)) { |
|
1921 - return 1; |
|
1922 - } |
|
1923 - |
|
1924 - if (user_param->use_mcg) { |
|
1925 - |
|
1926 - if ((!user_param->duplex && user_param->machine == SERVER) || (user_param->duplex && i > 0)) { |
|
1927 - if (ibv_attach_mcast(ctx->qp[i],&mcg_params->mgid,mcg_params->mlid)) { |
|
1928 - fprintf(stderr, "Couldn't attach QP to MultiCast group"); |
|
1929 - return 1; |
|
1930 - } |
|
1931 - } |
|
1932 - } |
|
1933 - } |
|
1934 - |
|
1935 - if (pp_connect_ctx(ctx,psn,dest,user_param)) { |
|
1936 - return 1; |
|
1937 - } |
|
1938 - |
|
1939 - return 0; |
|
1940 -} |
|
1941 - |
|
1942 -/****************************************************************************** |
|
1943 - * |
|
1944 - ******************************************************************************/ |
|
1945 -static void print_report(struct perftest_parameters *user_param) { |
|
1946 - |
|
1947 - double cycles_to_units; |
|
1948 - unsigned long tsize; /* Transferred size, in megabytes */ |
|
1949 - int i, j; |
|
1950 - int opt_posted = 0, opt_completed = 0; |
|
1951 - cycles_t opt_delta; |
|
1952 - cycles_t t; |
|
1953 - |
|
1954 - |
|
1955 - opt_delta = tcompleted[opt_posted] - tposted[opt_completed]; |
|
1956 - |
|
1957 - if (user_param->noPeak == OFF) { |
|
1958 - /* Find the peak bandwidth, unless asked not to in command line */ |
|
1959 - for (i = 0; i < user_param->iters; ++i) |
|
1960 - for (j = i; j < user_param->iters; ++j) { |
|
1961 - t = (tcompleted[j] - tposted[i]) / (j - i + 1); |
|
1962 - if (t < opt_delta) { |
|
1963 - opt_delta = t; |
|
1964 - opt_posted = i; |
|
1965 - opt_completed = j; |
|
1966 - } |
|
1967 - } |
|
1968 - } |
|
1969 - |
|
1970 - cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f) * 1000000; |
|
1971 - |
|
1972 - tsize = user_param->duplex ? 2 : 1; |
|
1973 - tsize = tsize * user_param->size; |
|
1974 - printf(REPORT_FMT,user_param->size,user_param->iters,(user_param->noPeak == OFF) * tsize * cycles_to_units / opt_delta / 0x100000, |
|
1975 - tsize * user_param->iters * cycles_to_units /(tcompleted[user_param->iters - 1] - tposted[0]) / 0x100000); |
|
1976 -} |
|
1977 - |
|
1978 -/****************************************************************************** |
|
1979 - * Important note : |
|
1980 - * In case of UD/UC this is NOT the way to measureBW since we are running with |
|
1981 - * loop on the send side , while we should run on the recieve side or enable |
|
1982 - * retry in SW , Since the sender may be faster than the reciver. |
|
1983 - * Although we had posted recieve it is not enough and might end this will |
|
1984 - * result in deadlock of test since both sides are stuck on poll cq. |
|
1985 - * In this test i do not solve this for the general test ,need to write |
|
1986 - * seperate test for UC/UD but in case the tx_depth is ~1/3 from the |
|
1987 - * number of iterations this should be ok . |
|
1988 - * Also note that the sender is limited in the number of send, ans |
|
1989 - * i try to make the reciver full . |
|
1990 - ******************************************************************************/ |
|
1991 -int run_iter_bi(struct pingpong_context *ctx, |
|
1992 - struct perftest_parameters *user_param) { |
|
1993 - |
|
1994 - int scnt = 0; |
|
1995 - int ccnt = 0; |
|
1996 - int rcnt = 0; |
|
1997 - int i = 0; |
|
1998 - int num_of_qps = user_param->num_of_qps; |
|
1999 - int ne; |
|
2000 - struct ibv_wc *wc = NULL; |
|
2001 - int *rcnt_for_qp = NULL; |
|
2002 - struct ibv_recv_wr *bad_wr_recv = NULL; |
|
2003 - struct ibv_send_wr *bad_wr = NULL; |
|
2004 - |
|
2005 - ALLOCATE(rcnt_for_qp,int,user_param->num_of_qps); |
|
2006 - ALLOCATE(wc,struct ibv_wc,DEF_WC_SIZE); |
|
2007 - memset(rcnt_for_qp,0,sizeof(int)*user_param->num_of_qps); |
|
2008 - |
|
2009 - if (user_param->use_mcg) |
|
2010 - num_of_qps--; |
|
2011 - |
|
2012 - // Set the length of the scatter in case of ALL option. |
|
2013 - ctx->list.length = user_param->size; |
|
2014 - ctx->list.addr = (uintptr_t)ctx->buf[0]; |
|
2015 - ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
2016 - |
|
2017 - if (user_param->size <= user_param->inline_size) |
|
2018 - ctx->wr.send_flags |= IBV_SEND_INLINE; |
|
2019 - |
|
2020 - while (ccnt < user_param->iters || rcnt < user_param->iters) { |
|
2021 - |
|
2022 - while (scnt < user_param->iters && (scnt - ccnt) < user_param->tx_depth / 2) { |
|
2023 - |
|
2024 - if (scnt % CQ_MODERATION == 0 && CQ_MODERATION > 1) |
|
2025 - ctx->wr.send_flags &= ~IBV_SEND_SIGNALED; |
|
2026 - |
|
2027 - tposted[scnt] = get_cycles(); |
|
2028 - if (ibv_post_send(ctx->qp[0],&ctx->wr, &bad_wr)) { |
|
2029 - fprintf(stderr, "Couldn't post send: scnt=%d\n",scnt); |
|
2030 - return 1; |
|
2031 - } |
|
2032 - |
|
2033 - if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
2034 - increase_loc_addr(&ctx->list,user_param->size,scnt,(uintptr_t)ctx->buf[0],0); |
|
2035 - |
|
2036 - ++scnt; |
|
2037 - |
|
2038 - if ((scnt % CQ_MODERATION) == (CQ_MODERATION - 1) || scnt == (user_param->iters - 1)) |
|
2039 - ctx->wr.send_flags |= IBV_SEND_SIGNALED; |
|
2040 - } |
|
2041 - |
|
2042 - if (user_param->use_event) { |
|
2043 - |
|
2044 - if (ctx_notify_events(ctx->cq,ctx->channel)) { |
|
2045 - fprintf(stderr,"Failed to notify events to CQ"); |
|
2046 - return 1; |
|
2047 - } |
|
2048 - } |
|
2049 - |
|
2050 - do { |
|
2051 - ne = ibv_poll_cq(ctx->cq,DEF_WC_SIZE,wc); |
|
2052 - if (ne > 0) { |
|
2053 - for (i = 0; i < ne; i++) { |
|
2054 - |
|
2055 - if (wc[i].status != IBV_WC_SUCCESS) |
|
2056 - NOTIFY_COMP_ERROR_SEND(wc[i],scnt,ccnt); |
|
2057 - |
|
2058 - if ((int) wc[i].wr_id == PINGPONG_SEND_WRID) { |
|
2059 - ccnt += CQ_MODERATION; |
|
2060 - if (ccnt >= user_param->iters - 1) |
|
2061 - tcompleted[user_param->iters - 1] = get_cycles(); |
|
2062 - |
|
2063 - else |
|
2064 - tcompleted[ccnt - 1] = get_cycles(); |
|
2065 - } |
|
2066 - |
|
2067 - else { |
|
2068 - |
|
2069 - rcnt_for_qp[wc[i].wr_id]++; |
|
2070 - rcnt++; |
|
2071 - if (ibv_post_recv(ctx->qp[wc[i].wr_id],&ctx->rwr[wc[i].wr_id],&bad_wr_recv)) { |
|
2072 - fprintf(stderr, "Couldn't post recv Qp=%d rcnt=%d\n",(int)wc[i].wr_id , rcnt_for_qp[wc[i].wr_id]); |
|
2073 - return 15; |
|
2074 - } |
|
2075 - |
|
2076 - if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
2077 - increase_loc_addr(&ctx->sge_list[wc[i].wr_id], |
|
2078 - user_param->size,rcnt_for_qp[wc[i].wr_id] + user_param->rx_depth - 1, |
|
2079 - ctx->my_addr[wc[i].wr_id],user_param->connection_type); |
|
2080 - } |
|
2081 - } |
|
2082 - } |
|
2083 - } while (ne > 0); |
|
2084 - |
|
2085 - if (ne < 0) { |
|
2086 - fprintf(stderr, "poll CQ failed %d\n", ne); |
|
2087 - return 1; |
|
2088 - } |
|
2089 - } |
|
2090 - |
|
2091 - if (user_param->size <= user_param->inline_size) |
|
2092 - ctx->wr.send_flags &= ~IBV_SEND_INLINE; |
|
2093 - |
|
2094 - free(rcnt_for_qp); |
|
2095 - free(wc); |
|
2096 - return 0; |
|
2097 -} |
|
2098 - |
|
2099 -/****************************************************************************** |
|
2100 - * |
|
2101 - ******************************************************************************/ |
|
2102 -int run_iter_uni_server(struct pingpong_context *ctx, |
|
2103 - struct perftest_parameters *user_param) { |
|
2104 - |
|
2105 - int rcnt = 0; |
|
2106 - int ne,i; |
|
2107 - int *rcnt_for_qp = NULL; |
|
2108 - struct ibv_wc *wc = NULL; |
|
2109 - struct ibv_recv_wr *bad_wr_recv = NULL; |
|
2110 - |
|
2111 - ALLOCATE(wc,struct ibv_wc,DEF_WC_SIZE); |
|
2112 - ALLOCATE(rcnt_for_qp,int,user_param->num_of_qps); |
|
2113 - |
|
2114 - memset(rcnt_for_qp,0,sizeof(int)*user_param->num_of_qps); |
|
2115 - |
|
2116 - while (rcnt < user_param->iters) { |
|
2117 - |
|
2118 - if (user_param->use_event) { |
|
2119 - if (ctx_notify_events(ctx->cq,ctx->channel)) { |
|
2120 - fprintf(stderr ," Failed to notify events to CQ"); |
|
2121 - return 1; |
|
2122 - } |
|
2123 - } |
|
2124 - |
|
2125 - do { |
|
2126 - ne = ibv_poll_cq(ctx->cq,DEF_WC_SIZE,wc); |
|
2127 - if (ne > 0) { |
|
2128 - for (i = 0; i < ne; i++) { |
|
2129 - |
|
2130 - if (wc[i].status != IBV_WC_SUCCESS) |
|
2131 - NOTIFY_COMP_ERROR_RECV(wc[i],rcnt_for_qp[wc[i].wr_id]); |
|
2132 - |
|
2133 - rcnt_for_qp[wc[i].wr_id]++; |
|
2134 - tcompleted[rcnt++] = get_cycles(); |
|
2135 - |
|
2136 - if (ibv_post_recv(ctx->qp[wc[i].wr_id],&ctx->rwr[wc[i].wr_id],&bad_wr_recv)) { |
|
2137 - fprintf(stderr, "Couldn't post recv Qp=%d rcnt=%d\n",(int)wc[i].wr_id,rcnt_for_qp[wc[i].wr_id]); |
|
2138 - return 15; |
|
2139 - } |
|
2140 - |
|
2141 - if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
2142 - increase_loc_addr(&ctx->sge_list[wc[i].wr_id],user_param->size, |
|
2143 - rcnt_for_qp[wc[i].wr_id] + user_param->rx_depth, |
|
2144 - ctx->my_addr[wc[i].wr_id],user_param->connection_type); |
|
2145 - } |
|
2146 - } |
|
2147 - } while (ne > 0); |
|
2148 - |
|
2149 - if (ne < 0) { |
|
2150 - fprintf(stderr, "Poll Recieve CQ failed %d\n", ne); |
|
2151 - return 1; |
|
2152 - } |
|
2153 - } |
|
2154 - |
|
2155 - tposted[0] = tcompleted[0]; |
|
2156 - free(wc); |
|
2157 - free(rcnt_for_qp); |
|
2158 - return 0; |
|
2159 -} |
|
2160 - |
|
2161 -/****************************************************************************** |
|
2162 - * |
|
2163 - ******************************************************************************/ |
|
2164 -int run_iter_uni_client(struct pingpong_context *ctx, |
|
2165 - struct perftest_parameters *user_param) { |
|
2166 - |
|
2167 - int ne; |
|
2168 - int i = 0; |
|
2169 - int scnt = 0; |
|
2170 - int ccnt = 0; |
|
2171 - struct ibv_wc *wc = NULL; |
|
2172 - struct ibv_send_wr *bad_wr = NULL; |
|
2173 - |
|
2174 - ALLOCATE(wc,struct ibv_wc,DEF_WC_SIZE); |
|
2175 - |
|
2176 - // Set the lenght of the scatter in case of ALL option. |
|
2177 - ctx->list.length = user_param->size; |
|
2178 - ctx->list.addr = (uintptr_t)ctx->buf[0]; |
|
2179 - ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
2180 - |
|
2181 - if (user_param->size <= user_param->inline_size) |
|
2182 - ctx->wr.send_flags |= IBV_SEND_INLINE; |
|
2183 - |
|
2184 - |
|
2185 - while (scnt < user_param->iters || ccnt < user_param->iters) { |
|
2186 - while (scnt < user_param->iters && (scnt - ccnt) < user_param->tx_depth ) { |
|
2187 - |
|
2188 - if (scnt % CQ_MODERATION == 0 && CQ_MODERATION > 1) |
|
2189 - ctx->wr.send_flags &= ~IBV_SEND_SIGNALED; |
|
2190 - |
|
2191 - tposted[scnt] = get_cycles(); |
|
2192 - if (ibv_post_send(ctx->qp[0], &ctx->wr, &bad_wr)) { |
|
2193 - fprintf(stderr, "Couldn't post send: scnt=%d\n",scnt); |
|
2194 - return 1; |
|
2195 - } |
|
2196 - |
|
2197 - if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
2198 - increase_loc_addr(&ctx->list,user_param->size,scnt,(uintptr_t)ctx->buf[0],0); |
|
2199 - |
|
2200 - scnt++; |
|
2201 - |
|
2202 - if ((scnt % CQ_MODERATION) == (CQ_MODERATION - 1) || scnt == (user_param->iters - 1)) |
|
2203 - ctx->wr.send_flags |= IBV_SEND_SIGNALED; |
|
2204 - } |
|
2205 - |
|
2206 - if (ccnt < user_param->iters) { |
|
2207 - |
|
2208 - if (user_param->use_event) { |
|
2209 - if (ctx_notify_events(ctx->cq,ctx->channel)) { |
|
2210 - fprintf(stderr , " Failed to notify events to CQ"); |
|
2211 - return 1; |
|
2212 - } |
|
2213 - } |
|
2214 - do { |
|
2215 - ne = ibv_poll_cq(ctx->cq,DEF_WC_SIZE,wc); |
|
2216 - if (ne > 0) { |
|
2217 - for (i = 0; i < DEF_WC_SIZE; i++) { |
|
2218 - |
|
2219 - if (wc[i].status != IBV_WC_SUCCESS) |
|
2220 - NOTIFY_COMP_ERROR_SEND(wc[i],scnt,ccnt); |
|
2221 - |
|
2222 - ccnt += CQ_MODERATION; |
|
2223 - if (ccnt >= user_param->iters - 1) |
|
2224 - tcompleted[user_param->iters - 1] = get_cycles(); |
|
2225 - |
|
2226 - else |
|
2227 - tcompleted[ccnt - 1] = get_cycles(); |
|
2228 - } |
|
2229 - } |
|
2230 - |
|
2231 - |
|
2232 - } while (ne > 0); |
|
2233 - |
|
2234 - if (ne < 0) { |
|
2235 - fprintf(stderr, "poll CQ failed\n"); |
|
2236 - return 1; |
|
2237 - } |
|
2238 - } |
|
2239 - } |
|
2240 - |
|
2241 - if (user_param->size <= user_param->inline_size) |
|
2242 - ctx->wr.send_flags &= ~IBV_SEND_INLINE; |
|
2243 - |
|
2244 - free(wc); |
|
2245 - return 0; |
|
2246 -} |
|
2247 - |
|
2248 -/****************************************************************************** |
|
2249 - * |
|
2250 - ******************************************************************************/ |
|
2251 -int main(int argc, char *argv[]) |
|
2252 -{ |
|
2253 - struct ibv_device *ib_dev = NULL; |
|
2254 - struct pingpong_context *ctx; |
|
2255 - struct pingpong_dest my_dest,rem_dest; |
|
2256 - struct perftest_parameters user_param; |
|
2257 - struct mcast_parameters mcg_params; |
|
2258 - int i = 0; |
|
2259 - int size_max_pow = 24; |
|
2260 - int size_of_arr; |
|
2261 - |
|
2262 - // Pointer to The relevent function of run_iter according to machine type. |
|
2263 - int (*ptr_to_run_iter_uni)(struct pingpong_context*,struct perftest_parameters*); |
|
2264 - |
|
2265 - /* init default values to user's parameters */ |
|
2266 - memset(&user_param, 0 , sizeof(struct perftest_parameters)); |
|
2267 - memset(&mcg_params, 0 , sizeof(struct mcast_parameters)); |
|
2268 - memset(&my_dest , 0 , sizeof(struct pingpong_dest)); |
|
2269 - memset(&rem_dest , 0 , sizeof(struct pingpong_dest)); |
|
2270 - |
|
2271 - user_param.verb = SEND; |
|
2272 - user_param.tst = BW; |
|
2273 - user_param.version = VERSION; |
|
2274 - |
|
2275 - if (parser(&user_param,argv,argc)) |
|
2276 - return 1; |
|
2277 - |
|
2278 - printf(RESULT_LINE); |
|
2279 - |
|
2280 - user_param.rx_depth = (user_param.iters < user_param.rx_depth) ? user_param.iters : user_param.rx_depth ; |
|
2281 - |
|
2282 - if (user_param.use_mcg) { |
|
2283 - |
|
2284 - user_param.connection_type = UD; |
|
2285 - if (user_param.duplex) { |
|
2286 - user_param.num_of_qps++; |
|
2287 - printf(" Send Bidirectional BW - Multicast Test\n"); |
|
2288 - } |
|
2289 - else { |
|
2290 - printf(" Send BW - Multicast Test\n"); |
|
2291 - if (user_param.machine == CLIENT) |
|
2292 - user_param.num_of_qps = 1; |
|
2293 - } |
|
2294 - } |
|
2295 - |
|
2296 - else if (user_param.duplex) { |
|
2297 - printf(" Send Bidirectional BW Test\n"); |
|
2298 - } else |
|
2299 - printf(" Send BW Test\n"); |
|
2300 - |
|
2301 - if (user_param.use_event) |
|
2302 - printf(" Test with events.\n"); |
|
2303 - |
|
2304 - if (user_param.connection_type == RC) |
|
2305 - printf(" Connection type : RC\n"); |
|
2306 - else if (user_param.connection_type == UC) |
|
2307 - printf(" Connection type : UC\n"); |
|
2308 - else{ |
|
2309 - printf(" Connection type : UD\n"); |
|
2310 - } |
|
2311 - |
|
2312 - // Done with parameter parsing. Perform setup. |
|
2313 - if (user_param.all == ON) { |
|
2314 - // since we run all sizes |
|
2315 - user_param.size = MAX_SIZE; |
|
2316 - } |
|
2317 - |
|
2318 - srand48(getpid() * time(NULL)); |
|
2319 - page_size = sysconf(_SC_PAGESIZE); |
|
2320 - |
|
2321 - ib_dev = ctx_find_dev(user_param.ib_devname); |
|
2322 - if (!ib_dev) |
|
2323 - return 7; |
|
2324 - |
|
2325 - mcg_params.ib_devname = ibv_get_device_name(ib_dev); |
|
2326 - |
|
2327 - ctx = pp_init_ctx(ib_dev,&user_param); |
|
2328 - if (!ctx) |
|
2329 - return 1; |
|
2330 - |
|
2331 - // Set up the Connection. |
|
2332 - if (set_up_connection(ctx,&user_param,&my_dest,&mcg_params)) { |
|
2333 - fprintf(stderr," Unable to set up socket connection\n"); |
|
2334 - return 1; |
|
2335 - } |
|
2336 - |
|
2337 - // Init the connection and print the local data. |
|
2338 - if (init_connection(&user_param,&my_dest)) { |
|
2339 - fprintf(stderr," Unable to init the socket connection\n"); |
|
2340 - return 1; |
|
2341 - } |
|
2342 - |
|
2343 - // shaking hands and gather the other side info. |
|
2344 - if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
2345 - fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
2346 - return 1; |
|
2347 - |
|
2348 - } |
|
2349 - // For printing only MGID in the remote side. |
|
2350 - user_param.side = REMOTE; |
|
2351 - ctx_print_pingpong_data(&rem_dest,&user_param); |
|
2352 - |
|
2353 - // Joining the Send side port the Mcast gid |
|
2354 - if (user_param.use_mcg && (user_param.machine == CLIENT || user_param.duplex)) { |
|
2355 - memcpy(mcg_params.mgid.raw, rem_dest.gid.raw, 16); |
|
2356 - if (set_mcast_group(ctx,&user_param,&mcg_params)) { |
|
2357 - fprintf(stderr," Unable to Join Sender to Mcast gid\n"); |
|
2358 - return 1; |
|
2359 - } |
|
2360 - } |
|
2361 - |
|
2362 - // Prepare IB resources for rtr/rts. |
|
2363 - if (pp_connect_ctx(ctx,my_dest.psn,&rem_dest,&user_param)) { |
|
2364 - fprintf(stderr," Unable to Connect the HCA's through the link\n"); |
|
2365 - return 1; |
|
2366 - } |
|
2367 - |
|
2368 - // shaking hands and gather the other side info. |
|
2369 - if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
2370 - fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
2371 - return 1; |
|
2372 - |
|
2373 - } |
|
2374 - |
|
2375 - if (user_param.use_event) { |
|
2376 - if (ibv_req_notify_cq(ctx->cq, 0)) { |
|
2377 - fprintf(stderr, " Couldn't request CQ notification\n"); |
|
2378 - return 1; |
|
2379 - } |
|
2380 - } |
|
2381 - |
|
2382 - printf(RESULT_LINE); |
|
2383 - printf(RESULT_FMT); |
|
2384 - |
|
2385 - size_of_arr = (user_param.duplex) ? 1 : user_param.num_of_qps; |
|
2386 - |
|
2387 - ALLOCATE(tposted,cycles_t,user_param.iters*size_of_arr); |
|
2388 - ALLOCATE(tcompleted,cycles_t,user_param.iters*size_of_arr); |
|
2389 - |
|
2390 - if (user_param.machine == SERVER || user_param.duplex) { |
|
2391 - ALLOCATE(ctx->rwr,struct ibv_recv_wr,user_param.num_of_qps); |
|
2392 - ALLOCATE(ctx->sge_list,struct ibv_sge,user_param.num_of_qps); |
|
2393 - ALLOCATE(ctx->my_addr ,uint64_t ,user_param.num_of_qps); |
|
2394 - } |
|
2395 - |
|
2396 - ptr_to_run_iter_uni = (user_param.machine == CLIENT) ? &run_iter_uni_client : &run_iter_uni_server; |
|
2397 - |
|
2398 - if (user_param.machine == SERVER && !user_param.duplex) { |
|
2399 - user_param.noPeak = ON; |
|
2400 - } |
|
2401 - |
|
2402 - if (user_param.machine == CLIENT || user_param.duplex) { |
|
2403 - set_send_wqe(ctx,rem_dest.qpn,&user_param); |
|
2404 - } |
|
2405 - |
|
2406 - if (user_param.all == ON) { |
|
2407 - |
|
2408 - if (user_param.connection_type == UD) |
|
2409 - size_max_pow = (int)UD_MSG_2_EXP(MTU_SIZE(user_param.curr_mtu)) + 1; |
|
2410 - |
|
2411 - for (i = 1; i < size_max_pow ; ++i) { |
|
2412 - user_param.size = 1 << i; |
|
2413 - |
|
2414 - if (user_param.machine == SERVER || user_param.duplex) { |
|
2415 - if (set_recv_wqes(ctx,&user_param)) { |
|
2416 - fprintf(stderr," Failed to post receive recv_wqes\n"); |
|
2417 - return 1; |
|
2418 - } |
|
2419 - } |
|
2420 - |
|
2421 - if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
2422 - fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
2423 - return 1; |
|
2424 - } |
|
2425 - |
|
2426 - if (user_param.duplex) { |
|
2427 - if(run_iter_bi(ctx,&user_param)) |
|
2428 - return 17; |
|
2429 - } else { |
|
2430 - if((*ptr_to_run_iter_uni)(ctx,&user_param)) |
|
2431 - return 17; |
|
2432 - } |
|
2433 - print_report(&user_param); |
|
2434 - |
|
2435 - if (pp_drain_qp(ctx,&user_param,my_dest.psn,&rem_dest,&mcg_params)) { |
|
2436 - fprintf(stderr,"Failed to drain Recv queue (performance optimization)\n"); |
|
2437 - return 1; |
|
2438 - } |
|
2439 - |
|
2440 - if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
2441 - fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
2442 - return 1; |
|
2443 - } |
|
2444 - |
|
2445 - } |
|
2446 - |
|
2447 - } else { |
|
2448 - |
|
2449 - if (user_param.machine == SERVER || user_param.duplex) { |
|
2450 - if (set_recv_wqes(ctx,&user_param)) { |
|
2451 - fprintf(stderr," Failed to post receive recv_wqes\n"); |
|
2452 - return 1; |
|
2453 - } |
|
2454 - } |
|
2455 - |
|
2456 - if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
2457 - fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
2458 - return 1; |
|
2459 - } |
|
2460 - |
|
2461 - if (user_param.duplex) { |
|
2462 - if(run_iter_bi(ctx,&user_param)) |
|
2463 - return 18; |
|
2464 - |
|
2465 - } else { |
|
2466 - if((*ptr_to_run_iter_uni)(ctx,&user_param)) |
|
2467 - return 18; |
|
2468 - } |
|
2469 - |
|
2470 - print_report(&user_param); |
|
2471 - } |
|
2472 - |
|
2473 - if (ctx_close_connection(&user_param,&my_dest,&rem_dest)) { |
|
2474 - fprintf(stderr," Failed to close connection between server and client\n"); |
|
2475 - return 1; |
|
2476 - } |
|
2477 - |
|
2478 - printf(RESULT_LINE); |
|
2479 - return destroy_ctx_resources(ctx,&user_param,&my_dest,&rem_dest,&mcg_params); |
|
2480 -} |
|
2481 +/* |
|
2482 + * Copyright (c) 2005 Topspin Communications. All rights reserved. |
|
2483 + * Copyright (c) 2005 Mellanox Technologies Ltd. All rights reserved. |
|
2484 + * Copyright (c) 2009 HNR Consulting. All rights reserved. |
|
2485 + * |
|
2486 + * This software is available to you under a choice of one of two |
|
2487 + * licenses. You may choose to be licensed under the terms of the GNU |
|
2488 + * General Public License (GPL) Version 2, available from the file |
|
2489 + * COPYING in the main directory of this source tree, or the |
|
2490 + * OpenIB.org BSD license below: |
|
2491 + * |
|
2492 + * Redistribution and use in source and binary forms, with or |
|
2493 + * without modification, are permitted provided that the following |
|
2494 + * conditions are met: |
|
2495 + * |
|
2496 + * - Redistributions of source code must retain the above |
|
2497 + * copyright notice, this list of conditions and the following |
|
2498 + * disclaimer. |
|
2499 + * |
|
2500 + * - Redistributions in binary form must reproduce the above |
|
2501 + * copyright notice, this list of conditions and the following |
|
2502 + * disclaimer in the documentation and/or other materials |
|
2503 + * provided with the distribution. |
|
2504 + * |
|
2505 + * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, |
|
2506 + * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF |
|
2507 + * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND |
|
2508 + * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS |
|
2509 + * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN |
|
2510 + * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN |
|
2511 + * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
2512 + * SOFTWARE. |
|
2513 + * |
|
2514 + * $Id$ |
|
2515 + */ |
|
2516 + |
|
2517 +#if HAVE_CONFIG_H |
|
2518 +# include <config.h> |
|
2519 +#endif /* HAVE_CONFIG_H */ |
|
2520 + |
|
2521 +#include <stdio.h> |
|
2522 +#include <stdlib.h> |
|
2523 +#include <unistd.h> |
|
2524 +#include <string.h> |
|
2525 +#include <limits.h> |
|
2526 +#include <malloc.h> |
|
2527 +#include <getopt.h> |
|
2528 +#include <time.h> |
|
2529 +#include <errno.h> |
|
2530 +#include <infiniband/verbs.h> |
|
2531 + |
|
2532 +#include "get_clock.h" |
|
2533 +#include "multicast_resources.h" |
|
2534 +#include "perftest_resources.h" |
|
2535 + |
|
2536 +#define VERSION 2.1 |
|
2537 + |
|
2538 +static int page_size; |
|
2539 +cycles_t *tposted; |
|
2540 +cycles_t *tcompleted; |
|
2541 + |
|
2542 +struct pingpong_context { |
|
2543 + struct ibv_context *context; |
|
2544 + struct ibv_comp_channel *channel; |
|
2545 + struct ibv_pd *pd; |
|
2546 + struct ibv_mr **mr; |
|
2547 + struct ibv_cq *cq; |
|
2548 + struct ibv_qp **qp; |
|
2549 + struct ibv_sge list; |
|
2550 + struct ibv_send_wr wr; |
|
2551 + struct ibv_sge *sge_list; |
|
2552 + struct ibv_recv_wr *rwr; |
|
2553 + struct ibv_ah *ah; |
|
2554 + void **buf; |
|
2555 + unsigned size; |
|
2556 + uint64_t *my_addr; |
|
2557 +}; |
|
2558 + |
|
2559 +/****************************************************************************** |
|
2560 + * |
|
2561 + ******************************************************************************/ |
|
2562 +static int set_mcast_group(struct pingpong_context *ctx, |
|
2563 + struct perftest_parameters *user_parm, |
|
2564 + struct mcast_parameters *mcg_params) { |
|
2565 + |
|
2566 + struct ibv_port_attr port_attr; |
|
2567 + |
|
2568 + if (ibv_query_gid(ctx->context,user_parm->ib_port,user_parm->gid_index,&mcg_params->port_gid)) { |
|
2569 + return 1; |
|
2570 + } |
|
2571 + |
|
2572 + if (ibv_query_pkey(ctx->context,user_parm->ib_port,DEF_PKEY_IDX,&mcg_params->pkey)) { |
|
2573 + return 1; |
|
2574 + } |
|
2575 + |
|
2576 + if (ibv_query_port(ctx->context,user_parm->ib_port,&port_attr)) { |
|
2577 + return 1; |
|
2578 + } |
|
2579 + mcg_params->sm_lid = port_attr.sm_lid; |
|
2580 + mcg_params->sm_sl = port_attr.sm_sl; |
|
2581 + mcg_params->ib_port = user_parm->ib_port; |
|
2582 + |
|
2583 + if (!strcmp(link_layer_str(user_parm->link_type),"IB")) { |
|
2584 + // Request for Mcast group create registery in SM. |
|
2585 + if (join_multicast_group(SUBN_ADM_METHOD_SET,mcg_params)) { |
|
2586 + fprintf(stderr,"Couldn't Register the Mcast group on the SM\n"); |
|
2587 + return 1; |
|
2588 + } |
|
2589 + } |
|
2590 + return 0; |
|
2591 +} |
|
2592 + |
|
2593 +/****************************************************************************** |
|
2594 + * |
|
2595 + ******************************************************************************/ |
|
2596 +static int set_up_connection(struct pingpong_context *ctx, |
|
2597 + struct perftest_parameters *user_parm, |
|
2598 + struct pingpong_dest *my_dest, |
|
2599 + struct mcast_parameters *mcg_params) { |
|
2600 + |
|
2601 + int i = (user_parm->duplex) ? 1 : 0; |
|
2602 + |
|
2603 + if (user_parm->use_mcg && (user_parm->duplex || user_parm->machine == SERVER)) { |
|
2604 + |
|
2605 + set_multicast_gid(mcg_params,ctx->qp[0]->qp_num,(int)user_parm->machine); |
|
2606 + if (set_mcast_group(ctx,user_parm,mcg_params)) { |
|
2607 + return 1; |
|
2608 + } |
|
2609 + |
|
2610 + while (i < user_parm->num_of_qps) { |
|
2611 + if (ibv_attach_mcast(ctx->qp[i],&mcg_params->mgid,mcg_params->mlid)) { |
|
2612 + fprintf(stderr, "Couldn't attach QP to MultiCast group"); |
|
2613 + return 1; |
|
2614 + } |
|
2615 + i++; |
|
2616 + } |
|
2617 + |
|
2618 + mcg_params->mcast_state |= MCAST_IS_ATTACHED; |
|
2619 + my_dest->gid = mcg_params->mgid; |
|
2620 + my_dest->lid = mcg_params->mlid; |
|
2621 + my_dest->qpn = QPNUM_MCAST; |
|
2622 + |
|
2623 + } else { |
|
2624 + if (user_parm->gid_index != -1) { |
|
2625 + if (ibv_query_gid(ctx->context,user_parm->ib_port,user_parm->gid_index,&my_dest->gid)) { |
|
2626 + return -1; |
|
2627 + } |
|
2628 + } |
|
2629 + my_dest->lid = ctx_get_local_lid(ctx->context,user_parm->ib_port); |
|
2630 + my_dest->qpn = ctx->qp[0]->qp_num; |
|
2631 + } |
|
2632 + my_dest->psn = lrand48() & 0xffffff; |
|
2633 + |
|
2634 + // We do not fail test upon lid above RoCE. |
|
2635 + |
|
2636 + if (user_parm->gid_index < 0) { |
|
2637 + if (!my_dest->lid) { |
|
2638 + fprintf(stderr," Local lid 0x0 detected,without any use of gid. Is SM running?\n"); |
|
2639 + return -1; |
|
2640 + } |
|
2641 + } |
|
2642 + return 0; |
|
2643 +} |
|
2644 + |
|
2645 +/****************************************************************************** |
|
2646 + * |
|
2647 + ******************************************************************************/ |
|
2648 +static int init_connection(struct perftest_parameters *params, |
|
2649 + struct pingpong_dest *my_dest) { |
|
2650 + |
|
2651 + params->side = LOCAL; |
|
2652 + ctx_print_pingpong_data(my_dest,params); |
|
2653 + |
|
2654 + if (params->machine == CLIENT) |
|
2655 + params->sockfd = ctx_client_connect(params->servername,params->port); |
|
2656 + else |
|
2657 + params->sockfd = ctx_server_connect(params->port); |
|
2658 + |
|
2659 + |
|
2660 + if(params->sockfd < 0) { |
|
2661 + fprintf(stderr,"Unable to open file descriptor for socket connection"); |
|
2662 + return 1; |
|
2663 + } |
|
2664 + return 0; |
|
2665 +} |
|
2666 + |
|
2667 +/****************************************************************************** |
|
2668 + * |
|
2669 + ******************************************************************************/ |
|
2670 +static int destroy_ctx_resources(struct pingpong_context *ctx, |
|
2671 + struct perftest_parameters *user_parm, |
|
2672 + struct pingpong_dest *my_dest, |
|
2673 + struct pingpong_dest *rem_dest, |
|
2674 + struct mcast_parameters *mcg_params) { |
|
2675 + |
|
2676 + int test_result = 0; |
|
2677 + int i = (user_parm->duplex) ? 1 : 0; |
|
2678 + |
|
2679 + if (user_parm->use_mcg) { |
|
2680 + |
|
2681 + if (user_parm->machine == SERVER || user_parm->duplex) { |
|
2682 + |
|
2683 + while (i < user_parm->num_of_qps) { |
|
2684 + if (ibv_detach_mcast(ctx->qp[i],&my_dest->gid,my_dest->lid)) { |
|
2685 + fprintf(stderr, "Couldn't deattach QP from MultiCast group\n"); |
|
2686 + return 1; |
|
2687 + } |
|
2688 + i++; |
|
2689 + } |
|
2690 + mcg_params->mgid = my_dest->gid; |
|
2691 + if (!strcmp(link_layer_str(user_parm->link_type),"IB")) { |
|
2692 + if (join_multicast_group(SUBN_ADM_METHOD_DELETE,mcg_params)) { |
|
2693 + fprintf(stderr,"Couldn't Unregister the Mcast group on the SM\n"); |
|
2694 + return 1; |
|
2695 + } |
|
2696 + } |
|
2697 + } |
|
2698 + |
|
2699 + if (user_parm->machine == CLIENT || user_parm->duplex) { |
|
2700 + |
|
2701 + mcg_params->mgid = rem_dest->gid; |
|
2702 + if (!strcmp(link_layer_str(user_parm->link_type),"IB")) { |
|
2703 + if (join_multicast_group(SUBN_ADM_METHOD_DELETE,mcg_params)) { |
|
2704 + fprintf(stderr,"Couldn't Unregister the Mcast group on the SM\n"); |
|
2705 + return 1; |
|
2706 + } |
|
2707 + } |
|
2708 + |
|
2709 + } |
|
2710 + } |
|
2711 + |
|
2712 + if (ctx->ah) { |
|
2713 + if (ibv_destroy_ah(ctx->ah)) { |
|
2714 + fprintf(stderr, "failed to destroy AH\n"); |
|
2715 + test_result = 1; |
|
2716 + } |
|
2717 + } |
|
2718 + |
|
2719 + for(i = 0; i < user_parm->num_of_qps; i++) { |
|
2720 + if (ibv_destroy_qp(ctx->qp[i])) { |
|
2721 + test_result = 1; |
|
2722 + } |
|
2723 + } |
|
2724 + free(ctx->qp); |
|
2725 + |
|
2726 + if (ibv_destroy_cq(ctx->cq)) { |
|
2727 + test_result = 1; |
|
2728 + } |
|
2729 + |
|
2730 + for(i = 0; i < user_parm->num_of_qps; i++) { |
|
2731 + |
|
2732 + if (ibv_dereg_mr(ctx->mr[i])) { |
|
2733 + test_result = 1; |
|
2734 + } |
|
2735 + free(ctx->buf[i]); |
|
2736 + } |
|
2737 + |
|
2738 + if (ibv_dealloc_pd(ctx->pd)) { |
|
2739 + test_result = 1; |
|
2740 + } |
|
2741 + |
|
2742 + if (ctx->channel) { |
|
2743 + if (ibv_destroy_comp_channel(ctx->channel)) { |
|
2744 + test_result = 1; |
|
2745 + } |
|
2746 + } |
|
2747 + |
|
2748 + if (ibv_close_device(ctx->context)) { |
|
2749 + test_result = 1; |
|
2750 + } |
|
2751 + |
|
2752 + if (user_parm->machine == SERVER || user_parm->duplex) { |
|
2753 + free(ctx->rwr); |
|
2754 + free(ctx->sge_list); |
|
2755 + free(ctx->my_addr); |
|
2756 + } |
|
2757 + |
|
2758 + free(ctx->mr); |
|
2759 + free(ctx->buf); |
|
2760 + free(ctx); |
|
2761 + free(tposted); |
|
2762 + free(tcompleted); |
|
2763 + return test_result; |
|
2764 +} |
|
2765 + |
|
2766 +/****************************************************************************** |
|
2767 + * |
|
2768 + ******************************************************************************/ |
|
2769 +static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, |
|
2770 + struct perftest_parameters *user_parm) { |
|
2771 + |
|
2772 + int i,m_size; |
|
2773 + int duplex_ind; |
|
2774 + struct pingpong_context *ctx; |
|
2775 + |
|
2776 + ALLOCATE(ctx,struct pingpong_context,1); |
|
2777 + ALLOCATE(ctx->buf,void*,user_parm->num_of_qps); |
|
2778 + ALLOCATE(ctx->mr,struct ibv_mr*,user_parm->num_of_qps); |
|
2779 + |
|
2780 + ctx->ah = NULL; |
|
2781 + ctx->channel = NULL; |
|
2782 + |
|
2783 + duplex_ind = (user_parm->duplex && !user_parm->use_mcg) ? 2 : 1; |
|
2784 + |
|
2785 + ctx->context = ibv_open_device(ib_dev); |
|
2786 + if (!ctx->context) { |
|
2787 + fprintf(stderr, "Couldn't get context for %s\n", |
|
2788 + ibv_get_device_name(ib_dev)); |
|
2789 + return NULL; |
|
2790 + } |
|
2791 + |
|
2792 + // Configure the Link MTU acoording to the user or the active mtu. |
|
2793 + if (ctx_set_mtu(ctx->context,user_parm)) { |
|
2794 + fprintf(stderr, "Couldn't set the link layer\n"); |
|
2795 + return NULL; |
|
2796 + } |
|
2797 + |
|
2798 + if (user_parm->connection_type == UD && user_parm->size > MTU_SIZE(user_parm->curr_mtu)) { |
|
2799 + printf(" Max msg size in UD is MTU - %d . changing to MTU\n",MTU_SIZE(user_parm->curr_mtu)); |
|
2800 + user_parm->size = MTU_SIZE(user_parm->curr_mtu); |
|
2801 + } |
|
2802 + |
|
2803 + if (is_dev_hermon(ctx->context) != NOT_HERMON && user_parm->inline_size != 0) |
|
2804 + user_parm->inline_size = 0; |
|
2805 + |
|
2806 + printf(" Inline data is used up to %d bytes message\n", user_parm->inline_size); |
|
2807 + |
|
2808 + ctx->size = user_parm->size; |
|
2809 + |
|
2810 + // Finds the link type and configure the HCA accordingly. |
|
2811 + if (ctx_set_link_layer(ctx->context,user_parm)) { |
|
2812 + fprintf(stderr, " Couldn't set the link layer\n"); |
|
2813 + return NULL; |
|
2814 + } |
|
2815 + |
|
2816 + if (user_parm->use_event) { |
|
2817 + ctx->channel = ibv_create_comp_channel(ctx->context); |
|
2818 + if (!ctx->channel) { |
|
2819 + fprintf(stderr, "Couldn't create completion channel\n"); |
|
2820 + return NULL; |
|
2821 + } |
|
2822 + } else |
|
2823 + ctx->channel = NULL; |
|
2824 + |
|
2825 + ctx->pd = ibv_alloc_pd(ctx->context); |
|
2826 + if (!ctx->pd) { |
|
2827 + fprintf(stderr, "Couldn't allocate PD\n"); |
|
2828 + return NULL; |
|
2829 + } |
|
2830 + |
|
2831 + for (i = 0; i < user_parm->num_of_qps; i++) { |
|
2832 + |
|
2833 + m_size = (BUFF_SIZE(user_parm->size) + IF_UD_ADD(user_parm->connection_type))*duplex_ind; |
|
2834 + ctx->buf[i] = memalign(page_size,m_size); |
|
2835 + if (!ctx->buf[i]) { |
|
2836 + fprintf(stderr, "Couldn't allocate work buf.\n"); |
|
2837 + return NULL; |
|
2838 + } |
|
2839 + memset(ctx->buf[i],0,m_size); |
|
2840 + |
|
2841 + // We dont really want IBV_ACCESS_LOCAL_WRITE, but IB spec says : |
|
2842 + // The Consumer is not allowed to assign Remote Write or Remote Atomic to |
|
2843 + // a Memory Region that has not been assigned Local Write. |
|
2844 + ctx->mr[i] = ibv_reg_mr(ctx->pd, |
|
2845 + ctx->buf[i], |
|
2846 + m_size, |
|
2847 + IBV_ACCESS_REMOTE_WRITE | |
|
2848 + IBV_ACCESS_LOCAL_WRITE); |
|
2849 + |
|
2850 + if (!ctx->mr[i]) { |
|
2851 + fprintf(stderr, "Couldn't allocate MR\n"); |
|
2852 + return NULL; |
|
2853 + } |
|
2854 + } |
|
2855 + |
|
2856 + // Create the CQ according to Client/Server or Duplex setting. |
|
2857 + ctx->cq = ctx_cq_create(ctx->context,ctx->channel,user_parm); |
|
2858 + if (ctx->cq == NULL) { |
|
2859 + fprintf(stderr, "Couldn't create CQ \n"); |
|
2860 + return NULL; |
|
2861 + } |
|
2862 + |
|
2863 + ALLOCATE(ctx->qp,struct ibv_qp*,user_parm->num_of_qps); |
|
2864 + |
|
2865 + for(i=0; i < user_parm->num_of_qps; i++) { |
|
2866 + ctx->qp[i] = ctx_qp_create(ctx->pd,ctx->cq,ctx->cq,user_parm); |
|
2867 + if (ctx->qp[i] == NULL) { |
|
2868 + return NULL; |
|
2869 + } |
|
2870 + |
|
2871 + if(ctx_modify_qp_to_init(ctx->qp[i],user_parm)) { |
|
2872 + return NULL; |
|
2873 + } |
|
2874 + } |
|
2875 + |
|
2876 + return ctx; |
|
2877 +} |
|
2878 + |
|
2879 +/****************************************************************************** |
|
2880 + * |
|
2881 + ******************************************************************************/ |
|
2882 +static int pp_connect_ctx(struct pingpong_context *ctx,int my_psn, |
|
2883 + struct pingpong_dest *dest, |
|
2884 + struct perftest_parameters *user_parm) |
|
2885 +{ |
|
2886 + struct ibv_qp_attr attr; |
|
2887 + memset(&attr, 0, sizeof attr); |
|
2888 + int i; |
|
2889 + |
|
2890 + attr.qp_state = IBV_QPS_RTR; |
|
2891 + attr.path_mtu = user_parm->curr_mtu; |
|
2892 + attr.dest_qp_num = dest->qpn; |
|
2893 + attr.rq_psn = dest->psn; |
|
2894 + attr.ah_attr.dlid = dest->lid; |
|
2895 + if (user_parm->connection_type == RC) { |
|
2896 + attr.max_dest_rd_atomic = 1; |
|
2897 + attr.min_rnr_timer = 12; |
|
2898 + } |
|
2899 + if (user_parm->gid_index < 0) { |
|
2900 + attr.ah_attr.is_global = 0; |
|
2901 + attr.ah_attr.sl = user_parm->sl; |
|
2902 + } else { |
|
2903 + attr.ah_attr.is_global = 1; |
|
2904 + attr.ah_attr.grh.dgid = dest->gid; |
|
2905 + attr.ah_attr.grh.sgid_index = user_parm->gid_index; |
|
2906 + attr.ah_attr.grh.hop_limit = 1; |
|
2907 + attr.ah_attr.sl = 0; |
|
2908 + } |
|
2909 + attr.ah_attr.src_path_bits = 0; |
|
2910 + attr.ah_attr.port_num = user_parm->ib_port; |
|
2911 + |
|
2912 + if (user_parm->connection_type == RC) { |
|
2913 + if (ibv_modify_qp(ctx->qp[0], &attr, |
|
2914 + IBV_QP_STATE | |
|
2915 + IBV_QP_AV | |
|
2916 + IBV_QP_PATH_MTU | |
|
2917 + IBV_QP_DEST_QPN | |
|
2918 + IBV_QP_RQ_PSN | |
|
2919 + IBV_QP_MIN_RNR_TIMER | |
|
2920 + IBV_QP_MAX_DEST_RD_ATOMIC)) { |
|
2921 + fprintf(stderr, "Failed to modify RC QP to RTR\n"); |
|
2922 + return 1; |
|
2923 + } |
|
2924 + attr.timeout = user_parm->qp_timeout; |
|
2925 + attr.retry_cnt = 7; |
|
2926 + attr.rnr_retry = 7; |
|
2927 + } else if (user_parm->connection_type == UC) { |
|
2928 + if (ibv_modify_qp(ctx->qp[0], &attr, |
|
2929 + IBV_QP_STATE | |
|
2930 + IBV_QP_AV | |
|
2931 + IBV_QP_PATH_MTU | |
|
2932 + IBV_QP_DEST_QPN | |
|
2933 + IBV_QP_RQ_PSN)) { |
|
2934 + fprintf(stderr, "Failed to modify UC QP to RTR\n"); |
|
2935 + return 1; |
|
2936 + } |
|
2937 + } |
|
2938 + |
|
2939 + else { |
|
2940 + for (i = 0; i < user_parm->num_of_qps; i++) { |
|
2941 + if (ibv_modify_qp(ctx->qp[i],&attr,IBV_QP_STATE )) { |
|
2942 + fprintf(stderr, "Failed to modify UD QP to RTR\n"); |
|
2943 + return 1; |
|
2944 + } |
|
2945 + } |
|
2946 + if (user_parm->machine == CLIENT || user_parm->duplex) { |
|
2947 + ctx->ah = ibv_create_ah(ctx->pd,&attr.ah_attr); |
|
2948 + if (!ctx->ah) { |
|
2949 + fprintf(stderr, "Failed to create AH for UD\n"); |
|
2950 + return 1; |
|
2951 + } |
|
2952 + } |
|
2953 + } |
|
2954 + |
|
2955 + if (user_parm->machine == CLIENT || user_parm->duplex) { |
|
2956 + |
|
2957 + attr.qp_state = IBV_QPS_RTS; |
|
2958 + attr.sq_psn = my_psn; |
|
2959 + if (user_parm->connection_type == RC) { |
|
2960 + attr.max_rd_atomic = 1; |
|
2961 + if (ibv_modify_qp(ctx->qp[0], &attr, |
|
2962 + IBV_QP_STATE | |
|
2963 + IBV_QP_SQ_PSN | |
|
2964 + IBV_QP_TIMEOUT | |
|
2965 + IBV_QP_RETRY_CNT | |
|
2966 + IBV_QP_RNR_RETRY | |
|
2967 + IBV_QP_MAX_QP_RD_ATOMIC)) { |
|
2968 + fprintf(stderr, "Failed to modify RC QP to RTS\n"); |
|
2969 + return 1; |
|
2970 + } |
|
2971 + |
|
2972 + } else { |
|
2973 + if(ibv_modify_qp(ctx->qp[0],&attr,IBV_QP_STATE |IBV_QP_SQ_PSN)) { |
|
2974 + fprintf(stderr, "Failed to modify UC QP to RTS\n"); |
|
2975 + return 1; |
|
2976 + } |
|
2977 + } |
|
2978 + } |
|
2979 + |
|
2980 + return 0; |
|
2981 +} |
|
2982 + |
|
2983 +/****************************************************************************** |
|
2984 + * |
|
2985 + ******************************************************************************/ |
|
2986 +static int set_recv_wqes(struct pingpong_context *ctx, |
|
2987 + struct perftest_parameters *user_param) { |
|
2988 + |
|
2989 + int i,j,buff_size; |
|
2990 + int duplex_ind; |
|
2991 + struct ibv_recv_wr *bad_wr_recv; |
|
2992 + |
|
2993 + i = (user_param->duplex && user_param->use_mcg) ? 1 : 0; |
|
2994 + duplex_ind = (user_param->duplex && !user_param->use_mcg) ? 1 : 0; |
|
2995 + |
|
2996 + buff_size = BUFF_SIZE(ctx->size) + IF_UD_ADD(user_param->connection_type); |
|
2997 + |
|
2998 + while (i < user_param->num_of_qps) { |
|
2999 + |
|
3000 + ctx->sge_list[i].addr = (uintptr_t)ctx->buf[i] + duplex_ind*buff_size; |
|
3001 + |
|
3002 + if (user_param->connection_type == UD) |
|
3003 + ctx->sge_list[i].addr += (CACHE_LINE_SIZE - UD_ADDITION); |
|
3004 + |
|
3005 + ctx->sge_list[i].length = SIZE(user_param->connection_type,user_param->size); |
|
3006 + ctx->sge_list[i].lkey = ctx->mr[i]->lkey; |
|
3007 + ctx->rwr[i].sg_list = &ctx->sge_list[i]; |
|
3008 + ctx->rwr[i].wr_id = i; |
|
3009 + ctx->rwr[i].next = NULL; |
|
3010 + ctx->rwr[i].num_sge = MAX_RECV_SGE; |
|
3011 + ctx->my_addr[i] = (uintptr_t)ctx->buf[i] + duplex_ind*buff_size; |
|
3012 + |
|
3013 + for (j = 0; j < user_param->rx_depth; ++j) { |
|
3014 + |
|
3015 + if (ibv_post_recv(ctx->qp[i],&ctx->rwr[i],&bad_wr_recv)) { |
|
3016 + fprintf(stderr, "Couldn't post recv Qp = %d: counter=%d\n",i,j); |
|
3017 + return 1; |
|
3018 + } |
|
3019 + |
|
3020 + if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
3021 + increase_loc_addr(&ctx->sge_list[i],user_param->size,j,ctx->my_addr[i],user_param->connection_type); |
|
3022 + } |
|
3023 + i++; |
|
3024 + } |
|
3025 + return 0; |
|
3026 +} |
|
3027 + |
|
3028 +/****************************************************************************** |
|
3029 + * |
|
3030 + ******************************************************************************/ |
|
3031 +static void set_send_wqe(struct pingpong_context *ctx,int rem_qpn, |
|
3032 + struct perftest_parameters *user_param) { |
|
3033 + |
|
3034 + ctx->list.addr = (uintptr_t)ctx->buf[0]; |
|
3035 + ctx->list.lkey = ctx->mr[0]->lkey; |
|
3036 + |
|
3037 + ctx->wr.sg_list = &ctx->list; |
|
3038 + ctx->wr.num_sge = 1; |
|
3039 + ctx->wr.opcode = IBV_WR_SEND; |
|
3040 + ctx->wr.next = NULL; |
|
3041 + ctx->wr.wr_id = PINGPONG_SEND_WRID; |
|
3042 + ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
3043 + |
|
3044 + if (user_param->connection_type == UD) { |
|
3045 + ctx->wr.wr.ud.ah = ctx->ah; |
|
3046 + ctx->wr.wr.ud.remote_qkey = DEF_QKEY; |
|
3047 + ctx->wr.wr.ud.remote_qpn = rem_qpn; |
|
3048 + } |
|
3049 +} |
|
3050 + |
|
3051 +/****************************************************************************** |
|
3052 + * |
|
3053 + ******************************************************************************/ |
|
3054 +static int pp_drain_qp(struct pingpong_context *ctx, |
|
3055 + struct perftest_parameters *user_param, |
|
3056 + int psn,struct pingpong_dest *dest, |
|
3057 + struct mcast_parameters *mcg_params) { |
|
3058 + |
|
3059 + struct ibv_qp_attr attr; |
|
3060 + struct ibv_wc wc; |
|
3061 + int i; |
|
3062 + |
|
3063 + memset(&attr, 0, sizeof attr); |
|
3064 + attr.qp_state = IBV_QPS_ERR; |
|
3065 + |
|
3066 + for (i = 0; i < user_param->num_of_qps; i++) { |
|
3067 + |
|
3068 + if (ibv_modify_qp(ctx->qp[i],&attr,IBV_QP_STATE)) { |
|
3069 + fprintf(stderr, "Failed to modify RC QP to ERR\n"); |
|
3070 + return 1; |
|
3071 + } |
|
3072 + |
|
3073 + while (ibv_poll_cq(ctx->cq,1,&wc)); |
|
3074 + |
|
3075 + attr.qp_state = IBV_QPS_RESET; |
|
3076 + |
|
3077 + if (ibv_modify_qp(ctx->qp[i],&attr,IBV_QP_STATE)) { |
|
3078 + fprintf(stderr, "Failed to modify RC QP to RESET\n"); |
|
3079 + return 1; |
|
3080 + } |
|
3081 + |
|
3082 + if(ctx_modify_qp_to_init(ctx->qp[i],user_param)) { |
|
3083 + return 1; |
|
3084 + } |
|
3085 + |
|
3086 + if (user_param->use_mcg) { |
|
3087 + |
|
3088 + if ((!user_param->duplex && user_param->machine == SERVER) || (user_param->duplex && i > 0)) { |
|
3089 + if (ibv_attach_mcast(ctx->qp[i],&mcg_params->mgid,mcg_params->mlid)) { |
|
3090 + fprintf(stderr, "Couldn't attach QP to MultiCast group"); |
|
3091 + return 1; |
|
3092 + } |
|
3093 + } |
|
3094 + } |
|
3095 + } |
|
3096 + |
|
3097 + if (pp_connect_ctx(ctx,psn,dest,user_param)) { |
|
3098 + return 1; |
|
3099 + } |
|
3100 + |
|
3101 + return 0; |
|
3102 +} |
|
3103 + |
|
3104 +/****************************************************************************** |
|
3105 + * |
|
3106 + ******************************************************************************/ |
|
3107 +static void print_report(struct perftest_parameters *user_param) { |
|
3108 + |
|
3109 + double cycles_to_units; |
|
3110 + unsigned long tsize; /* Transferred size, in megabytes */ |
|
3111 + int i, j; |
|
3112 + int opt_posted = 0, opt_completed = 0; |
|
3113 + cycles_t opt_delta; |
|
3114 + cycles_t t; |
|
3115 + |
|
3116 + |
|
3117 + opt_delta = tcompleted[opt_posted] - tposted[opt_completed]; |
|
3118 + |
|
3119 + if (user_param->noPeak == OFF) { |
|
3120 + /* Find the peak bandwidth, unless asked not to in command line */ |
|
3121 + for (i = 0; i < user_param->iters; ++i) |
|
3122 + for (j = i; j < user_param->iters; ++j) { |
|
3123 + t = (tcompleted[j] - tposted[i]) / (j - i + 1); |
|
3124 + if (t < opt_delta) { |
|
3125 + opt_delta = t; |
|
3126 + opt_posted = i; |
|
3127 + opt_completed = j; |
|
3128 + } |
|
3129 + } |
|
3130 + } |
|
3131 + |
|
3132 + cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f) * 1000000; |
|
3133 + |
|
3134 + tsize = user_param->duplex ? 2 : 1; |
|
3135 + tsize = tsize * user_param->size; |
|
3136 + printf(REPORT_FMT,user_param->size,user_param->iters,(user_param->noPeak == OFF) * tsize * cycles_to_units / opt_delta / 0x100000, |
|
3137 + tsize * user_param->iters * cycles_to_units /(tcompleted[user_param->iters - 1] - tposted[0]) / 0x100000); |
|
3138 +} |
|
3139 + |
|
3140 +/****************************************************************************** |
|
3141 + * Important note : |
|
3142 + * In case of UD/UC this is NOT the way to measureBW since we are running with |
|
3143 + * loop on the send side , while we should run on the recieve side or enable |
|
3144 + * retry in SW , Since the sender may be faster than the reciver. |
|
3145 + * Although we had posted recieve it is not enough and might end this will |
|
3146 + * result in deadlock of test since both sides are stuck on poll cq. |
|
3147 + * In this test i do not solve this for the general test ,need to write |
|
3148 + * seperate test for UC/UD but in case the tx_depth is ~1/3 from the |
|
3149 + * number of iterations this should be ok . |
|
3150 + * Also note that the sender is limited in the number of send, ans |
|
3151 + * i try to make the reciver full . |
|
3152 + ******************************************************************************/ |
|
3153 +int run_iter_bi(struct pingpong_context *ctx, |
|
3154 + struct perftest_parameters *user_param) { |
|
3155 + |
|
3156 + int scnt = 0; |
|
3157 + int ccnt = 0; |
|
3158 + int rcnt = 0; |
|
3159 + int i = 0; |
|
3160 + int num_of_qps = user_param->num_of_qps; |
|
3161 + int ne; |
|
3162 + struct ibv_wc *wc = NULL; |
|
3163 + int *rcnt_for_qp = NULL; |
|
3164 + struct ibv_recv_wr *bad_wr_recv = NULL; |
|
3165 + struct ibv_send_wr *bad_wr = NULL; |
|
3166 + |
|
3167 + ALLOCATE(rcnt_for_qp,int,user_param->num_of_qps); |
|
3168 + ALLOCATE(wc,struct ibv_wc,DEF_WC_SIZE); |
|
3169 + memset(rcnt_for_qp,0,sizeof(int)*user_param->num_of_qps); |
|
3170 + |
|
3171 + if (user_param->use_mcg) |
|
3172 + num_of_qps--; |
|
3173 + |
|
3174 + // Set the length of the scatter in case of ALL option. |
|
3175 + ctx->list.length = user_param->size; |
|
3176 + ctx->list.addr = (uintptr_t)ctx->buf[0]; |
|
3177 + ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
3178 + |
|
3179 + if (user_param->size <= user_param->inline_size) |
|
3180 + ctx->wr.send_flags |= IBV_SEND_INLINE; |
|
3181 + |
|
3182 + while (ccnt < user_param->iters || rcnt < user_param->iters) { |
|
3183 + |
|
3184 + while (scnt < user_param->iters && (scnt - ccnt) < user_param->tx_depth / 2) { |
|
3185 + |
|
3186 + if (scnt % CQ_MODERATION == 0 && CQ_MODERATION > 1) |
|
3187 + ctx->wr.send_flags &= ~IBV_SEND_SIGNALED; |
|
3188 + |
|
3189 + tposted[scnt] = get_cycles(); |
|
3190 + if (ibv_post_send(ctx->qp[0],&ctx->wr, &bad_wr)) { |
|
3191 + fprintf(stderr, "Couldn't post send: scnt=%d\n",scnt); |
|
3192 + return 1; |
|
3193 + } |
|
3194 + |
|
3195 + if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
3196 + increase_loc_addr(&ctx->list,user_param->size,scnt,(uintptr_t)ctx->buf[0],0); |
|
3197 + |
|
3198 + ++scnt; |
|
3199 + |
|
3200 + if ((scnt % CQ_MODERATION) == (CQ_MODERATION - 1) || scnt == (user_param->iters - 1)) |
|
3201 + ctx->wr.send_flags |= IBV_SEND_SIGNALED; |
|
3202 + } |
|
3203 + |
|
3204 + if (user_param->use_event) { |
|
3205 + |
|
3206 + if (ctx_notify_events(ctx->cq,ctx->channel)) { |
|
3207 + fprintf(stderr,"Failed to notify events to CQ"); |
|
3208 + return 1; |
|
3209 + } |
|
3210 + } |
|
3211 + |
|
3212 + do { |
|
3213 + ne = ibv_poll_cq(ctx->cq,DEF_WC_SIZE,wc); |
|
3214 + if (ne > 0) { |
|
3215 + for (i = 0; i < ne; i++) { |
|
3216 + |
|
3217 + if (wc[i].status != IBV_WC_SUCCESS) |
|
3218 + NOTIFY_COMP_ERROR_SEND(wc[i],scnt,ccnt); |
|
3219 + |
|
3220 + if ((int) wc[i].wr_id == PINGPONG_SEND_WRID) { |
|
3221 + ccnt += CQ_MODERATION; |
|
3222 + if (ccnt >= user_param->iters - 1) |
|
3223 + tcompleted[user_param->iters - 1] = get_cycles(); |
|
3224 + |
|
3225 + else |
|
3226 + tcompleted[ccnt - 1] = get_cycles(); |
|
3227 + } |
|
3228 + |
|
3229 + else { |
|
3230 + |
|
3231 + rcnt_for_qp[wc[i].wr_id]++; |
|
3232 + rcnt++; |
|
3233 + if (ibv_post_recv(ctx->qp[wc[i].wr_id],&ctx->rwr[wc[i].wr_id],&bad_wr_recv)) { |
|
3234 + fprintf(stderr, "Couldn't post recv Qp=%d rcnt=%d\n",(int)wc[i].wr_id , rcnt_for_qp[wc[i].wr_id]); |
|
3235 + return 15; |
|
3236 + } |
|
3237 + |
|
3238 + if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
3239 + increase_loc_addr(&ctx->sge_list[wc[i].wr_id], |
|
3240 + user_param->size,rcnt_for_qp[wc[i].wr_id] + user_param->rx_depth - 1, |
|
3241 + ctx->my_addr[wc[i].wr_id],user_param->connection_type); |
|
3242 + } |
|
3243 + } |
|
3244 + } |
|
3245 + } while (ne > 0); |
|
3246 + |
|
3247 + if (ne < 0) { |
|
3248 + fprintf(stderr, "poll CQ failed %d\n", ne); |
|
3249 + return 1; |
|
3250 + } |
|
3251 + } |
|
3252 + |
|
3253 + if (user_param->size <= user_param->inline_size) |
|
3254 + ctx->wr.send_flags &= ~IBV_SEND_INLINE; |
|
3255 + |
|
3256 + free(rcnt_for_qp); |
|
3257 + free(wc); |
|
3258 + return 0; |
|
3259 +} |
|
3260 + |
|
3261 +/****************************************************************************** |
|
3262 + * |
|
3263 + ******************************************************************************/ |
|
3264 +int run_iter_uni_server(struct pingpong_context *ctx, |
|
3265 + struct perftest_parameters *user_param) { |
|
3266 + |
|
3267 + int rcnt = 0; |
|
3268 + int ne,i; |
|
3269 + int *rcnt_for_qp = NULL; |
|
3270 + struct ibv_wc *wc = NULL; |
|
3271 + struct ibv_recv_wr *bad_wr_recv = NULL; |
|
3272 + |
|
3273 + ALLOCATE(wc,struct ibv_wc,DEF_WC_SIZE); |
|
3274 + ALLOCATE(rcnt_for_qp,int,user_param->num_of_qps); |
|
3275 + |
|
3276 + memset(rcnt_for_qp,0,sizeof(int)*user_param->num_of_qps); |
|
3277 + |
|
3278 + while (rcnt < user_param->iters) { |
|
3279 + |
|
3280 + if (user_param->use_event) { |
|
3281 + if (ctx_notify_events(ctx->cq,ctx->channel)) { |
|
3282 + fprintf(stderr ," Failed to notify events to CQ"); |
|
3283 + return 1; |
|
3284 + } |
|
3285 + } |
|
3286 + |
|
3287 + do { |
|
3288 + ne = ibv_poll_cq(ctx->cq,DEF_WC_SIZE,wc); |
|
3289 + if (ne > 0) { |
|
3290 + for (i = 0; i < ne; i++) { |
|
3291 + |
|
3292 + if (wc[i].status != IBV_WC_SUCCESS) |
|
3293 + NOTIFY_COMP_ERROR_RECV(wc[i],rcnt_for_qp[wc[i].wr_id]); |
|
3294 + |
|
3295 + rcnt_for_qp[wc[i].wr_id]++; |
|
3296 + tcompleted[rcnt++] = get_cycles(); |
|
3297 + |
|
3298 + if (ibv_post_recv(ctx->qp[wc[i].wr_id],&ctx->rwr[wc[i].wr_id],&bad_wr_recv)) { |
|
3299 + fprintf(stderr, "Couldn't post recv Qp=%d rcnt=%d\n",(int)wc[i].wr_id,rcnt_for_qp[wc[i].wr_id]); |
|
3300 + return 15; |
|
3301 + } |
|
3302 + |
|
3303 + if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
3304 + increase_loc_addr(&ctx->sge_list[wc[i].wr_id],user_param->size, |
|
3305 + rcnt_for_qp[wc[i].wr_id] + user_param->rx_depth, |
|
3306 + ctx->my_addr[wc[i].wr_id],user_param->connection_type); |
|
3307 + } |
|
3308 + } |
|
3309 + } while (ne > 0); |
|
3310 + |
|
3311 + if (ne < 0) { |
|
3312 + fprintf(stderr, "Poll Recieve CQ failed %d\n", ne); |
|
3313 + return 1; |
|
3314 + } |
|
3315 + } |
|
3316 + |
|
3317 + tposted[0] = tcompleted[0]; |
|
3318 + free(wc); |
|
3319 + free(rcnt_for_qp); |
|
3320 + return 0; |
|
3321 +} |
|
3322 + |
|
3323 +/****************************************************************************** |
|
3324 + * |
|
3325 + ******************************************************************************/ |
|
3326 +int run_iter_uni_client(struct pingpong_context *ctx, |
|
3327 + struct perftest_parameters *user_param) { |
|
3328 + |
|
3329 + int ne; |
|
3330 + int i = 0; |
|
3331 + int scnt = 0; |
|
3332 + int ccnt = 0; |
|
3333 + struct ibv_wc *wc = NULL; |
|
3334 + struct ibv_send_wr *bad_wr = NULL; |
|
3335 + |
|
3336 + ALLOCATE(wc,struct ibv_wc,DEF_WC_SIZE); |
|
3337 + |
|
3338 + // Set the lenght of the scatter in case of ALL option. |
|
3339 + ctx->list.length = user_param->size; |
|
3340 + ctx->list.addr = (uintptr_t)ctx->buf[0]; |
|
3341 + ctx->wr.send_flags = IBV_SEND_SIGNALED; |
|
3342 + |
|
3343 + if (user_param->size <= user_param->inline_size) |
|
3344 + ctx->wr.send_flags |= IBV_SEND_INLINE; |
|
3345 + |
|
3346 + |
|
3347 + while (scnt < user_param->iters || ccnt < user_param->iters) { |
|
3348 + while (scnt < user_param->iters && (scnt - ccnt) < user_param->tx_depth ) { |
|
3349 + |
|
3350 + if (scnt % CQ_MODERATION == 0 && CQ_MODERATION > 1) |
|
3351 + ctx->wr.send_flags &= ~IBV_SEND_SIGNALED; |
|
3352 + |
|
3353 + tposted[scnt] = get_cycles(); |
|
3354 + if (ibv_post_send(ctx->qp[0], &ctx->wr, &bad_wr)) { |
|
3355 + fprintf(stderr, "Couldn't post send: scnt=%d\n",scnt); |
|
3356 + return 1; |
|
3357 + } |
|
3358 + |
|
3359 + if (user_param->size <= (CYCLE_BUFFER / 2)) |
|
3360 + increase_loc_addr(&ctx->list,user_param->size,scnt,(uintptr_t)ctx->buf[0],0); |
|
3361 + |
|
3362 + scnt++; |
|
3363 + |
|
3364 + if ((scnt % CQ_MODERATION) == (CQ_MODERATION - 1) || scnt == (user_param->iters - 1)) |
|
3365 + ctx->wr.send_flags |= IBV_SEND_SIGNALED; |
|
3366 + } |
|
3367 + |
|
3368 + if (ccnt < user_param->iters) { |
|
3369 + |
|
3370 + if (user_param->use_event) { |
|
3371 + if (ctx_notify_events(ctx->cq,ctx->channel)) { |
|
3372 + fprintf(stderr , " Failed to notify events to CQ"); |
|
3373 + return 1; |
|
3374 + } |
|
3375 + } |
|
3376 + do { |
|
3377 + ne = ibv_poll_cq(ctx->cq,DEF_WC_SIZE,wc); |
|
3378 + if (ne > 0) { |
|
3379 + for (i = 0; i < DEF_WC_SIZE; i++) { |
|
3380 + |
|
3381 + if (wc[i].status != IBV_WC_SUCCESS) |
|
3382 + NOTIFY_COMP_ERROR_SEND(wc[i],scnt,ccnt); |
|
3383 + |
|
3384 + ccnt += CQ_MODERATION; |
|
3385 + if (ccnt >= user_param->iters - 1) |
|
3386 + tcompleted[user_param->iters - 1] = get_cycles(); |
|
3387 + |
|
3388 + else |
|
3389 + tcompleted[ccnt - 1] = get_cycles(); |
|
3390 + } |
|
3391 + } |
|
3392 + |
|
3393 + |
|
3394 + } while (ne > 0); |
|
3395 + |
|
3396 + if (ne < 0) { |
|
3397 + fprintf(stderr, "poll CQ failed\n"); |
|
3398 + return 1; |
|
3399 + } |
|
3400 + } |
|
3401 + } |
|
3402 + |
|
3403 + if (user_param->size <= user_param->inline_size) |
|
3404 + ctx->wr.send_flags &= ~IBV_SEND_INLINE; |
|
3405 + |
|
3406 + free(wc); |
|
3407 + return 0; |
|
3408 +} |
|
3409 + |
|
3410 +/****************************************************************************** |
|
3411 + * |
|
3412 + ******************************************************************************/ |
|
3413 +int main(int argc, char *argv[]) |
|
3414 +{ |
|
3415 + struct ibv_device *ib_dev = NULL; |
|
3416 + struct pingpong_context *ctx; |
|
3417 + struct pingpong_dest my_dest,rem_dest; |
|
3418 + struct perftest_parameters user_param; |
|
3419 + struct mcast_parameters mcg_params; |
|
3420 + int i = 0; |
|
3421 + int size_max_pow = 24; |
|
3422 + int size_of_arr; |
|
3423 + |
|
3424 + // Pointer to The relevent function of run_iter according to machine type. |
|
3425 + int (*ptr_to_run_iter_uni)(struct pingpong_context*,struct perftest_parameters*); |
|
3426 + |
|
3427 + /* init default values to user's parameters */ |
|
3428 + memset(&user_param, 0 , sizeof(struct perftest_parameters)); |
|
3429 + memset(&mcg_params, 0 , sizeof(struct mcast_parameters)); |
|
3430 + memset(&my_dest , 0 , sizeof(struct pingpong_dest)); |
|
3431 + memset(&rem_dest , 0 , sizeof(struct pingpong_dest)); |
|
3432 + |
|
3433 + user_param.verb = SEND; |
|
3434 + user_param.tst = BW; |
|
3435 + user_param.version = VERSION; |
|
3436 + |
|
3437 + if (parser(&user_param,argv,argc)) |
|
3438 + return 1; |
|
3439 + |
|
3440 + printf(RESULT_LINE); |
|
3441 + |
|
3442 + user_param.rx_depth = (user_param.iters < user_param.rx_depth) ? user_param.iters : user_param.rx_depth ; |
|
3443 + |
|
3444 + if (user_param.use_mcg) { |
|
3445 + |
|
3446 + user_param.connection_type = UD; |
|
3447 + if (user_param.duplex) { |
|
3448 + user_param.num_of_qps++; |
|
3449 + printf(" Send Bidirectional BW - Multicast Test\n"); |
|
3450 + } |
|
3451 + else { |
|
3452 + printf(" Send BW - Multicast Test\n"); |
|
3453 + if (user_param.machine == CLIENT) |
|
3454 + user_param.num_of_qps = 1; |
|
3455 + } |
|
3456 + } |
|
3457 + |
|
3458 + else if (user_param.duplex) { |
|
3459 + printf(" Send Bidirectional BW Test\n"); |
|
3460 + } else |
|
3461 + printf(" Send BW Test\n"); |
|
3462 + |
|
3463 + if (user_param.use_event) |
|
3464 + printf(" Test with events.\n"); |
|
3465 + |
|
3466 + if (user_param.connection_type == RC) |
|
3467 + printf(" Connection type : RC\n"); |
|
3468 + else if (user_param.connection_type == UC) |
|
3469 + printf(" Connection type : UC\n"); |
|
3470 + else{ |
|
3471 + printf(" Connection type : UD\n"); |
|
3472 + } |
|
3473 + |
|
3474 + // Done with parameter parsing. Perform setup. |
|
3475 + if (user_param.all == ON) { |
|
3476 + // since we run all sizes |
|
3477 + user_param.size = MAX_SIZE; |
|
3478 + } |
|
3479 + |
|
3480 + srand48(getpid() * time(NULL)); |
|
3481 + page_size = sysconf(_SC_PAGESIZE); |
|
3482 + |
|
3483 + ib_dev = ctx_find_dev(user_param.ib_devname); |
|
3484 + if (!ib_dev) |
|
3485 + return 7; |
|
3486 + |
|
3487 + mcg_params.ib_devname = ibv_get_device_name(ib_dev); |
|
3488 + |
|
3489 + ctx = pp_init_ctx(ib_dev,&user_param); |
|
3490 + if (!ctx) |
|
3491 + return 1; |
|
3492 + |
|
3493 + // Set up the Connection. |
|
3494 + if (set_up_connection(ctx,&user_param,&my_dest,&mcg_params)) { |
|
3495 + fprintf(stderr," Unable to set up socket connection\n"); |
|
3496 + return 1; |
|
3497 + } |
|
3498 + |
|
3499 + // Init the connection and print the local data. |
|
3500 + if (init_connection(&user_param,&my_dest)) { |
|
3501 + fprintf(stderr," Unable to init the socket connection\n"); |
|
3502 + return 1; |
|
3503 + } |
|
3504 + |
|
3505 + // shaking hands and gather the other side info. |
|
3506 + if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
3507 + fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
3508 + return 1; |
|
3509 + |
|
3510 + } |
|
3511 + // For printing only MGID in the remote side. |
|
3512 + user_param.side = REMOTE; |
|
3513 + ctx_print_pingpong_data(&rem_dest,&user_param); |
|
3514 + |
|
3515 + // Joining the Send side port the Mcast gid |
|
3516 + if (user_param.use_mcg && (user_param.machine == CLIENT || user_param.duplex)) { |
|
3517 + memcpy(mcg_params.mgid.raw, rem_dest.gid.raw, 16); |
|
3518 + if (set_mcast_group(ctx,&user_param,&mcg_params)) { |
|
3519 + fprintf(stderr," Unable to Join Sender to Mcast gid\n"); |
|
3520 + return 1; |
|
3521 + } |
|
3522 + } |
|
3523 + |
|
3524 + // Prepare IB resources for rtr/rts. |
|
3525 + if (pp_connect_ctx(ctx,my_dest.psn,&rem_dest,&user_param)) { |
|
3526 + fprintf(stderr," Unable to Connect the HCA's through the link\n"); |
|
3527 + return 1; |
|
3528 + } |
|
3529 + |
|
3530 + // shaking hands and gather the other side info. |
|
3531 + if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
3532 + fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
3533 + return 1; |
|
3534 + |
|
3535 + } |
|
3536 + |
|
3537 + if (user_param.use_event) { |
|
3538 + if (ibv_req_notify_cq(ctx->cq, 0)) { |
|
3539 + fprintf(stderr, " Couldn't request CQ notification\n"); |
|
3540 + return 1; |
|
3541 + } |
|
3542 + } |
|
3543 + |
|
3544 + printf(RESULT_LINE); |
|
3545 + printf(RESULT_FMT); |
|
3546 + |
|
3547 + size_of_arr = (user_param.duplex) ? 1 : user_param.num_of_qps; |
|
3548 + |
|
3549 + ALLOCATE(tposted,cycles_t,user_param.iters*size_of_arr); |
|
3550 + ALLOCATE(tcompleted,cycles_t,user_param.iters*size_of_arr); |
|
3551 + |
|
3552 + if (user_param.machine == SERVER || user_param.duplex) { |
|
3553 + ALLOCATE(ctx->rwr,struct ibv_recv_wr,user_param.num_of_qps); |
|
3554 + ALLOCATE(ctx->sge_list,struct ibv_sge,user_param.num_of_qps); |
|
3555 + ALLOCATE(ctx->my_addr ,uint64_t ,user_param.num_of_qps); |
|
3556 + } |
|
3557 + |
|
3558 + ptr_to_run_iter_uni = (user_param.machine == CLIENT) ? &run_iter_uni_client : &run_iter_uni_server; |
|
3559 + |
|
3560 + if (user_param.machine == SERVER && !user_param.duplex) { |
|
3561 + user_param.noPeak = ON; |
|
3562 + } |
|
3563 + |
|
3564 + if (user_param.machine == CLIENT || user_param.duplex) { |
|
3565 + set_send_wqe(ctx,rem_dest.qpn,&user_param); |
|
3566 + } |
|
3567 + |
|
3568 + if (user_param.all == ON) { |
|
3569 + |
|
3570 + if (user_param.connection_type == UD) |
|
3571 + size_max_pow = (int)UD_MSG_2_EXP(MTU_SIZE(user_param.curr_mtu)) + 1; |
|
3572 + |
|
3573 + for (i = 1; i < size_max_pow ; ++i) { |
|
3574 + user_param.size = 1 << i; |
|
3575 + |
|
3576 + if (user_param.machine == SERVER || user_param.duplex) { |
|
3577 + if (set_recv_wqes(ctx,&user_param)) { |
|
3578 + fprintf(stderr," Failed to post receive recv_wqes\n"); |
|
3579 + return 1; |
|
3580 + } |
|
3581 + } |
|
3582 + |
|
3583 + if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
3584 + fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
3585 + return 1; |
|
3586 + } |
|
3587 + |
|
3588 + if (user_param.duplex) { |
|
3589 + if(run_iter_bi(ctx,&user_param)) |
|
3590 + return 17; |
|
3591 + } else { |
|
3592 + if((*ptr_to_run_iter_uni)(ctx,&user_param)) |
|
3593 + return 17; |
|
3594 + } |
|
3595 + print_report(&user_param); |
|
3596 + |
|
3597 + if (pp_drain_qp(ctx,&user_param,my_dest.psn,&rem_dest,&mcg_params)) { |
|
3598 + fprintf(stderr,"Failed to drain Recv queue (performance optimization)\n"); |
|
3599 + return 1; |
|
3600 + } |
|
3601 + |
|
3602 + if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
3603 + fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
3604 + return 1; |
|
3605 + } |
|
3606 + |
|
3607 + } |
|
3608 + |
|
3609 + } else { |
|
3610 + |
|
3611 + if (user_param.machine == SERVER || user_param.duplex) { |
|
3612 + if (set_recv_wqes(ctx,&user_param)) { |
|
3613 + fprintf(stderr," Failed to post receive recv_wqes\n"); |
|
3614 + return 1; |
|
3615 + } |
|
3616 + } |
|
3617 + |
|
3618 + if (ctx_hand_shake(&user_param,&my_dest,&rem_dest)) { |
|
3619 + fprintf(stderr,"Failed to exchange date between server and clients\n"); |
|
3620 + return 1; |
|
3621 + } |
|
3622 + |
|
3623 + if (user_param.duplex) { |
|
3624 + if(run_iter_bi(ctx,&user_param)) |
|
3625 + return 18; |
|
3626 + |
|
3627 + } else { |
|
3628 + if((*ptr_to_run_iter_uni)(ctx,&user_param)) |
|
3629 + return 18; |
|
3630 + } |
|
3631 + |
|
3632 + print_report(&user_param); |
|
3633 + } |
|
3634 + |
|
3635 + if (ctx_close_connection(&user_param,&my_dest,&rem_dest)) { |
|
3636 + fprintf(stderr," Failed to close connection between server and client\n"); |
|
3637 + return 1; |
|
3638 + } |
|
3639 + |
|
3640 + printf(RESULT_LINE); |
|
3641 + return destroy_ctx_resources(ctx,&user_param,&my_dest,&rem_dest,&mcg_params); |
|
3642 +} |
|
3643 diff -r -u /tmp/perftest-1.3.0/multicast_resources.c perftest-1.3.0/multicast_resources.c |
|
3644 --- /tmp/perftest-1.3.0/multicast_resources.c Thu Dec 16 08:21:05 2010 |
|
3645 +++ perftest-1.3.0/multicast_resources.c Fri Feb 11 04:12:48 2011 |
|
3646 @@ -4,7 +4,9 @@ |
|
3647 #include <unistd.h> |
|
3648 #include <string.h> |
|
3649 #include <limits.h> |
|
3650 +#if !(defined(__SVR4) && defined(__sun)) |
|
3651 #include <byteswap.h> |
|
3652 +#endif |
|
3653 #include <arpa/inet.h> |
|
3654 #include <sys/types.h> |
|
3655 #include <sys/socket.h> |
|
3656 diff -r -u /tmp/perftest-1.3.0/write_bw.c perftest-1.3.0/write_bw.c |
|
3657 --- /tmp/perftest-1.3.0/write_bw.c Wed Mar 2 11:48:20 2011 |
|
3658 +++ perftest-1.3.0/write_bw.c Tue Mar 15 12:04:28 2011 |
|
3659 @@ -45,6 +45,7 @@ |
|
3660 #include <limits.h> |
|
3661 #include <malloc.h> |
|
3662 #include <getopt.h> |
|
3663 +#include <inttypes.h> |
|
3664 #include <time.h> |
|
3665 #include <infiniband/verbs.h> |
|
3666 |
|
3667 diff -r -u /tmp/perftest-1.3.0/write_bw_postlist.c perftest-1.3.0/write_bw_postlist.c |
|
3668 --- /tmp/perftest-1.3.0/write_bw_postlist.c Thu Mar 3 17:03:54 2011 |
|
3669 +++ perftest-1.3.0/write_bw_postlist.c Tue Mar 15 11:59:53 2011 |
|
3670 @@ -46,6 +46,7 @@ |
|
3671 #include <malloc.h> |
|
3672 #include <getopt.h> |
|
3673 #include <time.h> |
|
3674 +#include <inttypes.h> |
|
3675 #include <infiniband/verbs.h> |
|
3676 |
|
3677 #include "get_clock.h" |
|
3678 diff -r -u /tmp/perftest-1.3.0/write_lat.c perftest-1.3.0/write_lat.c |
|
3679 --- /tmp/perftest-1.3.0/write_lat.c Sat Feb 26 01:02:48 2011 |
|
3680 +++ perftest-1.3.0/write_lat.c Tue Mar 15 12:01:35 2011 |
|
3681 @@ -46,6 +46,7 @@ |
|
3682 #include <malloc.h> |
|
3683 #include <getopt.h> |
|
3684 #include <time.h> |
|
3685 +#include <inttypes.h> |
|
3686 #include <infiniband/verbs.h> |
|
3687 |
|
3688 #include "get_clock.h" |