Derecho  0.9
Distributed systems toolkit for RDMA
lf.hpp
Go to the documentation of this file.
1 #ifndef LF_HPP
2 #define LF_HPP
3 
10 #include <map>
11 #include <rdma/fabric.h>
12 #include <thread>
13 
15 
16 #ifndef LF_VERSION
17 #define LF_VERSION FI_VERSION(1, 5)
18 #endif
19 
20 namespace sst {
21 
23  uint32_t ce_idx; // index into the comepletion entry vector. - 0xFFFFFFFF for invalid
24  uint32_t remote_id; // thread id of the sender
25 };
26 
31 class _resources {
32 private:
39  void connect_endpoint(bool is_lf_server);
45  int init_endpoint(struct fi_info* fi);
46 
47 protected:
58  int post_remote_send(struct lf_sender_ctxt* ctxt, const long long int offset, const long long int size,
59  const int op, const bool completion);
60 
61 public:
63  int remote_id;
65  // struct fid_cq *txcq, *rxcq; - moved to g_ctxt
67  struct fid_ep* ep;
69  struct fid_mr* write_mr;
71  struct fid_mr* read_mr;
73  char* write_buf;
75  char* read_buf;
77  uint64_t mr_lrkey;
79  uint64_t mr_lwkey;
81  uint64_t mr_rwkey;
83  fi_addr_t remote_fi_addr;
85  struct fid_eq* eq;
86 
105  _resources(int r_id, char* write_addr, char* read_addr, int size_w,
106  int size_r, int is_lf_server);
108  virtual ~_resources();
109 };
110 
115 class resources : public _resources {
116 public:
118  resources(int r_id, char* write_addr, char* read_addr, int size_w,
119  int size_r, int is_lf_server) : _resources(r_id, write_addr, read_addr, size_w, size_r, is_lf_server) {
120  }
121 
122  /*
123  wrapper functions that make up the user interface
124  all call post_remote_send with different parameters
125  */
126 
128  void post_remote_read(const long long int size);
130  void post_remote_read(const long long int offset, const long long int size);
132  void post_remote_write(const long long int size);
134  void post_remote_write(const long long int offset, long long int size);
135  void post_remote_write_with_completion(struct lf_sender_ctxt* ctxt, const long long int size);
137  void post_remote_write_with_completion(struct lf_sender_ctxt* ctxt, const long long int offset, const long long int size);
138 };
139 
145  int post_receive(struct lf_sender_ctxt* ctxt, const long long int offset, const long long int size);
146 
147 public:
149  resources_two_sided(int r_id, char* write_addr, char* read_addr, int size_w,
150  int size_r, int is_lf_server) : _resources(r_id, write_addr, read_addr, size_w, size_r, is_lf_server) {
151  }
152 
153  void post_two_sided_send(const long long int size);
155  void post_two_sided_send(const long long int offset, long long int size);
156  void post_two_sided_send_with_completion(struct lf_sender_ctxt* ctxt, const long long int size);
158  void post_two_sided_send_with_completion(struct lf_sender_ctxt* ctxt, const long long int offset, const long long int size);
159  void post_two_sided_receive(struct lf_sender_ctxt* ctxt, const long long int size);
160  void post_two_sided_receive(struct lf_sender_ctxt* ctxt, const long long int offset, const long long int size);
161 };
162 
166 bool add_node(uint32_t new_id, const std::pair<ip_addr_t, uint16_t>& new_ip_addr_and_port);
170 bool remove_node(uint32_t node_id);
176 bool sync(uint32_t r_id);
184 void lf_initialize(const std::map<uint32_t, std::pair<ip_addr_t, uint16_t>>& ip_addrs_and_ports,
185  uint32_t node_rank);
187 std::pair<uint32_t, std::pair<int32_t, int32_t>> lf_poll_completion();
191 void lf_destroy();
192 } // namespace sst
193 
194 #endif // LF_HPP
uint32_t remote_id
Definition: lf.hpp:24
struct fid_mr * read_mr
memory region for remote writer
Definition: lf.hpp:71
uint32_t ce_idx
Definition: lf.hpp:23
struct fid_mr * write_mr
memory region for remote writer
Definition: lf.hpp:69
uint64_t mr_lrkey
key for local read buffer
Definition: lf.hpp:77
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
uint64_t mr_rwkey
key for remote write buffer
Definition: lf.hpp:81
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< int32_t, int32_t > > lf_poll_completion()
Polls for completion of a single posted remote write.
Definition: lf.cpp:610
bool remove_node(uint32_t node_id)
Removes a node from the SST TCP connections set.
Definition: lf.cpp:561
char * write_buf
Pointer to the memory buffer used for local writes.
Definition: lf.hpp:73
uint32_t node_rank
Definition: experiment.cpp:45
void lf_initialize(const std::map< uint32_t, std::pair< ip_addr_t, uint16_t >> &ip_addrs_and_ports, uint32_t node_rank)
Initializes the global libfabric resources.
Definition: lf.cpp:708
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 mr_lwkey
key for local write buffer
Definition: lf.hpp:79
struct fid_ep * ep
tx/rx completion queue
Definition: lf.hpp:67
struct fid_eq * eq
the event queue
Definition: lf.hpp:85
void lf_destroy()
Destroys the global libfabric resources.
Definition: lf.cpp:750
resources_two_sided(int r_id, char *write_addr, char *read_addr, int size_w, int size_r, int is_lf_server)
constructor: simply forwards to _resources::_resources
Definition: lf.hpp:149
A public-facing version of the internal _resources class that extends it with functions that support ...
Definition: lf.hpp:144
resources(int r_id, char *write_addr, char *read_addr, int size_w, int size_r, int is_lf_server)
Constructor: simply forwards to _resources::_resources.
Definition: lf.hpp:118
Represents the set of RDMA resources needed to maintain a two-way connection to a single remote node...
Definition: lf.hpp:31
fi_addr_t remote_fi_addr
remote write memory address
Definition: lf.hpp:83
char * read_buf
Pointer to the memory buffer used for the results of RDMA remote reads.
Definition: lf.hpp:75
int remote_id
ID of the remote node.
Definition: lf.hpp:63