NewMadeleine

Documentation

« back to PM2 home.
nm_coll_private.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2014-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_COLL_PRIVATE_H
17#define NM_COLL_PRIVATE_H
18
19#include <nm_public.h>
22#include <nm_private.h>
23#include <Padico/Puk.h>
24
25#include "nm_coll_interface.h"
26
27/* ********************************************************* */
28
30#define NM_COLL_TAG_MASK_P2P 0x7FFFFFFF
32#define NM_COLL_TAG_BASE 0xFF000000
34#define NM_COLL_TAG_COMM_CREATE_1 ( NM_COLL_TAG_BASE | 0x04 )
36#define NM_COLL_TAG_COMM_CREATE_2 ( NM_COLL_TAG_BASE | 0x05 )
37
38/* ********************************************************* */
39
61
63
64typedef void (*nm_coll_req_destructor_t)(struct nm_coll_req_s*);
65
67{
72 void*p_ref;
73#ifdef NMAD_PROFILE
74 struct
75 {
76 puk_tick_t start_time;
77 struct nm_coll_profile_s*p_prof_local;
78 struct nm_coll_profile_s*p_prof_global;
79 nm_len_t bytes;
80 int nodes;
81 } profiling;
82#endif /* NMAD_PROFILE */
84};
85
89
91{
92 return (void*)&p_coll_req->_payload;
93}
94
95static inline struct nm_coll_req_s*nm_coll_req_container(void*p_payload)
96{
97 struct nm_coll_req_s*p_coll_req = puk_container_of(p_payload, struct nm_coll_req_s, _payload);
98 return p_coll_req;
99}
100
103
104
105/* ********************************************************* */
106
108static inline void nm_coll_datav_descendants(const struct nm_coll_tree_info_s*p_tree,
109 struct nm_datav_s*p_datav, struct nm_data_s*p_data, nm_len_t data_size,
110 int*p_descendants, int child, int child_weight)
111{
112 assert(child_weight > 0);
113 if(p_descendants == NULL)
114 {
115 if(child + child_weight <= p_tree->n)
116 {
117 /* contig */
118 nm_datav_add_chunk_excerpt(p_datav, p_data, data_size * child, data_size * child_weight);
119 }
120 else
121 {
122 /* wrap-around */
123 const int w2 = child + child_weight - p_tree->n;
124 const int w1 = child_weight - w2;
125 nm_datav_add_chunk_excerpt(p_datav, p_data, data_size * child, data_size * w1);
126 nm_datav_add_chunk_excerpt(p_datav, p_data, 0, data_size * w2);
127 }
128 }
129 else
130 {
131 int start_index = p_descendants[0];
132 int span = 1;
133 int k;
134 for(k = 1; k < child_weight; k++)
135 {
136 const int index = p_descendants[k];
137 if(index == start_index + span)
138 {
139 span++;
140 }
141 else
142 {
143 nm_datav_add_chunk_excerpt(p_datav, p_data, data_size * start_index, data_size * span);
144 start_index = index;
145 span = 1;
146 }
147 }
148 nm_datav_add_chunk_excerpt(p_datav, p_data, data_size * start_index, data_size * span);
149 }
150}
151
152/* ** profiling ******************************************** */
153
156{
157 unsigned long long n;
158 unsigned long long total_bytes;
159 unsigned long long total_nodes;
161};
162
163#ifdef NMAD_PROFILE
164
165static inline void nm_coll_profile_add(struct nm_coll_profile_s*p_prof_local, struct nm_coll_profile_s*p_prof_global,
166 nm_len_t bytes, int nodes, puk_tick_t start_time)
167{
168 puk_tick_t end_time;
169 PUK_GET_TICK(end_time);
170 const double tdiff = PUK_TIMING_DELAY(start_time, end_time);
171 if(p_prof_local != NULL)
172 {
173 nm_profile_inc(p_prof_local->n);
174 nm_profile_add(p_prof_local->total_bytes, bytes);
175 nm_profile_add(p_prof_local->total_nodes, nodes);
176 p_prof_local->total_time_usecs += tdiff;
177 }
178 if(p_prof_global != NULL)
179 {
180 nm_profile_inc(p_prof_global->n);
181 nm_profile_add(p_prof_global->total_bytes, bytes);
182 nm_profile_add(p_prof_global->total_nodes, nodes);
183 p_prof_global->total_time_usecs += tdiff;
184 }
185}
186
187static inline void nm_coll_profile_def(struct nm_coll_profile_s*p_profile, const char*name)
188{
189 puk_profile_var_defx(unsigned_long_long, counter, &p_profile->n, 0,
190 "total number of this coll op",
191 "nm_coll.%s.n", name);
192 puk_profile_var_defx(unsigned_long_long, aggregate, &p_profile->total_bytes, 0,
193 "total number of bytes sent through this coll op",
194 "nm_coll.%s.total_bytes", name);
195 puk_profile_var_defx(unsigned_long_long, aggregate, &p_profile->total_nodes, 0,
196 "total number of nodes involved in this coll op",
197 "nm_coll.%s.total_nodes", name);
198 puk_profile_var_defx(double, timer, &p_profile->total_time_usecs, 0.0,
199 "total time spent in this coll op",
200 "nm_coll.%s.total_time_usecs", name);
201}
202
204static inline void nm_coll_req_set_profile(struct nm_coll_req_s*p_coll_req,
205 struct nm_coll_profile_s*p_prof_local, struct nm_coll_profile_s*p_prof_global,
206 nm_len_t bytes, int nodes)
207{
208 PUK_GET_TICK(p_coll_req->profiling.start_time);
209 p_coll_req->profiling.p_prof_local = p_prof_local;
210 p_coll_req->profiling.p_prof_global = p_prof_global;
211 p_coll_req->profiling.bytes = bytes;
212 p_coll_req->profiling.nodes = nodes;
213}
214
215#endif /* NMAD_PROFILE */
216
217#endif /* NM_COLL_PRIVATE_H */
void(* nm_coll_req_notifier_t)(void *ref)
notification function for collective reqs
Definition nm_coll.h:131
static void nm_datav_add_chunk_excerpt(struct nm_datav_s *p_datav, struct nm_data_s *p_data, nm_len_t chunk_offset, nm_len_t chunk_len)
add an excerpt of data to datav; given p_data content is not copied.
Definition nm_data.h:861
nm_status_t nm_cond_status_t
status with synchronization (wait/signal)
static void nm_coll_datav_descendants(const struct nm_coll_tree_info_s *p_tree, struct nm_datav_s *p_datav, struct nm_data_s *p_data, nm_len_t data_size, int *p_descendants, int child, int child_weight)
add chunks of data described by descendants to datav, with aggregation of adjacent chunks
static void * nm_coll_req_payload(struct nm_coll_req_s *p_coll_req)
static struct nm_coll_req_s * nm_coll_req_container(void *p_payload)
enum nm_coll_req_kind_e nm_coll_req_kind_t
struct nm_coll_req_s * nm_coll_req_alloc(nm_len_t payload_size, nm_coll_req_kind_t kind, nm_coll_req_destructor_t p_destructor, nm_coll_req_notifier_t p_notify, void *p_ref)
nm_coll_req_kind_e
@ NM_COLL_REQ_BCAST_TREEDRV
@ NM_COLL_REQ_SCATTER
@ NM_COLL_REQ_NONE
@ NM_COLL_REQ_COLLDRV
op is managed by a colldrv
@ NM_COLL_REQ_ALLGATHER_BUTTERFLY
@ NM_COLL_REQ_ALLGATHER_TREE
@ NM_COLL_REQ_BCAST_2TREES
@ NM_COLL_REQ_GATHER
@ NM_COLL_REQ_ALLGATHER_BRUCK
@ NM_COLL_REQ_BARRIER_BRUCK
@ NM_COLL_REQ_BARRIER_BUTTERFLY
@ _NM_COLL_REQ_KIND_MAX
@ NM_COLL_REQ_BCAST_TREE
@ NM_COLL_REQ_BARRIER_TREE
@ NM_COLL_REQ_DEFAULT
@ NM_COLL_REQ_BCAST_PIPELINE
@ NM_COLL_REQ_ALLGATHER_RBRUCK
@ NM_COLL_REQ_OTHER
external use of nm_coll_req_e
void(* nm_coll_req_destructor_t)(struct nm_coll_req_s *)
void nm_coll_req_signal(struct nm_coll_req_s *p_coll_req)
used internally to signal the completion of a coll req
#define nm_profile_inc(COUNTER)
#define nm_profile_add(COUNTER, VALUE)
assert(p_data->ops.p_traversal !=NULL)
nm_data_propertie_gpu_preinit & p_data
Definition nm_data.h:539
nm_len_t payload_size
Definition nm_headers.h:6
struct nm_coll_req_s * p_coll_req
non-blocking nmad native collective
main header for private nmad definitions.
This is the common public header for NewMad.
uint64_t nm_len_t
data length used by nmad
Definition nm_types.h:68
profiling block for collective ops
unsigned long long n
number of times the operation was called
unsigned long long total_nodes
total number of nodes involved for all ocurrences of this op
unsigned long long total_bytes
total number of bytes sent through this op
int _payload
dummy placeholder; payload is actually allocated after this struct
nm_coll_req_notifier_t p_notify
notification function for op termination
nm_cond_status_t status
status for explicit wait- not signaled if p_notify is non-NULL
nm_coll_req_destructor_t p_destructor
nm_coll_req_kind_t kind
void * p_ref
reference given to above p_notify
description of an instanciated tree
int n
number of nodes involved in collective
a data descriptor, used to pack/unpack data from app layout to/from contiguous buffers
Definition nm_data.h:200
encapsulate a dynamic vector of nm_data
Definition nm_data.h:255