All Projects → wxdwfc → rlib

wxdwfc / rlib

Licence: other
RLib is a header-only library for easier usage of RDMA.

Programming Languages

C++
36643 projects - #6 most used programming language
c
50402 projects - #5 most used programming language
Makefile
30231 projects
CMake
9771 projects

Labels

Projects that are alternatives of or similar to rlib

scst
No description or website provided.
Stars: ✭ 61 (+258.82%)
Mutual labels:  rdma
sparkucx
A high-performance, scalable and efficient ShuffleManager plugin for Apache Spark, utilizing UCX communication layer
Stars: ✭ 32 (+88.24%)
Mutual labels:  rdma
BigComputeLabs
Big Compute Learning Labs
Stars: ✭ 19 (+11.76%)
Mutual labels:  rdma
darpc
DaRPC: Data Center Remote Procedure Call
Stars: ✭ 49 (+188.24%)
Mutual labels:  rdma
k8s-rdma-sriov-dev-plugin
Kubernetes Rdma SRIOV device plugin
Stars: ✭ 92 (+441.18%)
Mutual labels:  rdma
pDPM
Passive Disaggregated Persistent Memory at USENIX ATC 2020.
Stars: ✭ 38 (+123.53%)
Mutual labels:  rdma
ksmbd
ksmbd kernel server(SMB/CIFS server)
Stars: ✭ 181 (+964.71%)
Mutual labels:  rdma
Coyote
Framework providing operating system abstractions and a range of shared networking (RDMA, TCP/IP) and memory services to common modern heterogeneous platforms.
Stars: ✭ 80 (+370.59%)
Mutual labels:  rdma
Validate-DCB
Validator for RDMA Configuration and Best Practices
Stars: ✭ 34 (+100%)
Mutual labels:  rdma
blog
blog entries
Stars: ✭ 39 (+129.41%)
Mutual labels:  rdma
Spark-PMoF
Spark Shuffle Optimization with RDMA+AEP
Stars: ✭ 28 (+64.71%)
Mutual labels:  rdma
ksmbd
ksmbd kernel server(SMB/CIFS server)
Stars: ✭ 98 (+476.47%)
Mutual labels:  rdma

RLib

Notice

The latest version has been transferred to https://github.com/wxdwfc/rlibv2, which is now actively maintained.

Intro

RLib is a header-only library for easier use of RDMA using C++. Basically it is a set of wrappers of the interfaces of libibverbs, yet it additionally handles many tedius things, such as establishing connections between RDMA QPs, and simplifies many configurations.


To use

#include "rdma_ctrl.hpp" is all you need.


Example

Usually very few lines of code are needed to use RDMA with RLib. Below is a snippet of using RLib to implement a simple pingpong application using one-sided RDMA primitive.

Server side

/**
 * Note, RDMA usually uses some other communication method (e.g. TCP/IP) to exchange QP informations.
 * RLib uses TCP for the pre-communication.
 */
int server_node_id = 1;
int tcp_port       = 8888;
int client_port    = 8000;

using namespace rdmaio;

RdmaCtrl *c = new RdmaCtrl(server_node_id,tcp_port);
RdmaCtrl::DevIdx idx {.dev_id = 0,.port_id = 1 }; // using the first RNIC's first port
c->open_thread_local_device(idx);

// register a buffer to the previous opened device, using id = 73
char *buffer = (char *)malloc(4096);
memset(buffer, 0, 4096);
RDMA_ASSERT(c->register_memory(73,buffer,4096,c->get_device()) == true);

char s[] = "hello world";
memcpy(buffer, s, strlen(s));

RCQP *qp = c->create_rc_qp(create_rc_idx(1,0),c->get_device(),c->get_local_mr(73));

// server also needs to "connect" clinet.
while(qp->connect(client_ip,client_port) != SUCC)  {
    usleep(2000);
}

while(true) {
    // This is RDMA, server does not need to do anything :)
    sleep(1);
}

Client side

int client_node_id = 0;
int tcp_port       = 8000;
int server_port    = 8888;

using namespace rdmaio;

RdmaCtrl *c = new RdmaCtrl(client_node_id,tcp_port);
RdmaCtrl::DevIdx idx {.dev_id = 0,.port_id = 1 }; // using the first RNIC's first port
c->open_thread_local_device(idx);

// register a buffer to the previous opened device, using id = 73
char *buffer = (char *)malloc(4096);
RDMA_ASSERT(c->register_memory(73,buffer,4096,c->get_device()) == true);

// get remote server's memory information
MemoryAttr mr;
while(QP::get_remote_mr(server_ip,server_port,73,&mr) != SUCC) {
    usleep(2000);
}

// create the RC qp to access remote server's memory, using the previous registered memory
RCQP *qp = c->create_rc_qp(create_rc_idx(1,0),c->get_device(),c->get_local_mr(73));
qp->bind_remote_mr(mr); // bind to the previous allocated mr

while(qp->connect(server_ip,server_port) != SUCC)  {
    usleep(2000);
}

// main pingpong loop

ibv_wc wc;
while(true) {
    char *local_buf  = buffer;
    uint64_t address = 0;
    int msg_len = 11;   // length of "hello world"
    // read an uint64_t from the server
    auto rc = qp->post_send(IBV_WR_RDMA_READ,local_buf,msg_len,address,IBV_SEND_SIGNALED);
    qp->poll_till_completion();
    // then get the results, stored in the local_buffer
}

Acknowledgments

TODO

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].