[openib-general] [PATCH] allow buffers > 1GB in rdma_bw

Justin Banks jbanks at lnxi.com
Fri Aug 19 13:35:00 PDT 2005


- Allow use of buffers > 1GB in rdma_bw
- Minor cosmetic fixes I couldn't resist, mostly line widths

Sorry if my email client wraps long lines - I've been shoehorned into
using evolution, and still haven't figured out how to make it do what I
want it to do.

Index: rdma_bw.c
===================================================================
--- rdma_bw.c	(revision 3137)
+++ rdma_bw.c	(working copy)
@@ -108,7 +108,8 @@
 	n = getaddrinfo(servername, service, &hints, &res);
 
 	if (n < 0) {
-		fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), servername, port);
+		fprintf(stderr, "%s for %s:%d\n", gai_strerror(n), 
+				servername, port);
 		return n;
 	}
 
@@ -125,7 +126,8 @@
 	freeaddrinfo(res);
 
 	if (sockfd < 0) {
-		fprintf(stderr, "Couldn't connect to %s:%d\n", servername, port);
+		fprintf(stderr, "Couldn't connect to %s:%d\n", 
+				servername, port);
 		return sockfd;
 	}
 	return sockfd;
@@ -195,7 +197,8 @@
 		if (sockfd >= 0) {
 			n = 1;
 
-			setsockopt(sockfd, SOL_SOCKET, SO_REUSEADDR, &n, sizeof n);
+			setsockopt(sockfd, SOL_SOCKET, 
+			           SO_REUSEADDR, &n, sizeof n);
 
 			if (!bind(sockfd, t->ai_addr, t->ai_addrlen))
 				break;
@@ -224,7 +227,8 @@
 	return connfd;
 }
 
-static struct pingpong_dest *pp_server_exch_dest(int connfd, const
struct pingpong_dest *my_dest)
+static struct pingpong_dest*
+pp_server_exch_dest(int connfd, const struct pingpong_dest *my_dest)
 {
 	char msg[sizeof "0000:000000:000000:00000000:0000000000000000"];
 	struct pingpong_dest *rem_dest = NULL;
@@ -234,7 +238,8 @@
 	n = read(connfd, msg, sizeof msg);
 	if (n != sizeof msg) {
 		perror("server read");
-		fprintf(stderr, "%d/%d: Couldn't read remote address\n", n, (int)
sizeof msg);
+		fprintf(stderr, "%d/%d: Couldn't read remote address\n", 
+		        n, (int) sizeof msg);
 		goto out;
 	}
 
@@ -265,7 +270,8 @@
 	return rem_dest;
 }
 
-static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev,
int size,
+static struct pingpong_context *pp_init_ctx(struct ibv_device *ib_dev, 
+                                            unsigned long size,
 					    int tx_depth, int port)
 {
 	struct pingpong_context *ctx;
@@ -407,20 +413,27 @@
 static void usage(const char *argv0)
 {
 	printf("Usage:\n");
-	printf("  %s            start a server and wait for connection\n",
argv0);
+	printf("  %s            start a server and wait for connection\n", 
+	       argv0);
 	printf("  %s <host>     connect to server at <host>\n", argv0);
 	printf("\n");
 	printf("Options:\n");
-	printf("  -p, --port=<port>      listen on/connect to port <port>
(default 18515)\n");
-	printf("  -d, --ib-dev=<dev>     use IB device <dev> (default first
device found)\n");
-	printf("  -i, --ib-port=<port>   use port <port> of IB device (default
1)\n");
-	printf("  -s, --size=<size>      size of message to exchange (default
4096)\n");
+	printf("  -p, --port=<port>      listen on/connect to port "
+	       "<port> (default 18515)\n");
+	printf("  -d, --ib-dev=<dev>     use IB device <dev> (default "
+	       "first device found)\n");
+	printf("  -i, --ib-port=<port>   use port <port> of IB device "
+	       "(default 1)\n");
+	printf("  -s, --size=<size>      size of message to exchange "
+	       "(default 4096)\n");
 	printf("  -t, --tx-depth=<dep>   size of tx queue (default 100)\n");
-	printf("  -n, --iters=<iters>    number of exchanges (at least 2,
default 1000)\n");
-	printf("  -b, --bidirectional    measure bidirectional bandwidth
(default unidirectional)\n");
+	printf("  -n, --iters=<iters>    number of exchanges "
+	       "(at least 2, default 1000)\n");
+	printf("  -b, --bidirectional    measure bidirectional bandwidth "
+	       "(default unidirectional)\n");
 }
 
-static void print_report(unsigned int iters, int size, int duplex,
+static void print_report(unsigned int iters, unsigned long size, int
duplex,
 			 cycles_t *tposted, cycles_t *tcompleted)
 {
 	double cycles_to_units;
@@ -453,7 +466,8 @@
 			 opt_posted, opt_completed,
 			 tsize * cycles_to_units / opt_delta / 1024);
 	printf("Bandwidth average: %g MB/sec\n",
-			 tsize * iters * cycles_to_units / (tcompleted[iters - 1] -
tposted[0]) / 1024);
+			 tsize * iters * cycles_to_units / 
+			 (tcompleted[iters-1] - tposted[0]) / 1024);
 
 	printf("Service Demand peak (#%d to #%d): %ld cycles/KB\n",
 			 opt_posted, opt_completed, opt_delta/tsize);
@@ -473,7 +487,7 @@
 	char                    *servername = NULL;
 	int                      port = 18515;
 	int                      ib_port = 1;
-	int                      size = 4096;
+	unsigned long            size = 4096;
 	int                      tx_depth = 100;
 	int                      iters = 1000;
 	int                      scnt, ccnt;
@@ -525,7 +539,7 @@
 			break;
 
 		case 's':
-			size = strtol(optarg, NULL, 0);
+			size = strtoul(optarg, NULL, 0);
 			if (size < 1) { usage(argv[0]); return 1; }
 			break;
 

-justinb





More information about the general mailing list