UCX++
endpoint.h
1#pragma once
2
3#include <coroutine>
4#include <cstdint>
5#include <memory>
6#include <ucs/type/status.h>
7#include <vector>
8
9#include <ucp/api/ucp.h>
10
11#include "ucxpp/address.h"
12#include "ucxpp/awaitable.h"
13#include "ucxpp/error.h"
14#include "ucxpp/memory.h"
15#include "ucxpp/task.h"
16#include "ucxpp/worker.h"
17
18#include "ucxpp/detail/noncopyable.h"
19
20namespace ucxpp {
21
26class endpoint : public noncopyable,
27 public std::enable_shared_from_this<endpoint> {
28 friend class worker;
29 friend class local_memory_handle;
30 friend class remote_memory_handle;
31 friend class ep_close_awaitable;
32 std::shared_ptr<worker> worker_;
33 ucp_ep_h ep_;
34 void *close_request_;
35 remote_address peer_;
36
37public:
44 endpoint(std::shared_ptr<worker> worker, remote_address const &peer);
45
53 static void error_cb(void *ep, ucp_ep_h ep_h, ucs_status_t status);
54
60 std::shared_ptr<worker> worker_ptr() const;
61
66 void print() const;
67
73 ucp_ep_h handle() const;
74
80 const remote_address &get_address() const;
81
89 stream_send_awaitable stream_send(void const *buffer, size_t length) const;
90
99 stream_recv_awaitable stream_recv(void *buffer, size_t length) const;
100
109 tag_send_awaitable tag_send(void const *buffer, size_t length,
110 ucp_tag_t tag) const;
111
118
126
134 static void close_cb(void *request, ucs_status_t status, void *user_data);
135
141 ~endpoint();
142};
143
144} // namespace ucxpp
145
Abstraction for a UCX endpoint.
Definition: endpoint.h:27
void print() const
Print the endpoint's information.
Definition: endpoint.cc:55
static void error_cb(void *ep, ucp_ep_h ep_h, ucs_status_t status)
Error handler for all endpoints.
Definition: endpoint.cc:20
endpoint(std::shared_ptr< worker > worker, remote_address const &peer)
Construct a new endpoint object.
Definition: endpoint.cc:41
~endpoint()
Destroy the endpoint object. If the endpoint is not closed yet, it will be closed.
Definition: endpoint.cc:91
stream_recv_awaitable stream_recv(void *buffer, size_t length) const
Stream receive to the buffer.
Definition: endpoint.cc:66
std::shared_ptr< worker > worker_ptr() const
Get the worker object.
Definition: endpoint.cc:53
const remote_address & get_address() const
Get the endpoint's remote address.
Definition: endpoint.cc:59
task< void > close()
Close the endpoint. You should not use the endpoint after calling this function.
Definition: endpoint.cc:79
tag_send_awaitable tag_send(void const *buffer, size_t length, ucp_tag_t tag) const
Tag send the buffer.
Definition: endpoint.cc:70
static void close_cb(void *request, ucs_status_t status, void *user_data)
Endpoint close callback.
Definition: endpoint.cc:85
ep_flush_awaitable flush() const
Flush the endpoint.
Definition: endpoint.cc:75
ucp_ep_h handle() const
Get the endpoint's native UCX handle.
Definition: endpoint.cc:57
stream_send_awaitable stream_send(void const *buffer, size_t length) const
Stream send the buffer.
Definition: endpoint.cc:61
Definition: awaitable.h:198
Definition: awaitable.h:189
Represents a registered local memory region.
Definition: memory.h:37
Definition: noncopyable.h:5
Represents a remote UCX address.
Definition: address.h:83
Represents a remote memory region. Note that this does not contain the remote address....
Definition: memory.h:98
Definition: awaitable.h:219
Definition: awaitable.h:70
Definition: awaitable.h:87
Abstraction for a UCX worker.
Definition: worker.h:20
Definition: task.h:53