#This patch was developed both in-house and from outside. We plan to submit it
#upstream, but do not yet have a target date for doing so
#
# HG changeset patch
# Parent 8cb431a3e51bc17ea032c64d150ea7799c778321
#
diff -r 8cb431a3e51b Makefile
--- a/Makefile Tue Feb 23 22:34:35 2016 -0800
+++ b/Makefile Tue Feb 23 22:34:53 2016 -0800
@@ -2,23 +2,25 @@
MCAST_TESTS = send_bw send_lat
TESTS = write_bw_postlist write_lat write_bw read_lat read_bw
UTILS = clock_test
+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
all: ${RDMACM_TESTS} ${MCAST_TESTS} ${TESTS} ${UTILS}
-CFLAGS += -Wall -g -D_GNU_SOURCE -O2
+CFLAGS += -Wall -g -D_GNU_SOURCE -O3
BASIC_FILES = get_clock.c
EXTRA_FILES = perftest_resources.c
MCAST_FILES = multicast_resources.c
BASIC_HEADERS = get_clock.h
EXTRA_HEADERS = perftest_resources.h
MCAST_HEADERS = multicast_resources.h
+CC=gcc
#The following seems to help GNU make on some platforms
LOADLIBES +=
LDFLAGS +=
-${RDMACM_TESTS}: LOADLIBES += -libverbs -lrdmacm
-${MCAST_TESTS}: LOADLIBES += -libverbs -libumad -lm
-${TESTS} ${UTILS}: LOADLIBES += -libverbs
+${RDMACM_TESTS}: LOADLIBES += -lsocket -libverbs -lrdmacm -lrt
+${MCAST_TESTS}: LOADLIBES += -lsocket -libverbs -lrdmacm -lrt -libumad -lm
+${TESTS} ${UTILS}: LOADLIBES += -lsocket -lrt -libverbs
${RDMACM_TESTS}: %: %.c ${BASIC_FILES} ${BASIC_HEADERS}
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< ${BASIC_FILES} $(LOADLIBES) $(LDLIBS) -o $@
@@ -27,6 +29,10 @@
${TESTS} ${UTILS}: %: %.c ${BASIC_FILES} ${EXTRA_FILES} ${BASIC_HEADERS} ${EXTRA_HEADERS}
$(CC) $(CPPFLAGS) $(CFLAGS) $(LDFLAGS) $< ${BASIC_FILES} ${EXTRA_FILES} $(LOADLIBES) $(LDLIBS) -o ib_$@
+install: all
+ $(INSTALL) -d $(DESTDIR)$(BINDIR)
+ $(INSTALL) -m 755 -s $(BINS) $(DESTDIR)$(BINDIR)
+
clean:
$(foreach fname,${RDMACM_TESTS}, rm -f ${fname})
$(foreach fname,${MCAST_TESTS}, rm -f ib_${fname})
diff -r 8cb431a3e51b clock_test.c
--- a/clock_test.c Tue Feb 23 22:34:35 2016 -0800
+++ b/clock_test.c Tue Feb 23 22:34:53 2016 -0800
@@ -20,6 +20,10 @@
c1 = get_cycles();
sleep(1);
c2 = get_cycles();
+#if defined(__sparc)
+ printf("1 sec = %g usec\n", (double)((c2 - c1))/1000);
+#else
printf("1 sec = %g usec\n", (c2 - c1) / mhz);
+#endif
}
}
diff -r 8cb431a3e51b get_clock.c
--- a/get_clock.c Tue Feb 23 22:34:35 2016 -0800
+++ b/get_clock.c Tue Feb 23 22:34:53 2016 -0800
@@ -45,6 +45,10 @@
#include <unistd.h>
#include <stdio.h>
#include "get_clock.h"
+#if defined(__SVR4) && defined(__sun)
+#include <stdlib.h>
+#include <infiniband/ofa_solaris.h>
+#endif
#ifndef DEBUG
#define DEBUG 0
@@ -56,6 +60,8 @@
#define MEASUREMENTS 200
#define USECSTEP 10
#define USECSTART 100
+#define NSECSTART 100000
+#define NSECSTEP 10000
/*
Use linear regression to calculate cycles per microsecond.
@@ -63,14 +69,14 @@
*/
static double sample_get_cpu_mhz(void)
{
- struct timeval tv1, tv2;
+ struct timeval tv1, tv2;
cycles_t start;
double sx = 0, sy = 0, sxx = 0, syy = 0, sxy = 0;
- double tx, ty;
+ cycles_t tx, ty;
int i;
/* Regression: y = a + b x */
- long x[MEASUREMENTS];
+ cycles_t x[MEASUREMENTS];
cycles_t y[MEASUREMENTS];
double a; /* system call overhead in cycles */
double b; /* cycles per microsecond */
@@ -78,7 +84,6 @@
for (i = 0; i < MEASUREMENTS; ++i) {
start = get_cycles();
-
if (gettimeofday(&tv1, NULL)) {
fprintf(stderr, "gettimeofday failed.\n");
return 0;
@@ -86,7 +91,7 @@
do {
if (gettimeofday(&tv2, NULL)) {
- fprintf(stderr, "gettimeofday failed.\n");
+ fprintf(stderr, "gettimeofday failed.\n");
return 0;
}
} while ((tv2.tv_sec - tv1.tv_sec) * 1000000 +
@@ -94,9 +99,10 @@
x[i] = (tv2.tv_sec - tv1.tv_sec) * 1000000 +
tv2.tv_usec - tv1.tv_usec;
+
y[i] = get_cycles() - start;
if (DEBUG_DATA)
- fprintf(stderr, "x=%ld y=%Ld\n", x[i], (long long)y[i]);
+ fprintf(stderr, "x=%lld y=%lld\n", x[i], y[i]);
}
for (i = 0; i < MEASUREMENTS; ++i) {
@@ -134,10 +140,15 @@
static double proc_get_cpu_mhz(int no_cpu_freq_fail)
{
+#if !(defined(__SVR4) && defined(__sun))
FILE* f;
char buf[256];
+#else
+ sol_cpu_info_t *info;
+#endif
double mhz = 0.0;
+#if !(defined(__SVR4) && defined(__sun))
f = fopen("/proc/cpuinfo","r");
if (!f)
return 0.0;
@@ -174,6 +185,13 @@
}
}
fclose(f);
+#else
+ if (sol_get_cpu_info(&info) > 0)
+ mhz = info[0].cpu_mhz;
+ else
+ return (0.0);
+ free(info);
+#endif
return mhz;
}
@@ -184,8 +202,9 @@
sample = sample_get_cpu_mhz();
proc = proc_get_cpu_mhz(no_cpu_freq_fail);
- if (!proc || !sample)
- return 0;
+#if defined(__sparc)
+ return proc;
+#endif
delta = proc > sample ? proc - sample : sample - proc;
if (delta / proc > 0.01) {
@@ -194,5 +213,6 @@
sample, proc);
return sample;
}
+
return proc;
}
diff -r 8cb431a3e51b get_clock.h
--- a/get_clock.h Tue Feb 23 22:34:35 2016 -0800
+++ b/get_clock.h Tue Feb 23 22:34:53 2016 -0800
@@ -36,8 +36,18 @@
#ifndef GET_CLOCK_H
#define GET_CLOCK_H
+#if defined(__sparc)
+#include <sys/times.h>
+#include <limits.h>
+#include <sys/time.h>
+typedef unsigned long long cycles_t;
-#if defined (__x86_64__) || defined(__i386__)
+static inline cycles_t get_cycles()
+{
+ return (gethrtime());
+}
+
+#elif defined (__x86_64__) || defined(__i386__)
/* Note: only x86 CPUs which have rdtsc instruction are supported. */
typedef unsigned long long cycles_t;
static inline cycles_t get_cycles()
diff -r 8cb431a3e51b multicast_resources.c
--- a/multicast_resources.c Tue Feb 23 22:34:35 2016 -0800
+++ b/multicast_resources.c Tue Feb 23 22:34:53 2016 -0800
@@ -4,7 +4,9 @@
#include <unistd.h>
#include <string.h>
#include <limits.h>
+#if !(defined(__SVR4) && defined(__sun))
#include <byteswap.h>
+#endif
#include <arpa/inet.h>
#include <sys/types.h>
#include <sys/socket.h>
diff -r 8cb431a3e51b multicast_resources.h
--- a/multicast_resources.h Tue Feb 23 22:34:35 2016 -0800
+++ b/multicast_resources.h Tue Feb 23 22:34:53 2016 -0800
@@ -68,7 +68,7 @@
#define DEF_PKEY_IDX 0
#define DEF_SLL 0
#define MAX_POLL_ITERATION_TIMEOUT 1000000
-#define MCG_GID {255,1,0,0,0,2,201,133,0,0,0,0,0,0,0,0}
+#define MCG_GID {255,21,0,0,0,2,201,133,0,0,0,0,0,0,0,0}
// Definitions section for MADs
#define SUBN_ADM_ATTR_MC_MEMBER_RECORD 0x38
@@ -80,10 +80,11 @@
#define DEF_TCLASS 0
#define DEF_FLOW_LABLE 0
+#if !(defined(__SVR4) && defined(__sun))
// Macro for 64 bit variables to switch to from net
#define ntohll(x) (((u_int64_t)(ntohl((int)((x << 32) >> 32))) << 32) | (unsigned int)ntohl(((int)(x >> 32))))
#define htonll(x) ntohll(x)
-
+#endif
// generate a bit mask S bits width
#define MASK32(S) ( ((u_int32_t) ~0L) >> (32-(S)) )
diff -r 8cb431a3e51b perftest_resources.c
--- a/perftest_resources.c Tue Feb 23 22:34:35 2016 -0800
+++ b/perftest_resources.c Tue Feb 23 22:34:53 2016 -0800
@@ -11,7 +11,9 @@
#include <sys/socket.h>
#include <netdb.h>
#include <math.h>
+#if !(defined(__SVR4) && defined(__sun))
// #include <byteswap.h>
+#endif
#include "perftest_resources.h"
@@ -566,8 +568,22 @@
// User did not ask for specific mtu.
if (params->mtu == 0) {
+#if !(defined(__SVR4) && defined(__sun))
params->curr_mtu = port_attr.active_mtu;
+#else
+ struct ibv_device_attr device_attr;
+ if (ibv_query_device(context, &device_attr)) {
+ fprintf(stderr, "Failed to query device props");
+ return -1;
+ }
+
+ if (device_attr.vendor_part_id == 23108) {
+ params->curr_mtu = IBV_MTU_1024;
+ } else {
+ params->curr_mtu = IBV_MTU_2048;
+ }
+#endif
} else {
switch (params->mtu) {
@@ -791,7 +807,7 @@
n = getaddrinfo(servername, service, &hints, &res);
- if (n < 0) {
+ if (n != 0) {
fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
return n;
}
@@ -835,7 +851,7 @@
n = getaddrinfo(NULL, service, &hints, &res);
- if (n < 0) {
+ if (n != 0) {
fprintf(stderr, "%s for port %d\n", gai_strerror(n), port);
return n;
}
@@ -869,7 +885,6 @@
close(sockfd);
return connfd;
}
-
close(sockfd);
return connfd;
}
@@ -882,6 +897,8 @@
struct pingpong_dest *my_dest,
struct pingpong_dest *rem_dest) {
+ int temp_reads = 0;
+
// Client.
if (params->machine == CLIENT) {
if (ctx_write_keys(my_dest,params)) {
@@ -904,6 +921,21 @@
return -1;
}
}
+
+ /*
+ * If we have different HCA's at either end of the connection with
+ * different RDMA attributes, then to avoid a modify QP error set
+ * max_rd_atomic to lowest on either side of connection.
+ */
+ if (rem_dest->out_reads > my_dest->out_reads)
+ temp_reads = my_dest->out_reads;
+
+ if (my_dest->out_reads > rem_dest->out_reads)
+ my_dest->out_reads = rem_dest->out_reads;
+
+ if (temp_reads)
+ rem_dest->out_reads = temp_reads;
+
return 0;
}
diff -r 8cb431a3e51b perftest_resources.h
--- a/perftest_resources.h Tue Feb 23 22:34:35 2016 -0800
+++ b/perftest_resources.h Tue Feb 23 22:34:53 2016 -0800
@@ -128,10 +128,10 @@
#define KEY_MSG_SIZE_GID 98 // Message size with gid (MGID as well).
// The Format of the message we pass through sockets , without passing Gid.
-#define KEY_PRINT_FMT "%04x:%04x:%06x:%06x:%08x:%016Lx"
+#define KEY_PRINT_FMT "%04x:%04x:%06x:%06x:%08x:%016llx"
// The Format of the message we pass through sockets (With Gid).
-#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"
+#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"
// The Basic print format for all verbs.
#define BASIC_ADDR_FMT " %s address: LID %#04x QPN %#06x PSN %#06x"
@@ -140,7 +140,7 @@
#define READ_FMT " OUT %#04x"
// The print format of the pingpong_dest element for RDMA verbs.
-#define RDMA_FMT " RKey %#08x VAddr %#016Lx"
+#define RDMA_FMT " RKey %#08x VAddr %#016llx"
// The print format of a global address or a multicast address.
#define GID_FMT " %s: %02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d:%02d\n"
@@ -154,10 +154,10 @@
#define RESULT_FMT_LAT " #bytes #iterations t_min[usec] t_max[usec] t_typical[usec]\n"
// Result print format
-#define REPORT_FMT " %-7lu %d %-7.2f %-7.2f\n"
+#define REPORT_FMT " %-7"PRIu64" %d %-7.2f %-7.2f\n"
// Result print format for latency tests.
-#define REPORT_FMT_LAT " %-7lu %d %-7.2f %-7.2f %-7.2f\n"
+#define REPORT_FMT_LAT " %-7"PRIu64" %d %-7.2f %-7.2f %-7.2f\n"
// Macro for allocating.
#define ALLOCATE(var,type,size) \
diff -r 8cb431a3e51b rdma_bw.c
--- a/rdma_bw.c Tue Feb 23 22:34:35 2016 -0800
+++ b/rdma_bw.c Tue Feb 23 22:34:53 2016 -0800
@@ -50,8 +50,11 @@
#include <malloc.h>
#include <getopt.h>
#include <arpa/inet.h>
+#if !(defined(__SVR4) && defined(__sun))
#include <byteswap.h>
+#endif
#include <time.h>
+#include <inttypes.h>
#include <infiniband/verbs.h>
#include <rdma/rdma_cma.h>
@@ -142,9 +145,9 @@
n = getaddrinfo(data->servername, service, &hints, &res);
- if (n < 0) {
+ if (n != 0) {
fprintf(stderr, "%d:%s: %s for %s:%d\n",
- pid, __func__, gai_strerror(n),
+ (int)pid, __func__, gai_strerror(n),
data->servername, data->port);
goto err4;
}
@@ -157,7 +160,7 @@
if (rdma_resolve_addr(data->cm_id, NULL,
(struct sockaddr *)&sin, 2000)) {
fprintf(stderr, "%d:%s: rdma_resolve_addr failed\n",
- pid, __func__ );
+ (int)pid, __func__ );
goto err2;
}
@@ -172,7 +175,7 @@
if (event->event != RDMA_CM_EVENT_ADDR_RESOLVED) {
fprintf(stderr, "%d:%s: unexpected CM event %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err1;
}
rdma_ack_cm_event(event);
@@ -180,7 +183,7 @@
retry_route:
if (rdma_resolve_route(data->cm_id, 2000)) {
fprintf(stderr, "%d:%s: rdma_resolve_route failed\n",
- pid, __func__);
+ (int)pid, __func__);
goto err2;
}
@@ -195,14 +198,14 @@
if (event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) {
fprintf(stderr, "%d:%s: unexpected CM event %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
rdma_ack_cm_event(event);
goto err1;
}
rdma_ack_cm_event(event);
ctx = pp_init_ctx(data->cm_id, data);
if (!ctx) {
- fprintf(stderr, "%d:%s: pp_init_ctx failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: pp_init_ctx failed\n", (int)pid, __func__);
goto err2;
}
data->my_dest.psn = lrand48() & 0xffffff;
@@ -218,7 +221,7 @@
conn_param.private_data_len = sizeof(data->my_dest);
if (rdma_connect(data->cm_id, &conn_param)) {
- fprintf(stderr, "%d:%s: rdma_connect failure\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_connect failure\n", (int)pid, __func__);
goto err2;
}
@@ -227,13 +230,13 @@
if (event->event != RDMA_CM_EVENT_ESTABLISHED) {
fprintf(stderr, "%d:%s: unexpected CM event %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err1;
}
if (!event->param.conn.private_data ||
(event->param.conn.private_data_len < sizeof(*data->rem_dest))) {
fprintf(stderr, "%d:%s: bad private data ptr %p len %d\n",
- pid, __func__, event->param.conn.private_data,
+ (int)pid, __func__, event->param.conn.private_data,
event->param.conn.private_data_len);
goto err1;
}
@@ -257,7 +260,7 @@
}
if (sockfd < 0) {
fprintf(stderr, "%d:%s: Couldn't connect to %s:%d\n",
- pid, __func__, data->servername, data->port);
+ (int)pid, __func__, data->servername, data->port);
goto err3;
}
ctx = pp_init_ctx(data->ib_dev, data);
@@ -287,20 +290,20 @@
int parsed;
if (!data->use_cma) {
- sprintf(msg, "%04x:%06x:%06x:%08x:%016Lx", data->my_dest.lid,
+ sprintf(msg, "%04x:%06x:%06x:%08x:%016llx", data->my_dest.lid,
data->my_dest.qpn, data->my_dest.psn,
data->my_dest.rkey, data->my_dest.vaddr);
if (write(data->sockfd, msg, sizeof msg) != sizeof msg) {
perror("client write");
fprintf(stderr, "%d:%s: Couldn't send local address\n",
- pid, __func__);
+ (int)pid, __func__);
goto err;
}
if (read(data->sockfd, msg, sizeof msg) != sizeof msg) {
perror("client read");
fprintf(stderr, "%d:%s: Couldn't read remote address\n",
- pid, __func__);
+ (int)pid, __func__);
goto err;
}
@@ -310,13 +313,13 @@
if (!data->rem_dest)
goto err;
- parsed = sscanf(msg, "%x:%x:%x:%x:%Lx", &data->rem_dest->lid,
+ parsed = sscanf(msg, "%x:%x:%x:%x:%llx", &data->rem_dest->lid,
&data->rem_dest->qpn, &data->rem_dest->psn,
&data->rem_dest->rkey, &data->rem_dest->vaddr);
if (parsed != 5) {
fprintf(stderr, "%d:%s: Couldn't parse line <%.*s>\n",
- pid, __func__, (int)sizeof msg, msg);
+ (int)pid, __func__, (int)sizeof msg, msg);
free(data->rem_dest);
goto err;
}
@@ -346,8 +349,8 @@
if (asprintf(&service, "%d", data->port) < 0)
goto err5;
- if ( (n = getaddrinfo(NULL, service, &hints, &res)) < 0 ) {
- fprintf(stderr, "%d:%s: %s for port %d\n", pid, __func__,
+ if ( (n = getaddrinfo(NULL, service, &hints, &res) != 0) ) {
+ fprintf(stderr, "%d:%s: %s for port %d\n", (int)pid, __func__,
gai_strerror(n), data->port);
goto err5;
}
@@ -357,12 +360,12 @@
sin.sin_family = AF_INET;
sin.sin_port = htons(data->port);
if (rdma_bind_addr(data->cm_id, (struct sockaddr *)&sin)) {
- fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", (int)pid, __func__);
goto err3;
}
if (rdma_listen(data->cm_id, 0)) {
- fprintf(stderr, "%d:%s: rdma_listen failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_listen failed\n", (int)pid, __func__);
goto err3;
}
@@ -371,13 +374,13 @@
if (event->event != RDMA_CM_EVENT_CONNECT_REQUEST) {
fprintf(stderr, "%d:%s: bad event waiting for connect request %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err2;
}
if (!event->param.conn.private_data ||
(event->param.conn.private_data_len < sizeof(*data->rem_dest))) {
- fprintf(stderr, "%d:%s: bad private data len %d\n", pid,
+ fprintf(stderr, "%d:%s: bad private data len %d\n", (int)pid,
__func__, event->param.conn.private_data_len);
goto err2;
}
@@ -405,18 +408,18 @@
conn_param.private_data = &data->my_dest;
conn_param.private_data_len = sizeof(data->my_dest);
if (rdma_accept(child_cm_id, &conn_param)) {
- fprintf(stderr, "%d:%s: rdma_accept failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_accept failed\n", (int)pid, __func__);
goto err1;
}
rdma_ack_cm_event(event);
if (rdma_get_cm_event(data->cm_channel, &event)) {
- fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", (int)pid, __func__);
rdma_destroy_id(child_cm_id);
goto err3;
}
if (event->event != RDMA_CM_EVENT_ESTABLISHED) {
fprintf(stderr, "%d:%s: bad event waiting for established %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err1;
}
rdma_ack_cm_event(event);
@@ -436,7 +439,7 @@
}
if (sockfd < 0) {
- fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", (int)pid,
__func__, data->port);
goto err4;
}
@@ -445,7 +448,7 @@
connfd = accept(sockfd, NULL, 0);
if (connfd < 0) {
perror("server accept");
- fprintf(stderr, "%d:%s: accept() failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: accept() failed\n", (int)pid, __func__);
close(sockfd);
goto err4;
}
@@ -485,7 +488,7 @@
if (n != sizeof msg) {
perror("server read");
fprintf(stderr, "%d:%s: %d/%d Couldn't read remote address\n",
- pid, __func__, n, (int) sizeof msg);
+ (int)pid, __func__, n, (int) sizeof msg);
goto err;
}
@@ -495,23 +498,23 @@
if (!data->rem_dest)
goto err;
- parsed = sscanf(msg, "%x:%x:%x:%x:%Lx", &data->rem_dest->lid,
+ parsed = sscanf(msg, "%x:%x:%x:%x:%llx", &data->rem_dest->lid,
&data->rem_dest->qpn, &data->rem_dest->psn,
&data->rem_dest->rkey, &data->rem_dest->vaddr);
if (parsed != 5) {
- fprintf(stderr, "%d:%s: Couldn't parse line <%.*s>\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't parse line <%.*s>\n", (int)pid,
__func__, (int)sizeof msg, msg);
free(data->rem_dest);
goto err;
}
- sprintf(msg, "%04x:%06x:%06x:%08x:%016Lx", data->my_dest.lid,
+ sprintf(msg, "%04x:%06x:%06x:%08x:%016llx", data->my_dest.lid,
data->my_dest.qpn, data->my_dest.psn,
data->my_dest.rkey, data->my_dest.vaddr);
if (write(data->sockfd, msg, sizeof msg) != sizeof msg) {
perror("server write");
fprintf(stderr, "%d:%s: Couldn't send local address\n",
- pid, __func__);
+ (int)pid, __func__);
free(data->rem_dest);
goto err;
}
@@ -538,7 +541,7 @@
ctx->buf = memalign(page_size, ctx->size * 2);
if (!ctx->buf) {
fprintf(stderr, "%d:%s: Couldn't allocate work buf.\n",
- pid, __func__);
+ (int)pid, __func__);
return NULL;
}
@@ -548,7 +551,7 @@
cm_id = (struct rdma_cm_id *)ptr;
ctx->context = cm_id->verbs;
if (!ctx->context) {
- fprintf(stderr, "%d:%s: Unbound cm_id!!\n", pid,
+ fprintf(stderr, "%d:%s: Unbound cm_id!!\n", (int)pid,
__func__);
return NULL;
}
@@ -558,14 +561,14 @@
ctx->context = ibv_open_device(ib_dev);
if (!ctx->context) {
fprintf(stderr, "%d:%s: Couldn't get context for %s\n",
- pid, __func__, ibv_get_device_name(ib_dev));
+ (int)pid, __func__, ibv_get_device_name(ib_dev));
return NULL;
}
}
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
- fprintf(stderr, "%d:%s: Couldn't allocate PD\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't allocate PD\n", (int)pid, __func__);
return NULL;
}
@@ -575,28 +578,28 @@
ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, ctx->size * 2,
IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
- fprintf(stderr, "%d:%s: Couldn't allocate MR\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't allocate MR\n", (int)pid, __func__);
return NULL;
}
ctx->ch = ibv_create_comp_channel(ctx->context);
if (!ctx->ch) {
- fprintf(stderr, "%d:%s: Couldn't create comp channel\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't create comp channel\n", (int)pid,
__func__);
return NULL;
}
ctx->rcq = ibv_create_cq(ctx->context, 1, NULL, NULL, 0);
if (!ctx->rcq) {
- fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", (int)pid,
__func__);
return NULL;
}
ctx->scq = ibv_create_cq(ctx->context, ctx->tx_depth, ctx, ctx->ch, 0);
if (!ctx->scq) {
- fprintf(stderr, "%d:%s: Couldn't create send CQ\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't create send CQ\n", (int)pid,
__func__);
return NULL;
}
@@ -619,7 +622,7 @@
if (data->use_cma) {
if (rdma_create_qp(cm_id, ctx->pd, &attr)) {
- fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__);
return NULL;
}
ctx->qp = cm_id->qp;
@@ -628,7 +631,7 @@
} else {
ctx->qp = ibv_create_qp(ctx->pd, &attr);
if (!ctx->qp) {
- fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__);
return NULL;
}
{
@@ -645,7 +648,7 @@
IBV_QP_PORT |
IBV_QP_ACCESS_FLAGS)) {
fprintf(stderr, "%d:%s: Failed to modify QP to INIT\n",
- pid, __func__);
+ (int)pid, __func__);
return NULL;
}
}
@@ -679,7 +682,7 @@
IBV_QP_RQ_PSN |
IBV_QP_MAX_DEST_RD_ATOMIC |
IBV_QP_MIN_RNR_TIMER)) {
- fprintf(stderr, "%d:%s: Failed to modify QP to RTR\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Failed to modify QP to RTR\n", (int)pid, __func__);
return 1;
}
@@ -696,7 +699,7 @@
IBV_QP_RNR_RETRY |
IBV_QP_SQ_PSN |
IBV_QP_MAX_QP_RD_ATOMIC)) {
- fprintf(stderr, "%d:%s: Failed to modify QP to RTS\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Failed to modify QP to RTS\n", (int)pid, __func__);
return 1;
}
@@ -720,7 +723,7 @@
rc = ibv_post_recv(ctx->qp, &wr, &bad_wr);
if (rc) {
perror("ibv_post_recv");
- fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", pid,
+ fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", (int)pid,
__func__, rc);
}
}
@@ -736,13 +739,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (!(wc.opcode & IBV_WC_RECV))
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xdeadbeef)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
}
@@ -762,7 +765,7 @@
ctx->wr.send_flags = IBV_SEND_SIGNALED;
ctx->wr.next = NULL;
if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) {
- fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__);
return;
}
do {
@@ -771,13 +774,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (wc.opcode != IBV_WC_SEND)
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xcafebabe)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
}
@@ -792,13 +795,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (!(wc.opcode & IBV_WC_RECV))
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xdeadbeef)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
pp_post_recv(ctx);
}
@@ -819,7 +822,7 @@
ctx->wr.send_flags = IBV_SEND_SIGNALED;
ctx->wr.next = NULL;
if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) {
- fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__);
return;
}
do {
@@ -828,13 +831,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (wc.opcode != IBV_WC_SEND)
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xabbaabba)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
}
@@ -847,7 +850,7 @@
rc = rdma_disconnect(data.cm_id);
if (rc) {
perror("rdma_disconnect");
- fprintf(stderr, "%d:%s: rdma disconnect error\n", pid,
+ fprintf(stderr, "%d:%s: rdma disconnect error\n", (int)pid,
__func__);
return;
}
@@ -856,7 +859,7 @@
rdma_get_cm_event(data.cm_channel, &event);
if (event->event != RDMA_CM_EVENT_DISCONNECTED)
fprintf(stderr, "%d:%s: unexpected event during disconnect %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
rdma_ack_cm_event(event);
rdma_destroy_id(data.cm_id);
rdma_destroy_event_channel(data.cm_channel);
@@ -904,22 +907,26 @@
}
}
+#if !(defined(__SVR4) && defined(__sun))
cycles_to_units = get_cpu_mhz(0) * 1000000;
+#else
+ cycles_to_units = 1000000000;
+#endif
tsize = duplex ? 2 : 1;
tsize = tsize * size;
- printf("\n%d: Bandwidth peak (#%d to #%d): %g MB/sec\n", pid,
+ printf("\n%d: Bandwidth peak (#%d to #%d): %g MB/sec\n", (int)pid,
opt_posted, opt_completed,
tsize * cycles_to_units / opt_delta / 0x100000);
- printf("%d: Bandwidth average: %g MB/sec\n", pid,
+ printf("%d: Bandwidth average: %g MB/sec\n", (int)pid,
tsize * iters * cycles_to_units /
(tcompleted[iters - 1] - tposted[0]) / 0x100000);
- printf("%d: Service Demand peak (#%d to #%d): %ld cycles/KB\n", pid,
+ printf("%d: Service Demand peak (#%d to #%d): %ld cycles/KB\n", (int)pid,
opt_posted, opt_completed,
(unsigned long)opt_delta * 1024 / tsize);
- printf("%d: Service Demand Avg : %ld cycles/KB\n", pid,
+ printf("%d: Service Demand Avg : %ld cycles/KB\n", (int)pid,
(unsigned long)(tcompleted[iters - 1] - tposted[0]) *
1024 / (tsize * iters));
}
@@ -1046,7 +1053,7 @@
pid = getpid();
printf("%d: | port=%d | ib_port=%d | size=%d | tx_depth=%d | sl=%d | iters=%d | duplex=%d | cma=%d |\n",
- pid, data.port, data.ib_port, data.size, data.tx_depth,
+ (int)pid, data.port, data.ib_port, data.size, data.tx_depth,
sl, iters, duplex, data.use_cma);
/* Done with parameter parsing. Perform setup. */
@@ -1059,12 +1066,12 @@
data.cm_channel = rdma_create_event_channel();
if (!data.cm_channel) {
fprintf(stderr, "%d:%s: rdma_create_event_channel failed\n",
- pid, __func__);
+ (int)pid, __func__);
return 1;
}
if (rdma_create_id(data.cm_channel, &data.cm_id, NULL, RDMA_PS_TCP)) {
fprintf(stderr, "%d:%s: rdma_create_id failed\n",
- pid, __func__);
+ (int)pid, __func__);
return 1;
}
@@ -1079,12 +1086,17 @@
}
} else {
dev_list = ibv_get_device_list(NULL);
+ if (!dev_list) {
+ fprintf(stderr, "%d:%s: No IB devices found\n",
+ (int)pid, __func__);
+ return 1;
+ }
if (!ib_devname) {
data.ib_dev = dev_list[0];
if (!data.ib_dev) {
fprintf(stderr, "%d:%s: No IB devices found\n",
- pid, __func__);
+ (int)pid, __func__);
return 1;
}
} else {
@@ -1093,7 +1105,7 @@
break;
if (!data.ib_dev) {
fprintf(stderr, "%d:%s: IB device %s not found\n",
- pid, __func__, ib_devname);
+ (int)pid, __func__, ib_devname);
return 1;
}
}
@@ -1109,7 +1121,7 @@
data.my_dest.lid = pp_get_local_lid(ctx, data.ib_port);
if (!data.my_dest.lid) {
fprintf(stderr, "%d:%s: Local lid 0x0 detected. Is an SM running?\n",
- pid, __func__);
+ (int)pid, __func__);
return 1;
}
data.my_dest.qpn = ctx->qp->qp_num;
@@ -1129,12 +1141,12 @@
}
printf("%d: Local address: LID %#04x, QPN %#06x, PSN %#06x "
- "RKey %#08x VAddr %#016Lx\n", pid,
+ "RKey %#08x VAddr %#016llx\n", (int)pid,
data.my_dest.lid, data.my_dest.qpn, data.my_dest.psn,
data.my_dest.rkey, data.my_dest.vaddr);
printf("%d: Remote address: LID %#04x, QPN %#06x, PSN %#06x, "
- "RKey %#08x VAddr %#016Lx\n\n", pid,
+ "RKey %#08x VAddr %#016llx\n\n", (int)pid,
data.rem_dest->lid, data.rem_dest->qpn, data.rem_dest->psn,
data.rem_dest->rkey, data.rem_dest->vaddr);
@@ -1219,7 +1231,7 @@
if (ibv_post_send(qp, &ctx->wr, &bad_wr)) {
fprintf(stderr, "%d:%s: Couldn't post send: scnt=%d\n",
- pid, __func__, scnt);
+ (int)pid, __func__, scnt);
return 1;
}
++scnt;
@@ -1235,17 +1247,17 @@
tcompleted[ccnt] = get_cycles();
if (ne < 0) {
- fprintf(stderr, "%d:%s: poll CQ failed %d\n", pid,
+ fprintf(stderr, "%d:%s: poll CQ failed %d\n", (int)pid,
__func__, ne);
return 1;
}
if (wc.status != IBV_WC_SUCCESS) {
fprintf(stderr, "%d:%s: Completion with error at %s:\n",
- pid, __func__, data.servername ? "client" : "server");
+ (int)pid, __func__, data.servername ? "client" : "server");
fprintf(stderr, "%d:%s: Failed status %d: wr_id %d\n",
- pid, __func__, wc.status, (int) wc.wr_id);
+ (int)pid, __func__, wc.status, (int) wc.wr_id);
fprintf(stderr, "%d:%s: scnt=%d, ccnt=%d\n",
- pid, __func__, scnt, ccnt);
+ (int)pid, __func__, scnt, ccnt);
return 1;
}
ccnt += 1;
@@ -1265,7 +1277,7 @@
write(data.sockfd, "done", sizeof "done");
close(data.sockfd);
-
+
}
print_report(iters, data.size, duplex, tposted, tcompleted);
diff -r 8cb431a3e51b rdma_lat.c
--- a/rdma_lat.c Tue Feb 23 22:34:35 2016 -0800
+++ b/rdma_lat.c Tue Feb 23 22:34:53 2016 -0800
@@ -50,8 +50,11 @@
#include <malloc.h>
#include <getopt.h>
#include <arpa/inet.h>
+#if !(defined(__SVR4) && defined(__sun))
#include <byteswap.h>
+#endif
#include <time.h>
+#include <inttypes.h>
#include <infiniband/verbs.h>
#include <rdma/rdma_cma.h>
@@ -138,6 +141,11 @@
struct ibv_device *ib_dev = NULL;
dev_list = ibv_get_device_list(NULL);
+ if (!dev_list) {
+ fprintf(stderr, "%d:%s: No IB devices found\n",
+ (int)pid, __func__);
+ return NULL;
+ }
if (!ib_devname) {
ib_dev = dev_list[0];
@@ -155,7 +163,8 @@
}
#define KEY_MSG_SIZE (sizeof "0000:000000:000000:00000000:0000000000000000")
-#define KEY_PRINT_FMT "%04x:%06x:%06x:%08x:%016Lx"
+#define KEY_PRINT_FMT "%04x:%06x:%06x:%08x:%016" "llx"
+#define KEY_SCAN_FMT "%04x:%06x:%06x:%08x:%016" "llx"
static int pp_write_keys(int sockfd, const struct pingpong_dest *my_dest)
{
@@ -185,7 +194,7 @@
return -1;
}
- parsed = sscanf(msg, KEY_PRINT_FMT, &rem_dest->lid, &rem_dest->qpn,
+ parsed = sscanf(msg, KEY_SCAN_FMT, &rem_dest->lid, &rem_dest->qpn,
&rem_dest->psn, &rem_dest->rkey, &rem_dest->vaddr);
if (parsed != 5) {
@@ -218,9 +227,9 @@
n = getaddrinfo(data->servername, service, &hints, &res);
- if (n < 0) {
+ if (n != 0) {
fprintf(stderr, "%d:%s: %s for %s:%d\n",
- pid, __func__, gai_strerror(n),
+ (int)pid, __func__, gai_strerror(n),
data->servername, data->port);
goto err4;
}
@@ -233,7 +242,7 @@
if (rdma_resolve_addr(data->cm_id, NULL,
(struct sockaddr *)&sin, 2000)) {
fprintf(stderr, "%d:%s: rdma_resolve_addr failed\n",
- pid, __func__ );
+ (int)pid, __func__ );
goto err2;
}
@@ -248,7 +257,7 @@
if (event->event != RDMA_CM_EVENT_ADDR_RESOLVED) {
fprintf(stderr, "%d:%s: unexpected CM event %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err1;
}
rdma_ack_cm_event(event);
@@ -256,7 +265,7 @@
retry_route:
if (rdma_resolve_route(data->cm_id, 2000)) {
fprintf(stderr, "%d:%s: rdma_resolve_route failed\n",
- pid, __func__);
+ (int)pid, __func__);
goto err2;
}
@@ -271,14 +280,14 @@
if (event->event != RDMA_CM_EVENT_ROUTE_RESOLVED) {
fprintf(stderr, "%d:%s: unexpected CM event %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
rdma_ack_cm_event(event);
goto err1;
}
rdma_ack_cm_event(event);
ctx = pp_init_ctx(data->cm_id, data);
if (!ctx) {
- fprintf(stderr, "%d:%s: pp_init_ctx failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: pp_init_ctx failed\n", (int)pid, __func__);
goto err2;
}
data->my_dest.psn = lrand48() & 0xffffff;
@@ -294,7 +303,7 @@
conn_param.private_data_len = sizeof(data->my_dest);
if (rdma_connect(data->cm_id, &conn_param)) {
- fprintf(stderr, "%d:%s: rdma_connect failure\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_connect failure\n", (int)pid, __func__);
goto err2;
}
@@ -303,13 +312,13 @@
if (event->event != RDMA_CM_EVENT_ESTABLISHED) {
fprintf(stderr, "%d:%s: unexpected CM event %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err1;
}
if (!event->param.conn.private_data ||
(event->param.conn.private_data_len < sizeof(*data->rem_dest))) {
fprintf(stderr, "%d:%s: bad private data ptr %p len %d\n",
- pid, __func__, event->param.conn.private_data,
+ (int)pid, __func__, event->param.conn.private_data,
event->param.conn.private_data_len);
goto err1;
}
@@ -332,7 +341,7 @@
}
if (sockfd < 0) {
fprintf(stderr, "%d:%s: Couldn't connect to %s:%d\n",
- pid, __func__, data->servername, data->port);
+ (int)pid, __func__, data->servername, data->port);
goto err3;
}
ctx = pp_init_ctx(data->ib_dev, data);
@@ -392,8 +401,8 @@
if (asprintf(&service, "%d", data->port) < 0)
goto err5;
- if ( (n = getaddrinfo(NULL, service, &hints, &res)) < 0 ) {
- fprintf(stderr, "%d:%s: %s for port %d\n", pid, __func__,
+ if ( (n = getaddrinfo(NULL, service, &hints, &res) != 0) ) {
+ fprintf(stderr, "%d:%s: %s for port %d\n", (int)pid, __func__,
gai_strerror(n), data->port);
goto err5;
}
@@ -403,12 +412,12 @@
sin.sin_family = AF_INET;
sin.sin_port = htons(data->port);
if (rdma_bind_addr(data->cm_id, (struct sockaddr *)&sin)) {
- fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_bind_addr failed\n", (int)pid, __func__);
goto err3;
}
if (rdma_listen(data->cm_id, 0)) {
- fprintf(stderr, "%d:%s: rdma_listen failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_listen failed\n", (int)pid, __func__);
goto err3;
}
@@ -417,13 +426,13 @@
if (event->event != RDMA_CM_EVENT_CONNECT_REQUEST) {
fprintf(stderr, "%d:%s: bad event waiting for connect request %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err2;
}
if (!event->param.conn.private_data ||
(event->param.conn.private_data_len < sizeof(*data->rem_dest))) {
- fprintf(stderr, "%d:%s: bad private data len %d\n", pid,
+ fprintf(stderr, "%d:%s: bad private data len %d\n", (int)pid,
__func__, event->param.conn.private_data_len);
goto err2;
}
@@ -451,18 +460,18 @@
conn_param.private_data = &data->my_dest;
conn_param.private_data_len = sizeof(data->my_dest);
if (rdma_accept(child_cm_id, &conn_param)) {
- fprintf(stderr, "%d:%s: rdma_accept failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_accept failed\n", (int)pid, __func__);
goto err1;
}
rdma_ack_cm_event(event);
if (rdma_get_cm_event(data->cm_channel, &event)) {
- fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", pid, __func__);
+ fprintf(stderr, "%d:%s: rdma_get_cm_event error\n", (int)pid, __func__);
rdma_destroy_id(child_cm_id);
goto err3;
}
if (event->event != RDMA_CM_EVENT_ESTABLISHED) {
fprintf(stderr, "%d:%s: bad event waiting for established %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
goto err1;
}
rdma_ack_cm_event(event);
@@ -482,7 +491,7 @@
}
if (sockfd < 0) {
- fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't listen to port %d\n", (int)pid,
__func__, data->port);
goto err4;
}
@@ -491,7 +500,7 @@
connfd = accept(sockfd, NULL, 0);
if (connfd < 0) {
perror("server accept");
- fprintf(stderr, "%d:%s: accept() failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: accept() failed\n", (int)pid, __func__);
close(sockfd);
goto err4;
}
@@ -551,7 +560,7 @@
ctx->buf = memalign(page_size, ctx->size * 2);
if (!ctx->buf) {
fprintf(stderr, "%d:%s: Couldn't allocate work buf.\n",
- pid, __func__);
+ (int)pid, __func__);
return NULL;
}
@@ -565,7 +574,7 @@
cm_id = (struct rdma_cm_id *)ptr;
ctx->context = cm_id->verbs;
if (!ctx->context) {
- fprintf(stderr, "%d:%s: Unbound cm_id!!\n", pid,
+ fprintf(stderr, "%d:%s: Unbound cm_id!!\n", (int)pid,
__func__);
return NULL;
}
@@ -575,14 +584,14 @@
ctx->context = ibv_open_device(ib_dev);
if (!ctx->context) {
fprintf(stderr, "%d:%s: Couldn't get context for %s\n",
- pid, __func__, ibv_get_device_name(ib_dev));
+ (int)pid, __func__, ibv_get_device_name(ib_dev));
return NULL;
}
}
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
- fprintf(stderr, "%d:%s: Couldn't allocate PD\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't allocate PD\n", (int)pid, __func__);
return NULL;
}
@@ -592,20 +601,20 @@
ctx->mr = ibv_reg_mr(ctx->pd, ctx->buf, ctx->size * 2,
IBV_ACCESS_REMOTE_WRITE | IBV_ACCESS_LOCAL_WRITE);
if (!ctx->mr) {
- fprintf(stderr, "%d:%s: Couldn't allocate MR\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't allocate MR\n", (int)pid, __func__);
return NULL;
}
ctx->rcq = ibv_create_cq(ctx->context, 1, NULL, NULL, 0);
if (!ctx->rcq) {
- fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't create recv CQ\n", (int)pid,
__func__);
return NULL;
}
ctx->scq = ibv_create_cq(ctx->context, ctx->tx_depth, ctx, NULL, 0);
if (!ctx->scq) {
- fprintf(stderr, "%d:%s: Couldn't create send CQ\n", pid,
+ fprintf(stderr, "%d:%s: Couldn't create send CQ\n", (int)pid,
__func__);
return NULL;
}
@@ -628,7 +637,7 @@
if (data->use_cma) {
if (rdma_create_qp(cm_id, ctx->pd, &attr)) {
- fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__);
return NULL;
}
ctx->qp = cm_id->qp;
@@ -636,7 +645,7 @@
} else {
ctx->qp = ibv_create_qp(ctx->pd, &attr);
if (!ctx->qp) {
- fprintf(stderr, "%d:%s: Couldn't create QP\n", pid, __func__);
+ fprintf(stderr, "%d:%s: Couldn't create QP\n", (int)pid, __func__);
return NULL;
}
{
@@ -653,7 +662,7 @@
IBV_QP_PORT |
IBV_QP_ACCESS_FLAGS)) {
fprintf(stderr, "%d:%s: Failed to modify QP to INIT\n",
- pid, __func__);
+ (int)pid, __func__);
return NULL;
}
}
@@ -710,10 +719,10 @@
return 0;
}
+#define ADDR_FMT "%8s address: LID %#04x QPN %#06x PSN %#06x RKey %#08x VAddr %#016" "llx" "\n"
+
static int pp_open_port(struct pingpong_context *ctx, struct pp_data *data )
{
- char addr_fmt[] = "%8s address: LID %#04x QPN %#06x PSN %#06x RKey %#08x VAddr %#016Lx\n";
-
/* Create connection between client and server.
* We do it by exchanging data over a TCP socket connection. */
@@ -727,7 +736,7 @@
data->my_dest.rkey = ctx->mr->rkey;
data->my_dest.vaddr = (uintptr_t)ctx->buf + ctx->size;
- printf(addr_fmt, "local", data->my_dest.lid, data->my_dest.qpn, data->my_dest.psn,
+ printf(ADDR_FMT, "local", data->my_dest.lid, data->my_dest.qpn, data->my_dest.psn,
data->my_dest.rkey, data->my_dest.vaddr);
if (data->servername) {
@@ -738,7 +747,7 @@
return 1;
}
- printf(addr_fmt, "remote", data->rem_dest->lid, data->rem_dest->qpn,
+ printf(ADDR_FMT, "remote", data->rem_dest->lid, data->rem_dest->qpn,
data->rem_dest->psn, data->rem_dest->rkey,
data->rem_dest->vaddr);
@@ -783,7 +792,7 @@
rc = ibv_post_recv(ctx->qp, &wr, &bad_wr);
if (rc) {
perror("ibv_post_recv");
- fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", pid,
+ fprintf(stderr, "%d:%s: ibv_post_recv failed %d\n", (int)pid,
__func__, rc);
}
}
@@ -799,13 +808,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (!(wc.opcode & IBV_WC_RECV))
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xdeadbeef)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
}
@@ -825,7 +834,7 @@
ctx->wr.send_flags = IBV_SEND_SIGNALED;
ctx->wr.next = NULL;
if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) {
- fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__);
return;
}
do {
@@ -834,13 +843,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (wc.opcode != IBV_WC_SEND)
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xcafebabe)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
}
@@ -855,13 +864,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (!(wc.opcode & IBV_WC_RECV))
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xdeadbeef)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
pp_post_recv(ctx);
}
@@ -882,7 +891,7 @@
ctx->wr.send_flags = IBV_SEND_SIGNALED;
ctx->wr.next = NULL;
if (ibv_post_send(ctx->qp, &ctx->wr, &bad_wr)) {
- fprintf(stderr, "%d:%s: ibv_post_send failed\n", pid, __func__);
+ fprintf(stderr, "%d:%s: ibv_post_send failed\n", (int)pid, __func__);
return;
}
do {
@@ -891,13 +900,13 @@
} while (ne == 0);
if (wc.status)
- fprintf(stderr, "%d:%s: bad wc status %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc status %d\n", (int)pid, __func__,
wc.status);
if (wc.opcode != IBV_WC_SEND)
- fprintf(stderr, "%d:%s: bad wc opcode %d\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc opcode %d\n", (int)pid, __func__,
wc.opcode);
if (wc.wr_id != 0xabbaabba)
- fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", pid, __func__,
+ fprintf(stderr, "%d:%s: bad wc wr_id 0x%x\n", (int)pid, __func__,
(int)wc.wr_id);
}
@@ -910,7 +919,7 @@
rc = rdma_disconnect(data.cm_id);
if (rc) {
perror("rdma_disconnect");
- fprintf(stderr, "%d:%s: rdma disconnect error\n", pid,
+ fprintf(stderr, "%d:%s: rdma disconnect error\n", (int)pid,
__func__);
return;
}
@@ -919,7 +928,7 @@
rdma_get_cm_event(data.cm_channel, &event);
if (event->event != RDMA_CM_EVENT_DISCONNECTED)
fprintf(stderr, "%d:%s: unexpected event during disconnect %d\n",
- pid, __func__, event->event);
+ (int)pid, __func__, event->event);
rdma_ack_cm_event(event);
rdma_destroy_id(data.cm_id);
rdma_destroy_event_channel(data.cm_channel);
@@ -989,10 +998,18 @@
if (options->cycles) {
+#if !(defined(__SVR4) && defined(__sun))
cycles_to_units = 1;
+#else
+ cycles_to_units = (1/get_cpu_mhz(0)) * 1000;
+#endif
units = "cycles";
} else {
+#if !(defined(__SVR4) && defined(__sun))
cycles_to_units = get_cpu_mhz(0);
+#else
+ cycles_to_units = 1000;
+#endif
units = "usec";
}
@@ -1164,12 +1181,12 @@
data.cm_channel = rdma_create_event_channel();
if (!data.cm_channel) {
fprintf(stderr, "%d:%s: rdma_create_event_channel failed\n",
- pid, __func__);
+ (int)pid, __func__);
return 1;
}
if (rdma_create_id(data.cm_channel, &data.cm_id, NULL, RDMA_PS_TCP)) {
fprintf(stderr, "%d:%s: rdma_create_id failed\n",
- pid, __func__);
+ (int)pid, __func__);
return 1;
}
@@ -1184,12 +1201,12 @@
}
printf("%d: Local address: LID %#04x, QPN %#06x, PSN %#06x "
- "RKey %#08x VAddr %#016Lx\n", pid,
+ "RKey %#08x VAddr %#016llx\n", (int)pid,
data.my_dest.lid, data.my_dest.qpn, data.my_dest.psn,
data.my_dest.rkey, data.my_dest.vaddr);
printf("%d: Remote address: LID %#04x, QPN %#06x, PSN %#06x, "
- "RKey %#08x VAddr %#016Lx\n\n", pid,
+ "RKey %#08x VAddr %#016llx\n\n", (int)pid,
data.rem_dest->lid, data.rem_dest->qpn, data.rem_dest->psn,
data.rem_dest->rkey, data.rem_dest->vaddr);
diff -r 8cb431a3e51b read_bw.c
--- a/read_bw.c Tue Feb 23 22:34:35 2016 -0800
+++ b/read_bw.c Tue Feb 23 22:34:53 2016 -0800
@@ -44,6 +44,7 @@
// #include <limits.h>
#include <malloc.h>
// #include <getopt.h>
+#include <inttypes.h>
#include <time.h>
#include <infiniband/verbs.h>
@@ -336,7 +337,11 @@
}
}
+#if !(defined(__sparc))
cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f) * 1000000;
+#else
+ cycles_to_units = 1000000000;
+#endif
tsize = user_param->duplex ? 2 : 1;
tsize = tsize * user_param->size;
@@ -443,6 +448,7 @@
******************************************************************************/
int main(int argc, char *argv[]) {
+ int ret = 0;
int i = 0;
struct ibv_device *ib_dev = NULL;
struct pingpong_context *ctx;
@@ -553,8 +559,10 @@
for (i = 1; i < 24 ; ++i) {
user_param.size = 1 << i;
- if(run_iter(ctx,&user_param,&rem_dest))
- return 17;
+ if(run_iter(ctx,&user_param,&rem_dest)) {
+ ret = 17;
+ goto exit;
+ }
print_report(&user_param);
}
@@ -562,11 +570,13 @@
else {
- if(run_iter(ctx,&user_param,&rem_dest))
- return 17;
-
+ if(run_iter(ctx,&user_param,&rem_dest)) {
+ ret = 17;
+ goto exit;
+ }
print_report(&user_param);
}
+exit:
if (ctx_close_connection(&user_param,&my_dest,&rem_dest)) {
fprintf(stderr,"Failed to close connection between server and client\n");
@@ -575,6 +585,9 @@
printf(RESULT_LINE);
- return destroy_ctx_resources(ctx);
+ if (destroy_ctx_resources(ctx))
+ return 1;
+ else
+ return ret;
}
diff -r 8cb431a3e51b read_lat.c
--- a/read_lat.c Tue Feb 23 22:34:35 2016 -0800
+++ b/read_lat.c Tue Feb 23 22:34:53 2016 -0800
@@ -46,6 +46,7 @@
#include <malloc.h>
#include <getopt.h>
#include <time.h>
+#include <inttypes.h>
#include <infiniband/verbs.h>
#include "get_clock.h"
@@ -358,10 +359,19 @@
if (user_param->r_flag->cycles) {
+#if !(defined(__sparc))
cycles_to_units = 1;
+#else
+ cycles_to_units =
+ (1/get_cpu_mhz(user_param->cpu_freq_f)) * 1000;
+#endif
units = "cycles";
} else {
+#if !(defined(__sparc))
cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f);
+#else
+ cycles_to_units = 1000;
+#endif
units = "usec";
}
diff -r 8cb431a3e51b send_lat.c
--- a/send_lat.c Tue Feb 23 22:34:35 2016 -0800
+++ b/send_lat.c Tue Feb 23 22:34:53 2016 -0800
@@ -61,7 +61,8 @@
struct ibv_sge *sge_list;
struct ibv_recv_wr *rwr;
struct ibv_context *context;
- struct ibv_comp_channel *channel;
+ struct ibv_comp_channel *rx_channel;
+ struct ibv_comp_channel *tx_channel;
struct ibv_pd *pd;
struct ibv_mr *mr;
struct ibv_cq *rcq;
@@ -259,9 +260,16 @@
test_result = 1;
}
- if (ctx->channel) {
- if (ibv_destroy_comp_channel(ctx->channel)) {
- fprintf(stderr, "failed to destroy channel \n");
+ if (ctx->rx_channel) {
+ if (ibv_destroy_comp_channel(ctx->rx_channel)) {
+ fprintf(stderr, "failed to destroy rx_channel \n");
+ test_result = 1;
+ }
+ }
+
+ if (ctx->tx_channel) {
+ if (ibv_destroy_comp_channel(ctx->tx_channel)) {
+ fprintf(stderr, "failed to destroy tx_channel \n");
test_result = 1;
}
}
@@ -328,13 +336,20 @@
memset(ctx->buf, 0,buff_size);
if (user_parm->use_event) {
- ctx->channel = ibv_create_comp_channel(ctx->context);
- if (!ctx->channel) {
- fprintf(stderr, "Couldn't create completion channel\n");
+ ctx->rx_channel = ibv_create_comp_channel(ctx->context);
+ if (!ctx->rx_channel) {
+ fprintf(stderr, "Couldn't create completion rx_channel\n");
return NULL;
}
- } else
- ctx->channel = NULL;
+ ctx->tx_channel = ibv_create_comp_channel(ctx->context);
+ if (!ctx->rx_channel) {
+ fprintf(stderr, "Couldn't create completion tx_channel\n");
+ return NULL;
+ }
+ } else {
+ ctx->rx_channel = NULL;
+ ctx->tx_channel = NULL;
+ }
ctx->pd = ibv_alloc_pd(ctx->context);
if (!ctx->pd) {
@@ -348,13 +363,13 @@
return NULL;
}
- ctx->scq = ibv_create_cq(ctx->context,user_parm->tx_depth,NULL,ctx->channel,0);
+ ctx->scq = ibv_create_cq(ctx->context,user_parm->tx_depth,NULL,ctx->tx_channel,0);
if (!ctx->scq) {
fprintf(stderr, "Couldn't create CQ\n");
return NULL;
}
- ctx->rcq = ibv_create_cq(ctx->context,user_parm->rx_depth*user_parm->num_of_qps,NULL,ctx->channel,0);
+ ctx->rcq = ibv_create_cq(ctx->context,user_parm->rx_depth*user_parm->num_of_qps,NULL,ctx->rx_channel,0);
if (!ctx->rcq) {
fprintf(stderr, "Couldn't create CQ\n");
return NULL;
@@ -581,12 +596,20 @@
for (i = 0; i < user_param->iters - 1; ++i)
delta[i] = tstamp[i + 1] - tstamp[i];
-
if (user_param->r_flag->cycles) {
+#if !(defined(__sparc))
cycles_to_units = 1;
+#else
+ cycles_to_units =
+ (1/get_cpu_mhz(user_param->cpu_freq_f)) * 1000;
+#endif
units = "cycles";
} else {
+#if !(defined(__sparc))
cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f);
+#else
+ cycles_to_units = 1000;
+#endif
units = "usec";
}
@@ -649,7 +672,7 @@
// Server is polling on recieve first .
if (user_param->use_event) {
- if (ctx_notify_events(ctx->rcq,ctx->channel)) {
+ if (ctx_notify_events(ctx->rcq, ctx->rx_channel)) {
fprintf(stderr , " Failed to notify events to CQ");
return 1;
}
@@ -701,7 +724,7 @@
int s_ne;
if (user_param->use_event) {
- if (ctx_notify_events(ctx->scq,ctx->channel)) {
+ if (ctx_notify_events(ctx->scq, ctx->tx_channel)) {
fprintf(stderr , " Failed to notify events to CQ");
return 1;
}
diff -r 8cb431a3e51b write_bw.c
--- a/write_bw.c Tue Feb 23 22:34:35 2016 -0800
+++ b/write_bw.c Tue Feb 23 22:34:53 2016 -0800
@@ -45,6 +45,7 @@
#include <limits.h>
#include <malloc.h>
#include <getopt.h>
+#include <inttypes.h>
#include <time.h>
#include <infiniband/verbs.h>
@@ -224,9 +225,6 @@
return NULL;
}
- if (is_dev_hermon(ctx->context) != NOT_HERMON && user_parm->inline_size != 0)
- user_parm->inline_size = 0;
-
printf(" Inline data is used up to %d bytes message\n", user_parm->inline_size);
ctx->pd = ibv_alloc_pd(ctx->context);
@@ -368,7 +366,6 @@
cycles_t t;
int iters = user_param->iters;
-
opt_delta = tcompleted[opt_posted] - tposted[opt_completed];
if (user_param->noPeak == OFF) {
@@ -384,7 +381,11 @@
}
}
+#if !(defined(__sparc))
cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f) * 1000000;
+#else
+ cycles_to_units = 1000000000;
+#endif
tsize = user_param->duplex ? 2 : 1;
tsize = tsize * user_param->size;
diff -r 8cb431a3e51b write_bw_postlist.c
--- a/write_bw_postlist.c Tue Feb 23 22:34:35 2016 -0800
+++ b/write_bw_postlist.c Tue Feb 23 22:34:53 2016 -0800
@@ -46,6 +46,7 @@
#include <malloc.h>
#include <getopt.h>
#include <time.h>
+#include <inttypes.h>
#include <infiniband/verbs.h>
#include "get_clock.h"
@@ -323,7 +324,11 @@
}
}
+#if !(defined(__SVR4) && defined(__sun))
cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f) * 1000000;
+#else
+ cycles_to_units = 1000000000;
+#endif
tsize = user_param->duplex ? 2 : 1;
tsize = tsize * user_param->size;
diff -r 8cb431a3e51b write_lat.c
--- a/write_lat.c Tue Feb 23 22:34:35 2016 -0800
+++ b/write_lat.c Tue Feb 23 22:34:53 2016 -0800
@@ -46,6 +46,7 @@
#include <malloc.h>
#include <getopt.h>
#include <time.h>
+#include <inttypes.h>
#include <infiniband/verbs.h>
#include "get_clock.h"
@@ -330,10 +331,19 @@
if (user_param->r_flag->cycles) {
+#if !(defined(__sparc))
cycles_to_units = 1;
+#else
+ cycles_to_units =
+ (1/get_cpu_mhz(user_param->cpu_freq_f)) * 1000;
+#endif
units = "cycles";
} else {
+#if !(defined(__sparc))
cycles_to_units = get_cpu_mhz(user_param->cpu_freq_f);
+#else
+ cycles_to_units = 1000;
+#endif
units = "usec";
}