NewMadeleine

Documentation

« back to PM2 home.
nm_minidriver.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2013-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_MINIDRIVER_H
17#define NM_MINIDRIVER_H
18
19#include <stdint.h>
20#include <stdbool.h>
21#include <nm_data.h>
22
211#include <nm_public.h>
212#include <Padico/Puk.h>
213#ifdef NMAD_HWLOC
214#include <hwloc.h>
215#endif
216#include <sys/uio.h>
217#include <string.h>
218
223{
224#ifdef NMAD_HWLOC
225 hwloc_cpuset_t cpuset;
226#endif /* NMAD_HWLOC */
231};
232
248
277
283
291
293#define NM_RDV_DATA_SIZE (4 * sizeof(uint64_t))
294
298{
299 /* if a data representation is not available, its pointer is NULL
300 */
301 struct
302 {
303 void*p_buf;
305 } buf;
306 struct
307 {
308 struct iovec*v;
309 int n;
310 } iov;
311 struct
312 {
318 struct
319 {
323 struct
324 {
325 void*p_ptr;
327 struct
328 {
329 void*p_entry;
331 struct
332 {
333 void*p_entry;
335 struct
336 {
340};
341
342static inline void nm_pkt_init(struct nm_pkt_s*p_pkt)
343{
344 memset(p_pkt, 0, sizeof(struct nm_pkt_s));
345}
346
352{
353 /* ** driver init; applied to context before/after instantiation */
354
356 void (*getprops)(puk_context_t context, struct nm_minidriver_properties_s*props);
358 void (*init)(puk_context_t context, const void**drv_url, size_t*url_size);
360 void (*close)(puk_context_t context);
361
362 /* ** connection establishment */
363
365 void (*connect_async)(void*_status, const void*remote_url, size_t url_size);
367 void (*connect_wait)(void*_status);
369 void (*disconnect)(void*_status);
370
371 /* ** send pkt-based functions */
372
379 int (*send_pkt_buf_get)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
385 int (*send_pkt_post)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
392 int (*send_pkt_poll)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
394 int (*send_pkt_wait)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
395
396 /* ** recv pkt-based functions */
397
404 int (*recv_pkt_post)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
415 int (*recv_pkt_poll)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
418 int (*recv_pkt_buf_release)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
424 int (*recv_pkt_wait)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
430 int (*recv_pkt_cancel)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
431
432 /* ** recv any functions */
433
439 int (*recv_probe_any)(puk_context_t p_context, void**_status) __attribute__ ((warn_unused_result));
445 int (*recv_wait_any)(puk_context_t p_context, void**_status) __attribute__ ((warn_unused_result));
451 int (*recv_cancel_any)(puk_context_t p_context) __attribute__ ((warn_unused_result));
452
453 /* ** prefetch */
454
456 void (*send_pkt_prefetch)(void*_status, struct nm_pkt_s*p_pkt);
458 void (*send_pkt_unfetch)(void*_status, struct nm_pkt_s*p_pkt);
460 void (*recv_pkt_prefetch)(puk_context_t p_context, struct nm_pkt_s*p_pkt);
462 void (*recv_pkt_unfetch)(puk_context_t p_context, struct nm_pkt_s*p_pkt);
463
464};
465PUK_IFACE_TYPE(NewMad_minidriver, struct nm_minidriver_iface_s);
466
469{
470 memset(p_props, 0, sizeof(struct nm_minidriver_properties_s));
471}
474{
475 assert(p_props->capabilities.max_pkt_sends > 0);
476 assert(p_props->capabilities.max_pkt_recvs > 0);
477 if(p_props->capabilities.max_iovecs == 0)
478 {
479 if(p_props->capabilities.supports_iovec)
480 {
481 p_props->capabilities.max_iovecs = INT_MAX;
482 }
483 else
484 {
485 p_props->capabilities.max_iovecs = 1;
486 }
487 }
488 if(p_props->capabilities.max_msg_size == 0)
489 {
491 }
492}
493
494#endif /* NM_MINIDRIVER_H */
struct nm_core_event_s __attribute__
Definition nm_data.h:539
High-level data manipulation through iterators.
assert(p_data->ops.p_traversal !=NULL)
nm_minidriver_reentrance_e
level of reentrance of driver.
@ nm_minidriver_reentrance_trk_dir
no concurrent calls for a track except between send/recv
@ nm_minidriver_reentrance_drv_dir
no concurrent calls for the driver except between send/recv directions
@ nm_minidriver_reentrance_hybrid
no concurrent calls for a track on sender-side, no concurrent calls for the driver on receiver-side
@ nm_minidriver_reentrance_drv
no concurrent calls at all for the full driver
@ nm_minidriver_reentrance_pkt
no concurrent calls for a given pkt (default)
@ nm_minidriver_reentrance_full
no restriction on reentrance
@ nm_minidriver_reentrance_trk
no concurrent calls for a track (driver instance)
PUK_IFACE_TYPE(NewMad_minidriver, struct nm_minidriver_iface_s)
static void nm_pkt_init(struct nm_pkt_s *p_pkt)
static void nm_minidriver_properties_init(struct nm_minidriver_properties_s *p_props)
initialize all properties to 0
static void nm_minidriver_properties_normalize(struct nm_minidriver_properties_s *p_props)
ensure properties are in canonical form
This is the common public header for NewMad.
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
#define NM_LEN_MAX
maximum length usable in nmad.
Definition nm_types.h:73
enum nm_trk_kind_e nm_trk_kind_t
block of static properties for a given data descriptor
Definition nm_data.h:94
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:200
Performance information for driver.
int latency
Approximative performance of the board.
int bandwidth
in MB/s
Static driver capabilities.
bool supports_recv_prefetch
supports prefetch on the receiver side
int max_iovecs
maximum size of iovecs; 0 for unlimited
enum nm_minidriver_reentrance_e reentrance
reentrance model this driver complies with
bool supports_buf_recv
driver supported buffer-based recv
int max_pkt_recvs
maximum number of concurrent receives; if 0, 1 is assumed
bool self
whether this driver communicates only with self
nm_len_t max_msg_size
maximum message size for the track
bool prefers_wait_any
wait_any must be prefered for this driver
bool no_send_poll
do not poll immediately after send post
bool supports_buf_send
driver supported buffer-based send
bool prefers_recv_wait
recv_pkt_wait must be prefered to recv_poll_one
bool supports_iovec
driver can send iovecs; if set to 0 and send_iov_post is non-NULL, then driver supports only iov coun...
bool supports_hip
the driver can send/recv data in HIP ROCm GPU memory
bool supports_cuda
the driver can send/recv data in CUDA GPU memory
int max_pkt_sends
maximum number of concurrent sends; if 0, 1 is assumed
bool supports_wait_any
drivers supports passive wait_any
int min_period
minimum delay between poll (in microseconds)
bool supports_data
driver can send/recv direct nm_data_s
bool prefers_send_wait
send_pkt_wait must be prefered to send_poll
bool supports_send_prefetch
supports prefetch on the sender side
bool trk_rdv
trk needs a rdv for matched send/recv size; if 0, trk preserves boundaries
bool supports_recv_wait
drivers support blocking wait for a single receive
bool supports_recv_any
driver accepts receive from any source (recv_probe_any)
some hints to help drivers tune themselves
Interface driver for the 'NewMad_minidriver' component interface.
void(* connect_wait)(void *_status)
wait for a previously posted connect_async to complete
int(* recv_wait_any)(puk_context_t p_context, void **_status) __attribute__((warn_unused_result))
passively wait for a pending recv from any source; return status of instance
int(* recv_pkt_wait)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
wait for completion of a recv operation already posted
void(* send_pkt_prefetch)(void *_status, struct nm_pkt_s *p_pkt)
prefetch data in driver buffers before send_pkt_post; calling it is optional
int(* recv_pkt_buf_release)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
release a buffer for buffer-based receive.
void(* init)(puk_context_t context, const void **drv_url, size_t *url_size)
init the driver and get its url
int(* recv_pkt_cancel)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
cancel a posted recv
int(* recv_cancel_any)(puk_context_t p_context) __attribute__((warn_unused_result))
cancel a recv_wait_any
void(* close)(puk_context_t context)
close the driver
int(* send_pkt_wait)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
wait for completion of a send operation already posted
void(* disconnect)(void *_status)
disconnect this instance
int(* recv_probe_any)(puk_context_t p_context, void **_status) __attribute__((warn_unused_result))
poll the driver for a pending recv from any source; returns status of instance
void(* recv_pkt_unfetch)(puk_context_t p_context, struct nm_pkt_s *p_pkt)
cancel a prefetch recv; a prefetch is assupmed to always be followed either by 'recv' or 'unfetch'
void(* getprops)(puk_context_t context, struct nm_minidriver_properties_s *props)
get driver properties (profiling and capabilities)
void(* send_pkt_unfetch)(void *_status, struct nm_pkt_s *p_pkt)
cancel a prefetch; a prefetch is assumed to always be followed by either 'send' or 'unfetch'
int(* recv_pkt_post)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
post a pkt recv
void(* recv_pkt_prefetch)(puk_context_t p_context, struct nm_pkt_s *p_pkt)
prefetch recv, i.e.
int(* send_pkt_buf_get)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
get a buffer from the driver for sending;
void(* connect_async)(void *_status, const void *remote_url, size_t url_size)
asynchronously start the connect process
int(* send_pkt_poll)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
poll a send operation already posted;
int(* recv_pkt_poll)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
poll a recv operation already posted.
int(* send_pkt_post)(void *_status, struct nm_pkt_s *p_pkt) __attribute__((warn_unused_result))
post a send request for data described in pkt;
struct nm_minidriver_capabilities_s capabilities
struct nm_minidriver_hints_s hints
struct nm_drv_profile_s profile
const char * nickname
user-friendly name to display when user asks which drivers are used
a packet to submit to a driver
struct nm_pkt_s::@33 flags
bool sender_is_contig
data is contiguous in sender side
struct nm_pkt_s::@32 recv_prefetch
void * p_content
content of rdv_data; remains allocated until pkt completion
struct iovec * v
nm_len_t chunk_offset
struct nm_pkt_s::@27 iov
iovec data (with a single entry if supports_iovec == 0)
nm_prio_t prio
priority of the packet, i.e.
struct nm_pkt_s::@31 send_prefetch
struct nm_data_properties_s chunk_props
pre-computed properties for the chunk of data
struct nm_pkt_s::@28 data
data iterator
struct nm_data_s * p_data
nm_len_t chunk_len
void * p_buf
struct nm_pkt_s::@30 driver_data
to be used by the driver itself, to save status accross calls
nm_len_t size
nm_len_t len
struct nm_pkt_s::@29 rdv_data
rdv data, filled by receiver, read by sender, if needed
void * p_ptr
struct nm_pkt_s::@26 buf
buffer given by the driver
void * p_entry
placeholder for driver to store a prefetch entry