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
209#include <nm_public.h>
210#include <Padico/Puk.h>
211#ifdef NMAD_HWLOC
212#include <hwloc.h>
213#endif
214#include <sys/uio.h>
215#include <string.h>
216
221{
222#ifdef NMAD_HWLOC
223 hwloc_cpuset_t cpuset;
224#endif /* NMAD_HWLOC */
229};
230
258
264
272
274#define NM_RDV_DATA_SIZE (4 * sizeof(uint64_t))
275
279{
280 /* if a data representation is not available, its pointer is NULL
281 */
282 struct
283 {
284 void*p_buf;
286 } buf;
287 struct
288 {
289 struct iovec*v;
290 int n;
291 } iov;
292 struct
293 {
299 struct
300 {
304 struct
305 {
306 void*p_ptr;
308 struct
309 {
310 void*p_entry;
312 struct
313 {
314 void*p_entry;
316 struct
317 {
320};
321
322static inline void nm_pkt_init(struct nm_pkt_s*p_pkt)
323{
324 memset(p_pkt, 0, sizeof(struct nm_pkt_s));
325}
326
332{
333 /* ** driver init; applied to context before/after instantiation */
334
336 void (*getprops)(puk_context_t context, struct nm_minidriver_properties_s*props);
338 void (*init)(puk_context_t context, const void**drv_url, size_t*url_size);
340 void (*close)(puk_context_t context);
341
342 /* ** connection establishment */
343
345 void (*connect_async)(void*_status, const void*remote_url, size_t url_size);
347 void (*connect_wait)(void*_status);
349 void (*disconnect)(void*_status);
350
351 /* ** send pkt-based functions */
352
359 int (*send_pkt_buf_get)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
365 int (*send_pkt_post)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
372 int (*send_pkt_poll)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
374 int (*send_pkt_wait)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
375
376 /* ** recv pkt-based functions */
377
384 int (*recv_pkt_post)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
395 int (*recv_pkt_poll)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
398 int (*recv_pkt_buf_release)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
404 int (*recv_pkt_wait)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
410 int (*recv_pkt_cancel)(void*_status, struct nm_pkt_s*p_pkt) __attribute__ ((warn_unused_result));
411
412 /* ** recv any functions */
413
419 int (*recv_probe_any)(puk_context_t p_context, void**_status) __attribute__ ((warn_unused_result));
425 int (*recv_wait_any)(puk_context_t p_context, void**_status) __attribute__ ((warn_unused_result));
431 int (*recv_cancel_any)(puk_context_t p_context) __attribute__ ((warn_unused_result));
432
433 /* ** prefetch */
434
436 void (*send_pkt_prefetch)(void*_status, struct nm_pkt_s*p_pkt);
438 void (*send_pkt_unfetch)(void*_status, struct nm_pkt_s*p_pkt);
440 void (*recv_pkt_prefetch)(puk_context_t p_context, struct nm_pkt_s*p_pkt);
442 void (*recv_pkt_unfetch)(puk_context_t p_context, struct nm_pkt_s*p_pkt);
443
444};
445PUK_IFACE_TYPE(NewMad_minidriver, struct nm_minidriver_iface_s);
446
449{
450 memset(p_props, 0, sizeof(struct nm_minidriver_properties_s));
451}
454{
455 assert(p_props->capabilities.max_pkt_sends > 0);
456 assert(p_props->capabilities.max_pkt_recvs > 0);
457 if(p_props->capabilities.max_iovecs == 0)
458 {
459 if(p_props->capabilities.supports_iovec)
460 {
461 p_props->capabilities.max_iovecs = INT_MAX;
462 }
463 else
464 {
465 p_props->capabilities.max_iovecs = 1;
466 }
467 }
468 if(p_props->capabilities.max_msg_size == 0)
469 {
471 }
472}
473
474#endif /* NM_MINIDRIVER_H */
struct nm_core_event_s __attribute__
Definition nm_data.h:538
assert(p_data->ops.p_traversal !=NULL)
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.
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:93
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:199
Performance information for driver.
int latency
Approximative performance of the board.
int bandwidth
in MB/s
Static driver capabilities.
int no_send_poll
do not poll immediately after send post
int max_iovecs
maximum size of iovecs; 0 for unlimited
int supports_recv_prefetch
supports prefetch on the receiver side
int max_pkt_recvs
maximum number of concurrent receives; if 0, 1 is assumed
int prefers_wait_any
wait_any must be prefered for this driver
nm_len_t max_msg_size
maximum message size for the track
int supports_buf_send
driver supported buffer-based send
int supports_recv_wait
drivers support blocking wait for a single receive
int supports_cuda
the driver can send/recv data in CUDA GPU memory
int prefers_recv_wait
recv_pkt_wait must be prefered to recv_poll_one
int supports_recv_any
driver accepts receive from any source (recv_probe_any)
int prefers_send_wait
send_pkt_wait must be prefered to send_poll
int self
whether this driver communicates only with self
int supports_send_prefetch
supports prefetch on the sender side
int supports_buf_recv
driver supported buffer-based recv
int supports_iovec
driver can send iovecs; if set to 0 and send_iov_post is non-NULL, then driver supports only iov coun...
int trk_rdv
trk needs a rdv for matched send/recv size; if 0, trk preserves boundaries
int max_pkt_sends
maximum number of concurrent sends; if 0, 1 is assumed
int supports_wait_any
drivers supports passive wait_any
int supports_data
driver can send/recv direct nm_data_s
int min_period
minimum delay between poll (in microseconds)
int supports_hip
the driver can send/recv data in HIP ROCm GPU memory
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
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)
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
int sender_is_contig
data is contiguous in sender side
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