Now fails if nested calls.
[charm.git] / examples / bigsim / tools / rewritelog / traceBigSim / traceBigSim.C
1 #include "charm++.h"
2 #include "traceBigSim.h"
3
4 CkpvDeclare(FILE*, bgfp);
5 CkpvDeclare(unsigned long, bgTraceCounter);
6
7
8 CkpvDeclare(bool, insideTraceBracket);
9
10 void initBigSimTrace()
11 {
12   CkpvInitialize(FILE *, bgfp);
13   CkpvInitialize(bool, insideTraceBracket);
14   CkpvInitialize(unsigned long, bgTraceCounter);
15   CkpvAccess(bgTraceCounter) = 0;
16   CkpvAccess(insideTraceBracket) = false;
17
18 #ifdef CMK_BLUEGENE_CHARM
19   //   for bigsim emulation, write to files, one for each processor
20   char fname[128];
21   sprintf(fname, "param.%d", CkMyPe());
22   CkpvAccess(bgfp) = fopen(fname, "w");
23   if (CkpvAccess(bgfp) == NULL) 
24     CmiAbort("Failed to generated trace param file!");
25 #else
26   //   for Mambo simulation, write to screen for now
27   CkpvAccess(bgfp) = stdout;
28 #endif
29
30
31
32
33 #ifdef BIG_SIM_PAPI
34         CkPrintf("PAPI: number of available counters: %d\n", PAPI_num_counters());
35         CkAssert(PAPI_num_counters() >= 0);
36 #endif
37
38 }
39
40 void finalizeBigSimTrace()
41 {
42 #ifdef CMK_BLUEGENE_CHARM
43   fclose(CkpvAccess(bgfp));
44 #endif  
45 }