NewMadeleine

Documentation

« back to PM2 home.
nm_sync_clocks_interface.h
Go to the documentation of this file.
1/*
2 * NewMadeleine
3 * Copyright (C) 2006-2021 (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_SYNC_CLOCKS_H
17#define NM_SYNC_CLOCKS_H
18
19#include <nm_coll_interface.h>
21
22#define SYNC_CLOCKS_USE_PUK
23#include "nm_sync_clocks_generic.h"
24
25
26#ifdef __cplusplus
27extern "C"
28{
29#endif
30
31 /* ********************************************************* */
32 /* ** nmad sync clocks public API */
33
35 typedef struct sync_clocks_generic_s*nm_sync_clocks_t;
36
38
40 static inline void nm_sync_clocks_shutdown(nm_sync_clocks_t p_clocks);
41
43 static inline double nm_sync_clocks_get_time_usec(nm_sync_clocks_t p_clocks);
44
46 static inline double nm_sync_clocks_remote_to_global(nm_sync_clocks_t p_clocks, int rank, double t);
47
49 static inline double nm_sync_clocks_global_to_local(nm_sync_clocks_t p_clocks, double global_time);
50
52 static inline double nm_sync_clocks_local_to_global(nm_sync_clocks_t p_clocks, double local_t);
53
55 static inline void nm_sync_clocks_synchronize(nm_sync_clocks_t p_clocks);
56
61 static inline int nm_sync_clocks_barrier(nm_sync_clocks_t p_clocks, double*barrier_local_time);
62
64 static inline long double nm_sync_clocks_get_skew(nm_sync_clocks_t p_clocks, int rank);
65
67 static inline double nm_sync_clocks_get_origin(nm_sync_clocks_t p_clocks);
68
69 /* ********************************************************* */
70 /* legacy function, for ascending compatibility */
71
72#define nm_sync_clocks_compute_offsets sync_clocks_generic_synchronize
73
74#define nm_sync_clocks_apply_offset sync_clocks_generic_remote_to_global
75
76 static inline double nm_sync_clocks_add_real_origin_usec(nm_sync_clocks_t p_clocks, double t)
77 {
78 return t + sync_clocks_generic_get_origin(p_clocks);;
79 }
80
81
82 /* ********************************************************* */
83 /* ** nmad sync clocks internals */
84
89
90 static inline void nm_sync_clocks_send(nm_sync_clocks_t p_clocks, int dest, int tag, void*p_data, int size)
91 {
92 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
94 nm_gate_t p_gate = nm_comm_get_gate(p_nm_clocks->p_comm, dest);
96 }
97 static inline void nm_sync_clocks_recv(nm_sync_clocks_t p_clocks, int from, int tag, void*p_data, int size)
98 {
99 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
101 nm_gate_t p_gate = nm_comm_get_gate(p_nm_clocks->p_comm, from);
102 nm_sr_recv(p_session, p_gate, tag, p_data, size);
103 }
104 static inline void nm_sync_clocks_bcast(nm_sync_clocks_t p_clocks, int root, int tag, void*p_data, int size)
105 {
106 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
107 nm_coll_bcast(p_nm_clocks->p_comm, root, p_data, size, tag);
108 }
109 static inline void nm_sync_clocks_gather(nm_sync_clocks_t p_clocks, int root, int tag, void*p_sbuf, int size, void*p_rbuf)
110 {
111 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
112 nm_coll_gather(p_nm_clocks->p_comm, root, p_sbuf, size, p_rbuf, size, tag);
113 }
114 static inline void nm_sync_clocks_nm_barrier(nm_sync_clocks_t p_clocks)
115 {
116 const nm_tag_t tag = 0x01;
117 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
118 nm_coll_barrier(p_nm_clocks->p_comm, tag);
119 }
120
121 /* ******************************************************* */
122 /* nmad sync clocks implementation */
123
125 {
126 static const struct sync_clocks_backend_s backend =
127 {
128 .send = &nm_sync_clocks_send,
129 .recv = &nm_sync_clocks_recv,
130 .bcast = &nm_sync_clocks_bcast,
131 .gather = &nm_sync_clocks_gather,
132 .barrier = &nm_sync_clocks_nm_barrier
133 };
134 struct sync_clocks_generic_s*p_clocks = malloc(sizeof(struct sync_clocks_generic_s));
135 p_clocks->backend = backend;
136 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
137 p_nm_clocks->p_comm = nm_comm_dup(p_comm);
138 p_clocks->comm_size = nm_comm_size(p_nm_clocks->p_comm);
139 p_clocks->rank = nm_comm_rank(p_nm_clocks->p_comm);
140 sync_clocks_generic_init(p_clocks);
141 return p_clocks;
142 }
143
144 static inline void nm_sync_clocks_shutdown(nm_sync_clocks_t p_clocks)
145 {
146 struct nm_sync_clocks_nmad_s*p_nm_clocks = (struct nm_sync_clocks_nmad_s*)&p_clocks->backend_data;
147 nm_comm_destroy(p_nm_clocks->p_comm);
148 sync_clocks_generic_shutdown(p_clocks);
149 }
150
151 static inline double nm_sync_clocks_get_time_usec(nm_sync_clocks_t p_clocks)
152 {
153 return sync_clocks_generic_get_time_usec(p_clocks);
154 }
155
156 static inline double nm_sync_clocks_remote_to_global(nm_sync_clocks_t p_clocks, int rank, double remote_time)
157 {
158 return sync_clocks_generic_remote_to_global(p_clocks, rank, remote_time);
159 }
160
161 static inline double nm_sync_clocks_local_to_global(nm_sync_clocks_t p_clocks, double local_time)
162 {
163 return sync_clocks_generic_local_to_global(p_clocks, local_time);
164 }
165
166 static inline double nm_sync_clocks_global_to_local(nm_sync_clocks_t p_clocks, double global_time)
167 {
168 return sync_clocks_generic_global_to_local(p_clocks, global_time);
169 }
170
171 static inline void nm_sync_clocks_synchronize(nm_sync_clocks_t p_clocks)
172 {
173 sync_clocks_generic_synchronize(p_clocks);
174 }
175
176 static inline int nm_sync_clocks_barrier(nm_sync_clocks_t p_clocks, double*barrier_local_time)
177 {
178 return sync_clocks_generic_barrier(p_clocks, barrier_local_time);
179 }
180
181 static inline long double nm_sync_clocks_get_skew(nm_sync_clocks_t p_clocks, int rank)
182 {
183 return sync_clocks_generic_get_skew(p_clocks, rank);
184 }
185
186 static inline double nm_sync_clocks_get_origin(nm_sync_clocks_t p_clocks)
187 {
188 return sync_clocks_generic_get_origin(p_clocks);
189 }
190
191#ifdef __cplusplus
192}
193#endif
194
195#endif /* NM_SYNC_CLOCKS_H */
void nm_coll_gather(nm_comm_t comm, int root, const void *sbuf, nm_len_t slen, void *rbuf, nm_len_t rlen, nm_tag_t tag)
void nm_coll_barrier(nm_comm_t comm, nm_tag_t tag)
void nm_coll_bcast(nm_comm_t comm, int root, void *buffer, nm_len_t len, nm_tag_t tag)
void nm_comm_destroy(nm_comm_t p_comm)
destroy a communicator- no synchronization is done
nm_comm_t nm_comm_dup(nm_comm_t comm)
get a duplicate of the given communicator- collective on parent communicator
static int nm_comm_rank(nm_comm_t p_comm)
static nm_gate_t nm_comm_get_gate(nm_comm_t p_comm, int rank)
static int nm_comm_size(nm_comm_t p_comm)
static nm_session_t nm_comm_get_session(nm_comm_t p_comm)
nm_tag_t tag
the user-supplied tag
static nm_comm_t p_comm
static nm_session_t p_session
static nm_gate_t p_gate
int root
nm_len_t size
size of the onsided data (not incuding target-side completion)
static int nm_sr_recv(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, void *data, nm_len_t len)
blocking recv
static int nm_sr_send(nm_session_t p_session, nm_gate_t p_gate, nm_tag_t tag, const void *data, nm_len_t len)
blocking send
static void nm_sync_clocks_send(nm_sync_clocks_t p_clocks, int dest, int tag, void *p_data, int size)
static double nm_sync_clocks_global_to_local(nm_sync_clocks_t p_clocks, double global_time)
get local time for the given global time
static void nm_sync_clocks_shutdown(nm_sync_clocks_t p_clocks)
destroy the given clock
static double nm_sync_clocks_add_real_origin_usec(nm_sync_clocks_t p_clocks, double t)
static void nm_sync_clocks_nm_barrier(nm_sync_clocks_t p_clocks)
static void nm_sync_clocks_recv(nm_sync_clocks_t p_clocks, int from, int tag, void *p_data, int size)
static double nm_sync_clocks_remote_to_global(nm_sync_clocks_t p_clocks, int rank, double t)
get global clock (in usec.) from remote local clock
static void nm_sync_clocks_bcast(nm_sync_clocks_t p_clocks, int root, int tag, void *p_data, int size)
static double nm_sync_clocks_local_to_global(nm_sync_clocks_t p_clocks, double local_t)
compute global time for the given local time
static nm_sync_clocks_t nm_sync_clocks_init(nm_comm_t p_comm)
struct sync_clocks_generic_s * nm_sync_clocks_t
an opaque sync-clocks object
static long double nm_sync_clocks_get_skew(nm_sync_clocks_t p_clocks, int rank)
get the clock skew between master and given rank
static void nm_sync_clocks_synchronize(nm_sync_clocks_t p_clocks)
synchronize time offsets between nodes; collective operation on communicator
static double nm_sync_clocks_get_origin(nm_sync_clocks_t p_clocks)
get the real time origin
static double nm_sync_clocks_get_time_usec(nm_sync_clocks_t p_clocks)
get local time, in usec.
static void nm_sync_clocks_gather(nm_sync_clocks_t p_clocks, int root, int tag, void *p_sbuf, int size, void *p_rbuf)
static int nm_sync_clocks_barrier(nm_sync_clocks_t p_clocks, double *barrier_local_time)
a barrier that unlocks all node at the same time as much as possible parameter barrier_local_time wil...
uint64_t nm_tag_t
user tags, 64 bits, contained in indirect hashtable
Definition nm_types.h:56
Connection to another process.
Definition nm_gate.h:104