Skip to content

Commit

Permalink
Example 1: minor tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
Jiachen Xue committed Mar 27, 2017
1 parent 65893ec commit e1570c6
Show file tree
Hide file tree
Showing 7 changed files with 43 additions and 22 deletions.
4 changes: 4 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,11 @@
*.i*86
*.x86_64
*.hex
rdma-tutorial

# Debug files
*.dSYM/
*.su

# Output files
*.log
20 changes: 19 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1 +1,19 @@
# RDMA-Tutorial
# RDMA-Tutorial
This project presents an example based tutorial on RDMA based programming. A more detailed
discussion can be found in the Wiki page.

## Hardware and software discussion
* Mellanox HCAs
* GNU make
* gcc-4.4
* Mellanox OFED 3.3

## How the build project
Simply use ```make``` to build the release version or ```make debug``` to build the
debug version.

## Code structure

## Contact

Jiachen Xue ([email protected])
10 changes: 4 additions & 6 deletions client.c
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ void *client_thread_func (void *arg)
ret = post_recv (msg_size, lkey, (uint64_t)buf_ptr, qp, buf_ptr);
check (ret == 0, "thread[%ld]: failed to post recv", thread_id);
buf_offset = (buf_offset + msg_size) % buf_size;
buf_ptr += buf_offset;
buf_ptr = ib_res.ib_buf + buf_offset;
}

/* wait for start signal */
Expand All @@ -69,7 +69,7 @@ void *client_thread_func (void *arg)
/* post a receive */
post_recv (msg_size, lkey, (uint64_t)buf_ptr, qp, buf_ptr);
buf_offset = (buf_offset + msg_size) % buf_size;
buf_ptr += buf_offset;
buf_ptr = ib_res.ib_buf + buf_offset;

if (ntohl(wc[i].imm_data) == MSG_CTL_START) {
start_sending = true;
Expand All @@ -86,7 +86,7 @@ void *client_thread_func (void *arg)
ret = post_send (msg_size, lkey, 0, MSG_REGULAR, qp, buf_ptr);
check (ret == 0, "thread[%ld]: failed to post send", thread_id);
buf_offset = (buf_offset + msg_size) % buf_size;
buf_ptr += buf_offset;
buf_ptr = ib_res.ib_buf + buf_offset;
}


Expand Down Expand Up @@ -127,9 +127,7 @@ void *client_thread_func (void *arg)
post_send (msg_size, lkey, 0, MSG_REGULAR, qp, msg_ptr);

/* post a new receive */
post_recv (msg_size, lkey, (uint64_t)buf_ptr, qp, buf_ptr);
buf_offset = (buf_offset + msg_size) % buf_size;
buf_ptr += buf_offset;
post_recv (msg_size, lkey, wc[i].wr_id, qp, msg_ptr);
}
} /* loop through all wc */
}
Expand Down
2 changes: 1 addition & 1 deletion ib.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#define IB_SL 0
#define IB_WR_ID_STOP 0xE000000000000000
#define NUM_WARMING_UP_OPS 500000
#define TOT_NUM_OPS 5000000
#define TOT_NUM_OPS 10000000

#if __BYTE_ORDER == __LITTLE_ENDIAN
static inline uint64_t htonll (uint64_t x) {return bswap_64(x); }
Expand Down
25 changes: 13 additions & 12 deletions main.c
Original file line number Diff line number Diff line change
Expand Up @@ -16,22 +16,23 @@ int main (int argc, char *argv[])
{
int ret = 0;

if (argc == 3) {
config_info.is_server = false;
config_info.server_name = argv[1];
config_info.sock_port = argv[2];
} else if (argc == 2) {
config_info.is_server = true;
config_info.sock_port = argv[1];
if (argc == 5) {
config_info.is_server = false;
config_info.server_name = argv[1];
config_info.msg_size = atoi (argv[2]);
config_info.num_concurr_msgs = atoi (argv[3]);
config_info.sock_port = argv[4];
} else if (argc == 4) {
config_info.is_server = true;
config_info.msg_size = atoi (argv[1]);
config_info.num_concurr_msgs = atoi (argv[2]);
config_info.sock_port = argv[3];
} else {
printf ("Server: %s sock_port\n", argv[0]);
printf ("Client: %s server_name sock_port\n", argv[0]);
printf ("Server: %s msg_size num_concurr_msgs sock_port\n", argv[0]);
printf ("Client: %s server_name msg_size num_concurr_msgs sock_port\n", argv[0]);
return 0;
}

config_info.msg_size = 64;
config_info.num_concurr_msgs = 1;

ret = init_env ();
check (ret == 0, "Failed to init env");

Expand Down
2 changes: 1 addition & 1 deletion server.c
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ void *server_thread (void *arg)
ret = post_recv (msg_size, lkey, (uint64_t)buf_ptr, qp, buf_ptr);
check (ret == 0, "thread[%ld]: failed to post recv", thread_id);
buf_offset = (buf_offset + msg_size) % buf_size;
buf_ptr += buf_offset;
buf_ptr = ib_res.ib_buf + buf_offset;
}

/* signal the client to start */
Expand Down
2 changes: 1 addition & 1 deletion setup_ib.c
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ void close_ib_connection ()
if (ib_res.qp != NULL) {
ibv_destroy_qp (ib_res.qp);
}

if (ib_res.cq != NULL) {
ibv_destroy_cq (ib_res.cq);
}
Expand Down

0 comments on commit e1570c6

Please sign in to comment.