18#include <unordered_map>
21#include <ucp/api/ucp.h>
44 UCXX_LOG_LEVEL_TRACE_REQ,
45 UCXX_LOG_LEVEL_TRACE_DATA,
46 UCXX_LOG_LEVEL_TRACE_ASYNC,
47 UCXX_LOG_LEVEL_TRACE_FUNC,
48 UCXX_LOG_LEVEL_TRACE_POLL,
66enum Tag : ucp_tag_t {};
81static constexpr TagMask TagMaskFull{std::numeric_limits<std::underlying_type_t<TagMask>>::max()};
89typedef std::unordered_map<std::string, std::string>
ConfigMap;
143static constexpr size_t AmReceiverCallbackOwnerMaxLen = 63;
148static constexpr size_t AmReceiverCallbackOwnerStorageSize = AmReceiverCallbackOwnerMaxLen + 1;
171 if (s ==
nullptr)
return;
172 const size_t len = std::strlen(s);
173 if (len > AmReceiverCallbackOwnerMaxLen)
174 throw std::invalid_argument(
175 "AmReceiverCallbackOwnerType: owner name exceeds "
176 "maximum length of " +
177 std::to_string(AmReceiverCallbackOwnerMaxLen) +
" characters");
178 std::memcpy(_data.data(), s, len);
188 [[nodiscard]]
const char*
data() const noexcept {
return _data.data(); }
191 [[nodiscard]]
char*
data() noexcept {
return _data.data(); }
194 static constexpr size_t storageSize() noexcept {
return AmReceiverCallbackOwnerStorageSize; }
199 return _data == other._data;
205 return !(*
this == other);
209 std::array<char, AmReceiverCallbackOwnerStorageSize> _data{};
224class AmReceiverCallbackInfo {
229 AmReceiverCallbackInfo() =
delete;
258 uint32_t
flags{UCP_AM_SEND_FLAG_REPLY};
283 if (size > 0 && data ==
nullptr)
284 throw std::invalid_argument(
285 "AmSendParams::setUserHeader received null data with non-zero size");
287 if (size > 0) memcpy(
userHeader.data(), data, size);
316 return std::hash<std::string_view>{}(
317 std::string_view(o.data(), AmReceiverCallbackOwnerStorageSize));
AmReceiverCallbackOwnerType owner
The owner name of the callback.
Definition typedefs.h:226
AmReceiverCallbackInfo(const AmReceiverCallbackOwnerType owner, AmReceiverCallbackIdType id)
Construct an AmReceiverCallbackInfo object.
AmReceiverCallbackIdType id
The unique identifier of the callback.
Definition typedefs.h:227
Active Message receiver callback owner name (fixed-size).
Definition typedefs.h:163
const char * data() const noexcept
Pointer to the raw fixed-size storage.
Definition typedefs.h:188
char * data() noexcept
Mutable pointer to the raw fixed-size storage (for deserialization).
Definition typedefs.h:191
bool operator!=(const AmReceiverCallbackOwnerType &other) const noexcept
Inequality comparison.
Definition typedefs.h:203
AmReceiverCallbackOwnerType()=default
Construct an empty (all-zero) owner name.
AmReceiverCallbackOwnerType(const char *s)
Construct from a null-terminated C string. Throws if length exceeds the limit.
Definition typedefs.h:169
bool operator==(const AmReceiverCallbackOwnerType &other) const noexcept
Equality comparison.
Definition typedefs.h:197
static constexpr size_t storageSize() noexcept
The fixed storage size that is always sent on the wire.
Definition typedefs.h:194
AmReceiverCallbackOwnerType(const std::string &s)
Construct from a std::string. Throws if length exceeds the limit.
Definition typedefs.h:182
A simple object to simplify managing buffers.
Definition buffer.h:31
Send or receive a message with the UCX Active Message API.
Definition request_am.h:33
Base type for a UCXX transfer request.
Definition request.h:39
std::function< void(ucs_status_t, std::shared_ptr< void >)> RequestCallbackUserFunction
A user-defined function to execute as part of a ucxx::Request callback.
Definition typedefs.h:97
std::shared_ptr< void > RequestCallbackUserData
Data for the user-defined function provided to the ucxx::Request callback.
Definition typedefs.h:105
std::unordered_map< std::string, std::string > ConfigMap
A UCP configuration map.
Definition typedefs.h:89
RequestCallbackUserData EndpointCloseCallbackUserData
Data for the user-defined function provided to endpoint close callback.
Definition typedefs.h:121
std::function< std::shared_ptr< Buffer >(size_t)> AmAllocatorType
Custom Active Message allocator type.
Definition typedefs.h:129
TransferDirection
The direction of a UCXX transfer.
Definition typedefs.h:58
AmSendMemoryTypePolicy
Policy used to allocate receive buffers for Active Messages.
Definition typedefs.h:246
@ FallbackToHost
If no allocator exists for memory type, fallback to host memory.
Definition typedefs.h:247
@ ErrorOnUnsupported
If no allocator exists for memory type, fail with unsupported error.
Definition typedefs.h:248
const std::string SerializedRemoteKey
Serialized form of a remote key.
Definition typedefs.h:304
ucxx_log_level_t
Available logging levels.
Definition typedefs.h:36
uint64_t AmReceiverCallbackIdType
Active Message receiver callback identifier.
Definition typedefs.h:217
RequestCallbackUserFunction EndpointCloseCallbackUserFunction
A user-defined function to execute after an endpoint closes.
Definition typedefs.h:113
TagMask
Strong type for a UCP tag mask.
Definition typedefs.h:74
Tag
Strong type for a UCP tag.
Definition typedefs.h:66
std::function< void(std::shared_ptr< Request >, ucp_ep_h)> AmReceiverCallbackType
Active Message receiver callback.
Definition typedefs.h:138
Hash functor for AmReceiverCallbackOwnerType.
Definition typedefs.h:312
size_t operator()(const AmReceiverCallbackOwnerType &o) const noexcept
Compute hash of an AmReceiverCallbackOwnerType.
Definition typedefs.h:314
Parameters controlling Active Message send behavior.
Definition typedefs.h:257
std::optional< AmReceiverCallbackInfo > receiverCallbackInfo
Optional receiver callback metadata.
Definition typedefs.h:263
ucp_datatype_t datatype
Datatype used by ucp_am_send_nbx.
Definition typedefs.h:259
AmSendMemoryTypePolicy memoryTypePolicy
Receiver allocation policy.
Definition typedefs.h:261
void setUserHeader(std::string_view data)
Convenience overload to set user header from string-like views.
Definition typedefs.h:295
std::vector< std::byte > userHeader
Definition typedefs.h:265
void setUserHeader(const void *data, size_t size)
Set opaque user header bytes from raw pointer.
Definition typedefs.h:281
ucs_memory_type_t memoryType
Sender memory type hint.
Definition typedefs.h:260
uint32_t flags
UCP AM send flags.
Definition typedefs.h:258