UCX++
worker.h
1#pragma once
2
3#include <functional>
4#include <memory>
5#include <ucs/type/status.h>
6#include <unordered_map>
7
8#include <ucp/api/ucp.h>
9
10#include "ucxpp/address.h"
11#include "ucxpp/awaitable.h"
12#include "ucxpp/context.h"
13
14namespace ucxpp {
15
20class worker : public std::enable_shared_from_this<worker> {
21 friend class local_address;
22 friend class endpoint;
23 ucp_worker_h worker_;
24 std::shared_ptr<context> ctx_;
25 int event_fd_;
26
27public:
33 worker(std::shared_ptr<context> ctx);
34
41 int event_fd() const;
42
48 std::shared_ptr<context> context_ptr() const;
49
56
62 ucp_worker_h handle() const;
63
70 bool progress() const;
71
77 void wait() const;
78
86 bool arm() const;
87
98 tag_recv_awaitable tag_recv(void *buffer, size_t length, ucp_tag_t tag,
99 ucp_tag_t tag_mask = 0xFFFFFFFFFFFFFFFF) const;
100
106 void fence();
107
115
116 ~worker();
117};
118
119} // namespace ucxpp
Abstraction for a UCX endpoint.
Definition: endpoint.h:27
Represents a local UCX address.
Definition: address.h:19
Definition: awaitable.h:283
Definition: awaitable.h:208
Abstraction for a UCX worker.
Definition: worker.h:20
tag_recv_awaitable tag_recv(void *buffer, size_t length, ucp_tag_t tag, ucp_tag_t tag_mask=0xFFFFFFFFFFFFFFFF) const
Tag receive to the buffer.
Definition: worker.cc:66
std::shared_ptr< context > context_ptr() const
Get the worker's context object.
Definition: worker.cc:39
bool progress() const
Progress the worker.
Definition: worker.cc:51
void fence()
Fence the worker. Operations issued on the worker before the fence are ensured to complete before ope...
Definition: worker.cc:71
bool arm() const
Arm the worker for next event notification.
Definition: worker.cc:57
worker(std::shared_ptr< context > ctx)
Construct a new worker object.
Definition: worker.cc:22
local_address get_address() const
Get the worker's UCX address.
Definition: worker.cc:41
worker_flush_awaitable flush()
Flush the worker.
Definition: worker.cc:75
void wait() const
Wait for an event on the worker. It should be called only after a call to progress() returns false.
Definition: worker.cc:53
ucp_worker_h handle() const
Get the worker's native UCX handle.
Definition: worker.cc:49
int event_fd() const
Get the event fd for the worker. The wakeup feature must be enabled for this to work.
Definition: worker.cc:34