File: pomp_lib.c

package info (click to toggle)
opari 1.1%2Bdfsg-7
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 728 kB
  • sloc: cpp: 2,005; ansic: 901; f90: 252; makefile: 128; sh: 86; fortran: 50
file content (323 lines) | stat: -rw-r--r-- 7,623 bytes parent folder | download | duplicates (5)
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
313
314
315
316
317
318
319
320
321
322
323
/*************************************************************************/
/* OPARI Version 1.1                                                     */
/* Copyright (C) 2001                                                    */
/* Forschungszentrum Juelich, Zentralinstitut fuer Angewandte Mathematik */
/*************************************************************************/

#include <stdio.h>
#include <stdlib.h>

#include "pomp_lib.h"

/*
 * Global variables
 */

int pomp_tracing = 0;

/*
 * C pomp function library
 */

void pomp_finalize() {
  static int pomp_finalize_called = 0;

  if ( ! pomp_finalize_called ) {
    pomp_finalize_called = 1;

    fprintf(stderr, "  0: finalize\n");
  }
}

void pomp_init() {
  int i;
  static int pomp_init_called = 0;

  if ( ! pomp_init_called ) {
    pomp_init_called = 1;

    atexit(pomp_finalize);
    fprintf(stderr, "  0: init\n");

    for(i=0; i<POMP_MAX_ID; ++i) {
      if ( pomp_rd_table[i] ) {
        pomp_rd_table[i]->data = 0;   /* <-- allocate space for
					     performance data here */
      }
    }
    pomp_tracing = 1;
  }
}

void pomp_off() {
  pomp_tracing = 0;
}

void pomp_on() {
  pomp_tracing = 1;
}

void pomp_atomic_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter atomic\n", omp_get_thread_num());
  }
}

void pomp_atomic_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  atomic\n", omp_get_thread_num());
  }
}

void pomp_barrier_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    if ( r->name[0] == 'b' )
      fprintf(stderr, "%3d: enter barrier\n", omp_get_thread_num());
    else
      fprintf(stderr, "%3d: enter implicit barrier of %s\n",
	      omp_get_thread_num(), r->name);
  }
}

void pomp_barrier_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    if ( r->name[0] == 'b' )
      fprintf(stderr, "%3d: exit  barrier\n", omp_get_thread_num());
    else
      fprintf(stderr, "%3d: exit  implicit barrier of %s\n",
	      omp_get_thread_num(), r->name);
  }
}

void pomp_flush_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter flush\n", omp_get_thread_num());
  }
}

void pomp_flush_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  flush\n", omp_get_thread_num());
  }
}

void pomp_critical_begin(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: begin critical %s\n",
            omp_get_thread_num(), r->sub_name);
  }
}

void pomp_critical_end(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: end   critical %s\n",
            omp_get_thread_num(), r->sub_name);
  }
}

void pomp_critical_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter critical %s\n",
            omp_get_thread_num(), r->sub_name);
  }
}

void pomp_critical_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  critical %s\n",
            omp_get_thread_num(), r->sub_name);
  }
}

void pomp_for_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter for\n", omp_get_thread_num());
  }
}

void pomp_for_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  for\n", omp_get_thread_num());
  }
}

void pomp_master_begin(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: begin master\n", omp_get_thread_num());
  }
}

void pomp_master_end(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: end   master\n", omp_get_thread_num());
  }
}

void pomp_parallel_begin(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: begin parallel\n", omp_get_thread_num());
  }
}

void pomp_parallel_end(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: end   parallel\n", omp_get_thread_num());
  }
}

void pomp_parallel_fork(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: fork  parallel\n", omp_get_thread_num());
  }
}

void pomp_parallel_join(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: join  parallel\n", omp_get_thread_num());
  }
}

void pomp_section_begin(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: begin section\n", omp_get_thread_num());
  }
}

void pomp_section_end(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: end   section\n", omp_get_thread_num());
  }
}

void pomp_sections_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter sections\n", omp_get_thread_num());
  }
}

void pomp_sections_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  sections\n", omp_get_thread_num());
  }
}

void pomp_single_begin(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: begin single\n", omp_get_thread_num());
  }
}

void pomp_single_end(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: end   single\n", omp_get_thread_num());
  }
}

void pomp_single_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter single\n", omp_get_thread_num());
  }
}

void pomp_single_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  single\n", omp_get_thread_num());
  }
}

void pomp_workshare_enter(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: enter workshare\n", omp_get_thread_num());
  }
}

void pomp_workshare_exit(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: exit  workshare\n", omp_get_thread_num());
  }
}

void pomp_begin(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: begin region %s\n",
            omp_get_thread_num(), r->sub_name);
  }
}

void pomp_end(struct ompregdescr* r) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: end   region %s\n",
            omp_get_thread_num(), r->sub_name);
  }
}

void pomp_init_lock(omp_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: init lock\n", omp_get_thread_num());
  }
  omp_init_lock(s);
}

void pomp_destroy_lock(omp_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: destroy lock\n", omp_get_thread_num());
  }
  omp_destroy_lock(s);
}

void pomp_set_lock(omp_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: set lock\n", omp_get_thread_num());
  }
  omp_set_lock(s);
}

void pomp_unset_lock(omp_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: unset lock\n", omp_get_thread_num());
  }
  omp_unset_lock(s);
}

int  pomp_test_lock(omp_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: test lock\n", omp_get_thread_num());
  }
  return omp_test_lock(s);
}

void pomp_init_nest_lock(omp_nest_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: init nestlock\n", omp_get_thread_num());
  }
  omp_init_nest_lock(s);
}

void pomp_destroy_nest_lock(omp_nest_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: destroy nestlock\n", omp_get_thread_num());
  }
  omp_destroy_nest_lock(s);
}

void pomp_set_nest_lock(omp_nest_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: set nestlock\n", omp_get_thread_num());
  }
  omp_set_nest_lock(s);
}

void pomp_unset_nest_lock(omp_nest_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: unset nestlock\n", omp_get_thread_num());
  }
  omp_unset_nest_lock(s);
}

int  pomp_test_nest_lock(omp_nest_lock_t *s) {
  if ( pomp_tracing ) {
    fprintf(stderr, "%3d: test nestlock\n", omp_get_thread_num());
  }
  return omp_test_nest_lock(s);
}