Derecho  0.9
Distributed systems toolkit for RDMA
verbs.hpp
Go to the documentation of this file.
1 #ifndef VERBS_HPP
2 #define VERBS_HPP
3 
10 #include <map>
11 
12 #include <infiniband/verbs.h>
13 
14 namespace sst {
15 
17 struct cm_con_data_t {
19  uint64_t addr;
21  uint32_t rkey;
23  uint32_t qp_num;
25  uint16_t lid;
27  uint8_t gid[16];
28 } __attribute__((packed));
29 
31  uint32_t remote_id; // id of the remote node
32  uint32_t ce_idx; // index into the completion entry list
33 };
34 
39 class _resources {
40 private:
42  void set_qp_initialized();
44  void set_qp_ready_to_receive();
46  void set_qp_ready_to_send();
48  void connect_qp();
49 
50 protected:
52  int post_remote_send(const uint32_t id, const long long int offset, const long long int size, const int op, const bool completion);
53 
54 public:
58  struct ibv_qp *qp;
60  struct ibv_mr *write_mr;
62  struct ibv_mr *read_mr;
64  struct cm_con_data_t remote_props;
66  char *write_buf;
69  char *read_buf;
70 
73  _resources(int r_index, char *write_addr, char *read_addr, int size_w,
74  int size_r);
76  virtual ~_resources();
77 };
78 
79 class resources : public _resources {
80 public:
81  resources(int r_index, char *write_addr, char *read_addr, int size_w,
82  int size_r);
83  /*
84  wrapper functions that make up the user interface
85  all call post_remote_send with different parameters
86  */
88  void post_remote_read(const uint32_t id, const long long int size);
90  void post_remote_read(const uint32_t id, const long long int offset, const long long int size);
92  void post_remote_write(const uint32_t id, const long long int size);
94  void post_remote_write(const uint32_t id, const long long int offset, long long int size);
95  void post_remote_write_with_completion(const uint32_t id, const long long int size);
97  void post_remote_write_with_completion(const uint32_t id, const long long int offset, const long long int size);
98 };
99 
100 class resources_two_sided : public _resources {
101  int post_receive(const uint32_t id, const long long int offset, const long long int size);
102 
103 public:
104  resources_two_sided(int r_index, char *write_addr, char *read_addr, int size_w,
105  int size_r);
106  void post_two_sided_send(const uint32_t id, const long long int size);
108  void post_two_sided_send(const uint32_t id, const long long int offset, long long int size);
109  void post_two_sided_send_with_completion(const uint32_t id, const long long int size);
111  void post_two_sided_send_with_completion(const uint32_t id, const long long int offset, const long long int size);
112  void post_two_sided_receive(const uint32_t id, const long long int size);
113  void post_two_sided_receive(const uint32_t id, const long long int offset, const long long int size);
114 };
115 
116 bool add_node(uint32_t new_id, const std::string new_ip_addr);
117 bool remove_node(uint32_t node_id);
123 bool sync(uint32_t r_index);
125 void verbs_initialize(const std::map<uint32_t, std::string> &ip_addrs,
126  uint32_t node_rank);
128 std::pair<uint32_t, std::pair<int, int>> verbs_poll_completion();
131 void verbs_destroy();
132 
133 } // namespace sst
134 
135 #endif // VERBS_HPP
struct ibv_mr * read_mr
Memory Region handle for the read buffer.
Definition: verbs.hpp:62
uint32_t qp_num
Queue Pair number.
Definition: verbs.hpp:23
bool add_node(uint32_t new_id, const std::pair< ip_addr_t, uint16_t > &new_ip_addr_and_port)
Adds a new node to the SST TPC connections set.
Definition: lf.cpp:557
void shutdown_polling_thread()
Shutdown the polling thread.
Definition: lf.cpp:743
A public-facing version of the internal _resources class that extends it with more convenient functio...
Definition: lf.hpp:115
std::pair< uint32_t, std::pair< int, int > > verbs_poll_completion()
Polls for completion of a single posted remote write.
Definition: verbs.cpp:515
bool remove_node(uint32_t node_id)
Removes a node from the SST TCP connections set.
Definition: lf.cpp:561
uint32_t rkey
Remote key.
Definition: verbs.hpp:21
uint32_t node_rank
Definition: experiment.cpp:45
int remote_index
Index of the remote node.
Definition: verbs.hpp:56
void verbs_initialize(const std::map< uint32_t, std::string > &ip_addrs, uint32_t node_rank)
Initializes the global verbs resources.
bool sync(uint32_t r_id)
Blocks the current thread until both this node and a remote node reach this function, which exchanges some trivial data over a TCP connection.
Definition: lf.cpp:565
uint64_t addr
Buffer address.
Definition: verbs.hpp:19
struct ibv_mr * write_mr
Memory Region handle for the write buffer.
Definition: verbs.hpp:60
uint32_t remote_id
Definition: verbs.hpp:31
struct ibv_qp * qp
Handle for the IB Verbs Queue Pair object.
Definition: verbs.hpp:58
uint8_t gid[16]
GID.
Definition: verbs.hpp:27
void verbs_destroy()
Destroys the global verbs resources.
Definition: verbs.cpp:664
uint16_t lid
LID of the InfiniBand port.
Definition: verbs.hpp:25
A public-facing version of the internal _resources class that extends it with functions that support ...
Definition: lf.hpp:144
Represents the set of RDMA resources needed to maintain a two-way connection to a single remote node...
Definition: lf.hpp:31
Structure to exchange the data needed to connect the Queue Pairs.
Definition: verbs.hpp:17
struct sst::verbs_sender_ctxt __attribute__