NewMadeleine

Documentation

« back to PM2 home.
nm_pkt_wrap.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2006-2026 (see AUTHORS file)
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or (at
8 * your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
14 */
15
16#ifndef NM_PKT_WRAP_H
17#define NM_PKT_WRAP_H
18#include <sys/uio.h>
19
33typedef uint32_t nm_pw_flag_t;
34
36#define NM_PW_FLAG_NONE ((nm_pw_flag_t)0x00u)
37
39#define NM_PW_NOHEADER ((nm_pw_flag_t)(0x1u << 0))
40
44#define NM_PW_BUFFER ((nm_pw_flag_t)(0x1u << 1))
45
49#define NM_PW_GLOBAL_HEADER ((nm_pw_flag_t)(0x1u << 2))
50
52#define NM_PW_DYNAMIC_V0 ((nm_pw_flag_t)(0x1u << 3))
53
55#define NM_PW_FINALIZED ((nm_pw_flag_t)(0x1u << 4))
56
58#define NM_PW_PREFETCHING ((nm_pw_flag_t)(0x1u << 5))
59
61#define NM_PW_PREFETCHED ((nm_pw_flag_t)(0x1u << 6))
62
64#define NM_PW_POSTING ((nm_pw_flag_t)(0x1u << 7))
65
67#define NM_PW_POSTED ((nm_pw_flag_t)(0x1u << 8))
68
70#define NM_PW_COMPLETED ((nm_pw_flag_t)(0x1u << 9))
71
73#define NM_PW_SEND ((nm_pw_flag_t)(0x1u << 10))
74
76#define NM_PW_RECV ((nm_pw_flag_t)(0x1u << 11))
77
79#define NM_PW_DATA_COPY ((nm_pw_flag_t)(0x1u << 12))
80
82#define NM_PW_BUF_SEND ((nm_pw_flag_t)(0x1u << 13))
83
85#define NM_PW_BUF_RECV ((nm_pw_flag_t)(0x1u << 14))
86
88#define NM_PW_BUF_MIRROR ((nm_pw_flag_t)(0x1u << 15))
89
91#define NM_PW_CLOSED ((nm_pw_flag_t)(0x1u << 16))
92
94#define NM_PW_POLL_ANY ((nm_pw_flag_t)(0x1u << 17))
95
97#define NM_PW_CANCELED ((nm_pw_flag_t)(0x1u << 18))
98
100#define NM_PW_BLOCKING_CALL ((nm_pw_flag_t)(0x1u << 19))
101
103#define NM_PW_RDV_READY ((nm_pw_flag_t)(0x1u << 20))
104
106#define NM_PW_DATA_IS_CUDA ((nm_pw_flag_t)(0x1u << 21))
107
109#define NM_PW_DATA_IS_HIP ((nm_pw_flag_t)(0x1u << 22))
110
114PUK_LIST_TYPE(nm_pw_pending_rtr,
115 struct nm_gate_s*p_gate;
116 struct nm_header_ctrl_rtr_s header;
117 void*p_payload;
118 );
119
120
126
127#ifndef NMAD_PIOMAN
132#endif /* NMAD_PIOMAN */
133
137{
138 /* ** links */
139
140 PUK_LIST_LINK(nm_pkt_wrap);
141#ifndef NMAD_PIOMAN
142 PUK_LIST_LINK(nm_pw_poll);
143#endif /* NMAD_PIOMAN */
146 /* ** scheduler fields */
147
148#ifdef PIOMAN
149 piom_ltask_t ltask;
150#endif /* PIOMAN */
156 /* ** packet / data description fields. */
157
162 struct iovec*v;
163 int v_size;
164 int v_nb;
165 __attribute__((aligned(16))) struct iovec prealloc_v[NM_PREALLOC_IOV_LEN];
167 struct nm_pkt_s pkt;
169 /* ** lifecycle */
171 void (*destructor)(struct nm_pkt_wrap_s*p_pw);
174 /* ** fields used when sending */
175
176 struct nm_req_chunk_list_s req_chunks;
177 struct nm_pw_pending_rtr_list_s pending_rtrs;
179 /* ** fields used when receiving */
180
183 /* ** fields used only for large messages */
187#if defined(NMAD_PROFILE) || defined(NMAD_SAMPLING)
188 puk_tick_t start_transfer_time;
189#endif /* NMAD_PROFILE || NMAD_SAMPLING */
190#ifdef PIO_OFFLOAD
191 int data_to_offload;
192 piom_ltask_t offload_ltask;
193#endif /* PIO_OFFLOAD */
194
195 /* The following field MUST be the LAST within the structure */
197};
198
200#ifndef NMAD_PIOMAN
202#endif /* NMAD_PIOMAN */
203
204/* tokens for ref-counting
205 * refcount debug may track holders of counters; to do so, the refcount
206 * increment and decrement must pass the same variable (an identical
207 * string is not enough; the pointer must be the same). Hence we define
208 * a variable for each case.
209 */
211extern const char nm_pw_refcount_core[];
213extern const char nm_pw_refcount_completion[];
215extern const char nm_pw_refcount_unexpected[];
217extern const char nm_pw_refcount_prefetch[];
219extern const char nm_pw_refcount_pioman[];
220
225
236
238#define INITIAL_PKT_NUM 16
239
241
243
245
246void nm_pw_free(struct nm_core*p_core, struct nm_pkt_wrap_s*p_pw);
247
248void nm_pw_split(struct nm_core*p_core, struct nm_pkt_wrap_s*p_pw, struct nm_pkt_wrap_s**pp_pw2, nm_len_t offset);
249
251
254
256 const struct nm_data_properties_s*p_props);
257
258struct iovec*nm_pw_grow_iovec(struct nm_pkt_wrap_s*p_pw);
259
261
262/* forward declaration to resolve dependancy */
264
265int nm_pw_add_control(struct nm_pkt_wrap_s*p_pw, const union nm_header_ctrl_generic_s*p_ctrl, const void*p_payload);
266
268
271{
273 assert(p_pw->length <= p_pw->max_len);
274 return p_pw->max_len - p_pw->length;
275}
276
277
278#endif /* NM_PKT_WRAP_H */
uint32_t nm_req_chunk_flag_t
flags for req_chunk
nm_tag_t tag
the user-supplied tag
assert(p_data->ops.p_traversal !=NULL)
nm_data_propertie_gpu_preinit & p_data
Definition nm_data.h:538
static nm_gate_t p_gate
uint16_t len
chunk len
Definition nm_headers.h:0
nm_len_t chunk_len
length of this chunk
Definition nm_headers.h:4
nm_len_t chunk_offset
offset of the enclosed chunk
Definition nm_headers.h:4
nm_seq_t seq
sequence number
Definition nm_headers.h:2
nm_onesided_flag_t flags
#define NM_ALIGN_TYPE
base type for data alignment in packets
#define NM_PREALLOC_IOV_LEN
Number of preallocated iovec entries within packet wrappers.
#define NM_MAX_UNEXPECTED
Maximum size of unexpected packets.
PUK_LIST_TYPE(nm_pw_pending_rtr, struct nm_gate_s *p_gate;struct nm_header_ctrl_rtr_s header;void *p_payload;)
a pending RTR, not processed immediately because prefetch was in progress
void nm_pw_add_data_in_header(struct nm_pkt_wrap_s *p_pw, nm_core_tag_t tag, nm_seq_t seq, struct nm_data_s *p_data, nm_len_t len, nm_len_t chunk_offset, nm_proto_t proto_flags)
const char nm_pw_refcount_prefetch[]
ref by prefetch
const char nm_pw_refcount_pioman[]
ref by pioman ltask
struct nm_pkt_wrap_s * nm_pw_alloc_noheader(struct nm_core *p_core)
PUK_ALLOCATOR_TYPE_SINGLE(nm_pw_nohd, struct nm_pkt_wrap_s)
Allocator for headerless pkt wrapper.
struct iovec * nm_pw_grow_iovec(struct nm_pkt_wrap_s *p_pw)
int nm_pw_finalize(struct nm_pkt_wrap_s *p_pw)
struct nm_pkt_wrap_s * nm_pw_alloc_buffer(struct nm_core *p_core)
PUK_LIST_DECLARE_TYPE2(nm_pw_poll, struct nm_pkt_wrap_s)
list used for pw polling without pioman.
const char nm_pw_refcount_core[]
reference of nmad core on pw
void nm_pw_split(struct nm_core *p_core, struct nm_pkt_wrap_s *p_pw, struct nm_pkt_wrap_s **pp_pw2, nm_len_t offset)
const char nm_pw_refcount_unexpected[]
ref by an unexpected (nm_unexpected_s)
uint32_t nm_pw_flag_t
flags to describe packet wrappers
Definition nm_pkt_wrap.h:33
struct nm_pkt_wrap_s * nm_pw_alloc_global_header(struct nm_core *p_core, struct nm_trk_s *p_trk)
void nm_pw_add_req_chunk(struct nm_pkt_wrap_s *p_pw, struct nm_req_chunk_s *p_req_chunk, nm_req_chunk_flag_t flags)
void nm_pw_set_data_raw(struct nm_pkt_wrap_s *p_pw, struct nm_data_s *p_data, nm_len_t chunk_len, nm_len_t chunk_offset, const struct nm_data_properties_s *p_props)
PUK_LIST_CREATE_FUNCS(nm_pkt_wrap)
PUK_LIST_DECLARE_TYPE(nm_pkt_wrap)
generic list containing a pw.
static nm_len_t nm_pw_remaining_buf(struct nm_pkt_wrap_s *p_pw)
remaining space in pw buffer
const char nm_pw_refcount_completion[]
ref from completion core_task
void nm_pw_free(struct nm_core *p_core, struct nm_pkt_wrap_s *p_pw)
int nm_pw_add_control(struct nm_pkt_wrap_s *p_pw, const union nm_header_ctrl_generic_s *p_ctrl, const void *p_payload)
void nm_pw_data_to_iovec(struct nm_pkt_wrap_s *p_pw)
int8_t nm_trk_id_t
ID of a track, assigned in order.
Definition nm_types.h:86
#define NM_LEN_UNDEFINED
length is undefined
Definition nm_types.h:71
int32_t nm_prio_t
message priority
Definition nm_types.h:78
uint64_t nm_len_t
data length used by nmad
Definition nm_types.h:68
uint32_t nm_seq_t
Sequence number for packets on a given gate/tag.
Definition nm_types.h:102
uint8_t nm_proto_t
protocol flags- not part of the public API, but needed for inline
Definition nm_types.h:99
An internal tag.
asynchronous tasks for nmad core.
Core NewMadeleine structure.
Definition nm_core.h:43
block of static properties for a given data descriptor
Definition nm_data.h:93
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:199
a driver.
Definition nm_drv.h:35
Connection to another process.
Definition nm_gate.h:104
a packet to submit to a driver
Internal packet wrapper.
struct nm_req_s * p_unpack
user-level unpack request (large message only)
struct nm_data_properties_s data_props
pre-computed properties for the chunk of data
PUK_LIST_LINK(nm_pw_poll)
link to insert the pw into a nm_pw_poll
nm_len_t length
cumulated amount of data (everything included) referenced by this wrap.
struct iovec * v
IO vector.
PUK_LIST_LINK(nm_pkt_wrap)
link to insert the pw into a nm_pkt_wrap_list.
struct nm_pkt_s pkt
pkt to give to the driver
void(* destructor)(struct nm_pkt_wrap_s *p_pw)
destructor called uppon packet destroy
int v_nb
number of used entries in the iovec
struct nm_refcount_s refcount
number of references pointing to the header
void * destructor_key
key for destructor to store private data
struct nm_data_s * p_data
data represented as datatype (if non-NULL, v must be empty)
struct nm_req_chunk_list_s req_chunks
list of req chunks contained in this pw (sending)
nm_len_t chunk_offset
offset of this chunk in the message (for large message)
struct nm_pw_pending_rtr_list_s pending_rtrs
pending RTRs attached to this pw
__attribute__((aligned(16))) struct iovec prealloc_v[NM_PREALLOC_IOV_LEN]
pre-allcoated iovec
NM_ALIGN_TYPE buf[1]
struct nm_core_task_s core_task
link to insert the pw as a core task
nm_trk_id_t trk_id
assignated track ID.
int v_size
number of allocated entries in the iovec.
nm_len_t max_len
maximum usable length
nm_prio_t prio
priority, used for sending (all trks) and recv (large only)
nm_pw_flag_t flags
packet flags.
nm_drv_t p_drv
assignated driver.
struct nm_trk_s * p_trk
assignated track, if relevant.
nm_gate_t p_gate
assignated gate, if relevant.
a pw and its associated buffer, allocated together
char buf[NM_MAX_UNEXPECTED]
struct nm_pkt_wrap_s pw
a reference-counter that keeps trace of who increments/decrements in debug: full reference tracking i...
a chunk of request
a generic pack/unpack request
a track on a given gate
Definition nm_gate.h:69
a unified control header type
Definition nm_headers.h:145