tag_probe.h
1 
5 #pragma once
6 
7 #include <atomic>
8 #include <memory>
9 #include <optional>
10 
11 #include <ucp/api/ucp.h>
12 #include <ucxx/typedefs.h>
13 
14 namespace ucxx {
15 
16 // Forward declaration for friend access
17 class RequestTag;
18 
25 class TagRecvInfo {
26  public:
27  const Tag senderTag;
28  const size_t length;
29 
34 
41  explicit TagRecvInfo(const ucp_tag_recv_info_t& info);
42 };
43 
59 class TagProbeInfo {
60  public:
61  TagProbeInfo(const TagProbeInfo&) = delete;
62  TagProbeInfo& operator=(TagProbeInfo const&) = delete;
63  TagProbeInfo(TagProbeInfo&& o) = delete;
64  TagProbeInfo& operator=(TagProbeInfo&& o) = delete;
65 
66  ~TagProbeInfo();
67 
73  bool isMatched() const;
74 
81  const TagRecvInfo& getInfo() const;
82 
89  ucp_tag_message_h getHandle() const;
90 
101  ucp_tag_message_h releaseHandle() const;
102 
103  private:
104  const bool _matched{false};
105  const std::optional<TagRecvInfo> _info{
106  std::nullopt};
107  const ucp_tag_message_h _handle{
108  nullptr};
110  mutable std::atomic<bool> _consumed{false};
111 
118  void consume() const;
119 
133  TagProbeInfo() = default;
134 
152  TagProbeInfo(const ucp_tag_recv_info_t& info, ucp_tag_message_h handle);
153 
166  friend std::shared_ptr<TagProbeInfo> createTagProbeInfo();
167 
184  friend std::shared_ptr<TagProbeInfo> createTagProbeInfo(const ucp_tag_recv_info_t& info,
185  ucp_tag_message_h handle);
186 
187  // Allow RequestTag to consume the handle
188  friend class RequestTag;
189 };
190 
191 } // namespace ucxx
Send or receive a message with the UCX Tag API.
Definition: request_tag.h:24
Information about probed tag message.
Definition: tag_probe.h:59
ucp_tag_message_h releaseHandle() const
Release the message handle.
friend std::shared_ptr< TagProbeInfo > createTagProbeInfo()
Constructor for shared_ptr<ucxx::TagProbeInfo>.
friend std::shared_ptr< TagProbeInfo > createTagProbeInfo(const ucp_tag_recv_info_t &info, ucp_tag_message_h handle)
Constructor for shared_ptr<ucxx::TagProbeInfo>.
bool isMatched() const
Check if a message was matched.
ucp_tag_message_h getHandle() const
Get the message handle.
const TagRecvInfo & getInfo() const
Get tag receive information.
Information about probed tag message.
Definition: tag_probe.h:25
TagRecvInfo(const ucp_tag_recv_info_t &info)
Construct a TagRecvInfo object from a UCP tag receive info structure.
TagRecvInfo()
Default constructor for TagRecvInfo.
Definition: tag_probe.h:33
const size_t length
The size of the received data.
Definition: tag_probe.h:28
const Tag senderTag
Sender tag.
Definition: tag_probe.h:27
Definition: address.h:15
Tag
Strong type for a UCP tag.
Definition: typedefs.h:60