1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
|
/*@@
@file Registration.c
@date Sat Oct 8 19:29:25 CDT 2005
@author Dylan Stark (TommyD)
@desc
Allows registration of topology and
physical to logical processor mapping routines.
Mostly taken from work done by Thomas Dramlitsch.
@enddesc
@version $Header$
@@*/
#include <stdio.h>
#include <stdlib.h>
#include "cctk.h"
#include "cctk_Parameters.h"
#include "Register.h"
static const char *rcsid = "$Header$";
CCTK_FILEVERSION(CactusPUGH_PUGH_Registerables_c)
/********************************************************************
********************* Macro Definitions **************************
********************************************************************/
/********************************************************************
********************* Local Data Types ***************************
********************************************************************/
/********************************************************************
********************* Aliased Routine Prototypes *****************
********************************************************************/
/********************************************************************
********************* Scheduled Routine Prototypes ***************
********************************************************************/
/********************************************************************
********************* Fortran Wrapper Prototypes *****************
********************************************************************/
/********************************************************************
********************* Local Routine Prototypes *******************
********************************************************************/
static int GenerateTopologyUnavailable(int dim,
int total_procs,
const int *nsize,
const int *nghostzones,
int *nprocs);
static void *CreateP2LTranslationUnavailable(int dim,
int *nprocs,
int np);
static int DestroyP2LTranslationUnavailable(void *table);
static int PhysicalToLogicalUnavailable (void *table, int proc);
static int LogicalToPhysicalUnavailable(void *table, int num);
/********************************************************************
********************* Local Data *********************************
********************************************************************/
int (*PUGH_GenerateTopology) (int dim,
int total_procs,
const int *nsize,
const int *nghostzones,
int *nprocs) = GenerateTopologyUnavailable;
void *(*PUGHi_CreateP2LTranslation) (int dim,
int *nprocs,
int np) = CreateP2LTranslationUnavailable;
int (*PUGHi_DestroyP2LTranslation) (void *table) = DestroyP2LTranslationUnavailable;
int (*PUGHi_PhysicalToLogical) (void *table, int proc) = PhysicalToLogicalUnavailable;
int (*PUGHi_LogicalToPhysical) (void *table, int num) = LogicalToPhysicalUnavailable;
/********************************************************************
************************ External Routines ********************
********************************************************************/
/* Registration routines */
/*@@
@routine PUGH_RegisterGenerateTopology
@date Sat Oct 8 19:29:25 CDT 2005
@author Dylan Stark (Thomas Dramlitsch)
@desc
Registration routine for topology generators.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
int PUGH_RegisterGenerateTopology(int (*GenerateTopology) (int dim,
int total_procs,
const int *nsize,
const int *nghostzones,
int *nprocs),
const char *topologyname)
{
DECLARE_CCTK_PARAMETERS;
if (CCTK_Equals(processor_topology, topologyname))
{
if (PUGH_GenerateTopology != GenerateTopologyUnavailable)
{
CCTK_VWarn(0,__LINE__,__FILE__,CCTK_THORNSTRING,
"Attempted to register topology generator %s more than once!",
topologyname);
}
else
{
PUGH_GenerateTopology = GenerateTopology;
CCTK_VInfo(CCTK_THORNSTRING, "Using topology generator: %s",
topologyname);
}
}
return 0;
}
/*@@
@routine PUGH_RegisterP2L
@date Sat Oct 8 19:29:25 CDT 2005
@author Dylan Stark (Thomas Dramlitsch)
@desc
Registration routine for physical to logical processor mappings.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
int PUGH_RegisterP2L(void *(*CreateP2LTranslation) (int dim,
int *nprocs,
int np),
int (*DestroyP2LTranslation) (void *table),
int (*PhysicalToLogical) (void *table,
int proc),
int (*LogicalToPhysical) (void *table,
int num),
const char *p2lname)
{
DECLARE_CCTK_PARAMETERS;
if (CCTK_Equals(physical2logical, p2lname))
{
if (PUGHi_CreateP2LTranslation != CreateP2LTranslationUnavailable)
{
CCTK_VWarn(0, __LINE__,__FILE__,CCTK_THORNSTRING,
"Attempted to register P2L methods %s more than once!",
physical2logical);
}
else
{
PUGHi_CreateP2LTranslation = CreateP2LTranslation;
PUGHi_DestroyP2LTranslation = DestroyP2LTranslation;
PUGHi_PhysicalToLogical = PhysicalToLogical;
PUGHi_LogicalToPhysical = LogicalToPhysical;
CCTK_VInfo(CCTK_THORNSTRING, "Using physical to logical mappings: %s",
p2lname);
}
}
return 0;
}
/********************************************************************
********************* Local Routines *****************************
********************************************************************/
/*@@
@routine GenerateTopologyUnavailable
@date Wed Dec 14 21:14:55 2005
@author Tom Goodale
@desc
Generates an error if the routine has not been registered.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
static int GenerateTopologyUnavailable(int dim,
int total_procs,
const int *nsize,
const int *nghostzones,
int *nprocs)
{
DECLARE_CCTK_PARAMETERS;
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"No processor topology routine registered under the name '%s'"
" set in the processor_topology parameter.",
processor_topology);
return 0;
}
/*@@
@routine CreateP2LTranslationUnavailable
@date Wed Dec 14 21:14:55 2005
@author Tom Goodale
@desc
Generates an error if the routine has not been registered.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
static void *CreateP2LTranslationUnavailable(int dim,
int *nprocs,
int np)
{
DECLARE_CCTK_PARAMETERS;
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"No physical to logical mapping routine registered under the name '%s'"
" set in the physical2logical parameter.",
physical2logical);
return 0;
}
/*@@
@routine DestroyP2LTranslationUnavailable
@date Wed Dec 14 21:14:55 2005
@author Tom Goodale
@desc
Generates an error if the routine has not been registered.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
static int DestroyP2LTranslationUnavailable(void *table)
{
DECLARE_CCTK_PARAMETERS;
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"No physical to logical mapping routine registered under the name '%s'"
" set in the physical2logical parameter.",
physical2logical);
return 0;
}
/*@@
@routine PhysicalToLogicalUnavailable
@date Wed Dec 14 21:14:55 2005
@author Tom Goodale
@desc
Generates an error if the routine has not been registered.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
static int PhysicalToLogicalUnavailable (void *table, int proc)
{
DECLARE_CCTK_PARAMETERS;
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"No physical to logical mapping routine registered under the name '%s'"
" set in the physical2logical parameter.",
physical2logical);
return 0;
}
/*@@
@routine LogicalToPhysicalUnavailable
@date Wed Dec 14 21:14:55 2005
@author Tom Goodale
@desc
Generates an error if the routine has not been registered.
@enddesc
@calls
@calledby
@history
@endhistory
@@*/
static int LogicalToPhysicalUnavailable(void *table, int num)
{
DECLARE_CCTK_PARAMETERS;
CCTK_VWarn (0, __LINE__, __FILE__, CCTK_THORNSTRING,
"No physical to logical mapping routine registered under the name '%s'"
" set in the physical2logical parameter.",
physical2logical);
return 0;
}
|