NewMadeleine

Documentation

« back to PM2 home.
nm_launcher_interface.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_LAUNCHER_INTERFACE_H
17#define NM_LAUNCHER_INTERFACE_H
18
23#include <nm_public.h>
25
32
37PUK_VECT_TYPE(nm_launcher_rank, int);
38
39PUK_VECT_TYPE(nm_launcher_subgroup, int);
40
42static inline int nm_launcher_init(int*argc, char**argv);
43
46
49
52
55
58
65int nm_launcher_get_topology(struct nm_launcher_rank_vect_s*p_ranks,
66 struct nm_launcher_subgroup_vect_s*p_subgroups, int*n_subgroups);
67
69void nm_launcher_abort(int rc);
70
71typedef void (*nm_launcher_atexit_t)(void);
74
78int nm_launcher_init_nocheck(int*argc, char**argv);
79
80static inline int nm_launcher_init(int*argc, char**argv)
81{
83 return nm_launcher_init_nocheck(argc, argv);
84}
85
88{
89 int rank;
93 return p_gate;
94}
95
98
102
103/* ** lazy init for sub-modules **************************** */
104
105#ifndef __cplusplus
106
107#include <stdatomic.h>
108
110{
111 atomic_int init_done;
112 atomic_int initializing;
113};
114
115#define NM_LAZY_INITIALIZER_INIT { .init_done = 0, .initializing = 0 }
116
122#define NM_LAZY_INITIALIZER(ENAME, CTOR, DTOR) \
123 static struct nm_lazy_initializer_s ENAME ## _lazy_initializer = NM_LAZY_INITIALIZER_INIT; \
124 \
125 static void ENAME ## _lazy_destructor(void) \
126 { \
127 if(ENAME##_lazy_initializer.init_done > 0) \
128 { \
129 (*DTOR)(); \
130 } \
131 ENAME##_lazy_initializer.init_done = -1; \
132 } \
133 static void ENAME ## _lazy_init(void) \
134 { \
135 if(ENAME##_lazy_initializer.init_done == 0) \
136 { \
137 if(atomic_fetch_add(&ENAME##_lazy_initializer.initializing, 1) == 0) \
138 { \
139 (*CTOR)(); \
140 atomic_fetch_add(&ENAME##_lazy_initializer.init_done, 1); \
141 nm_launcher_atexit(ENAME ## _lazy_destructor); \
142 } \
143 else \
144 { \
145 while(!ENAME##_lazy_initializer.init_done) \
146 { \
147 sched_yield(); \
148 } \
149 } \
150 } \
151 else if(ENAME##_lazy_initializer.init_done == -1) \
152 { \
153 NM_FATAL("trying to use %s after detructor.\n", #ENAME); \
154 } \
155 }
156
157#endif /* __cplusplus */
158
160
161#endif /* NM_LAUNCHER_INTERFACE_H */
NM_EXTERN_C_BEGIN PUK_VECT_TYPE(nm_launcher_rank, int)
static void nm_abi_config_check(void)
Check consistency of ABI config between nmad and application.
Definition nm_public.h:209
typedefNM_EXTERN_C_BEGIN struct nm_core * nm_core_t
static nm_gate_t p_gate
int nm_launcher_get_rank(int *rank)
Returns process rank.
void(* nm_launcher_atexit_t)(void)
int nm_launcher_get_topology(struct nm_launcher_rank_vect_s *p_ranks, struct nm_launcher_subgroup_vect_s *p_subgroups, int *n_subgroups)
Returns topology.
void nm_launcher_print_drivers_strategy(nm_core_t p_core)
print on stderr loaded drivers and the selected strategy
int nm_launcher_get_size(int *size)
Returns the number of nodes.
void nm_launcher_abort(int rc)
Abort all processes.
int nm_launcher_exit(void)
Cleans session.
int nm_launcher_homogeneous_network(void)
Checks whether the networks are homogeneous across all nodes.
int nm_launcher_get_gate(int dest, nm_gate_t *gate)
Returns the gate for the process dest.
int nm_launcher_init_nocheck(int *argc, char **argv)
static int nm_launcher_init(int *argc, char **argv)
Initializes nmad.
static nm_gate_t nm_launcher_self_gate(void)
shortcut to get the gate to self
int nm_launcher_get_dest(nm_gate_t p_gate, int *dest)
Returns the dest rank for the given gate.
void nm_launcher_atexit(nm_launcher_atexit_t p_func)
registers a function to be called at exit
nm_gate_t gate
gate of the destination or the source node
nm_len_t size
size of the onsided data (not incuding target-side completion)
This is the common public header for NewMad.
#define NM_EXTERN_C_END
Definition nm_public.h:78
#define NM_EXTERN_C_BEGIN
Definition nm_public.h:77
Connection to another process.
Definition nm_gate.h:109
atomic_int initializing
whether init is in progress
atomic_int init_done
whether init is already done