Download RDMA Aware Networks Programming User Manual
Transcript
Rev 1.7
8.3
Programming Examples Using RDMA Verbs
Shared Received Queue (SRQ)
/*
* Compile Command:
* gcc srq.c -o srq -libverbs -lrdmacm
*
* Description:
* Both the client and server use an SRQ. A number of Queue Pairs (QPs) are
* created (ctx.qp_count) and each QP uses the SRQ. The connection between the
* client and server is established using the IP address details passed on the
* command line. After the connection is established, the client starts
* blasting sends to the server and stops when the maximum work requests
* (ctx.max_wr) have been sent. When the server has received all the sends, it
* performs a send to the client to tell it to continue. The process repeats
* until the number of requested number of sends (ctx.msg_count) have been
* performed.
*
* Running the Example:
* The executable can operate as either the client or server application. It
* can be demonstrated on a simple fabric of two nodes with the server
* application running on one node and the client application running on the
* other. Each node must be configured to support IPoIB and the IB interface
* (ex. ib0) must be assigned an IP Address. Finally, the fabric must be
* initialized using OpenSM.
*
* Server (-a is IP of local interface):
* ./srq -s -a 192.168.1.12
*
* Client (-a is IP of remote interface):
* ./srq -a 192.168.1.12
*
*/
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <errno.h>
#include <getopt.h>
#include <rdma/rdma_verbs.h>
#define VERB_ERR(verb, ret) \
fprintf(stderr, "%s returned %d errno %d\n", verb, ret, errno)
/* Default parameters values */
#define DEFAULT_PORT "51216"
#define DEFAULT_MSG_COUNT 100
#define DEFAULT_MSG_LENGTH 100000
#define DEFAULT_QP_COUNT 4
#define DEFAULT_MAX_WR 64
/* Resources used in the example */
struct context
{
/* User parameters */
186
Mellanox Technologies