PIO  1.7.1
 All Classes Files Functions Groups Pages
private.h
1 /*
2 ** $Id: private.h,v 1.74 2011-03-28 20:55:19 rosinski Exp $
3 **
4 ** Author: Jim Rosinski
5 **
6 ** Contains definitions private to GPTL and inaccessible to invoking user environment
7 */
8 
9 #include <stdio.h>
10 #include <sys/time.h>
11 
12 #ifndef NO_COMM_F2C
13 #define HAVE_COMM_F2C
14 #endif
15 
16 #ifndef MIN
17 #define MIN(X,Y) ((X) < (Y) ? (X) : (Y))
18 #endif
19 
20 #ifndef MAX
21 #define MAX(X,Y) ((X) > (Y) ? (X) : (Y))
22 #endif
23 
24 #define STRMATCH(X,Y) (strcmp((X),(Y)) == 0)
25 
26 /* Output counts less than PRTHRESH will be printed as integers */
27 #define PRTHRESH 1000000L
28 
29 /* Maximum allowed callstack depth */
30 #define MAX_STACK 128
31 
32 /* longest timer name allowed (probably safe to just change) */
33 #define MAX_CHARS 63
34 
35 /*
36 ** max allowable number of PAPI counters, or derived events. For convenience,
37 ** set to max (# derived events, # papi counters required) so "avail" lists
38 ** all available options.
39 */
40 #define MAX_AUX 9
41 
42 #ifndef __cplusplus
43 typedef enum {false = 0, true = 1} bool; /* mimic C++ */
44 #endif
45 
46 typedef struct {
47  long last_utime; /* saved usr time from "start" */
48  long last_stime; /* saved sys time from "start" */
49  long accum_utime; /* accumulator for usr time */
50  long accum_stime; /* accumulator for sys time */
51 } Cpustats;
52 
53 typedef struct {
54  double last; /* timestamp from last call */
55  double accum; /* accumulated time */
56  float max; /* longest time for start/stop pair */
57  float min; /* shortest time for start/stop pair */
58 } Wallstats;
59 
60 typedef struct {
61  long long last[MAX_AUX]; /* array of saved counters from "start" */
62  long long accum[MAX_AUX]; /* accumulator for counters */
63 } Papistats;
64 
65 typedef struct {
66  int counter; /* PAPI or Derived counter */
67  char *namestr; /* PAPI or Derived counter as string */
68  char *str8; /* print string for output timers (8 chars) */
69  char *str16; /* print string for output timers (16 chars) */
70  char *longstr; /* long descriptive print string */
71 } Entry;
72 
73 typedef struct {
74  Entry event;
75  int numidx; /* derived event: PAPI counter array index for numerator */
76  int denomidx; /* derived event: PAPI counter array index for denominator */
77 } Pr_event;
78 
79 typedef struct TIMER {
80  char name[MAX_CHARS+1]; /* timer name (user input) */
81  bool onflg; /* timer currently on or off */
82 #ifdef ENABLE_PMPI
83  double nbytes; /* number of bytes for MPI call */
84 #endif
85 #ifdef HAVE_PAPI
86  Papistats aux; /* PAPI stats */
87 #endif
88  Wallstats wall; /* wallclock stats */
89  Cpustats cpu; /* cpu stats */
90  unsigned long count; /* number of start/stop calls */
91  unsigned long nrecurse; /* number of recursive start/stop calls */
92  void *address; /* address of timer: used only by _instr routines */
93  struct TIMER *next; /* next timer in linked list */
94  struct TIMER **parent; /* array of parents */
95  struct TIMER **children; /* array of children */
96  int *parent_count; /* array of call counts, one for each parent */
97  unsigned int recurselvl; /* recursion level */
98  unsigned int nchildren; /* number of children */
99  unsigned int nparent; /* number of parents */
100  unsigned int norphan; /* number of times this timer was an orphan */
101  int num_desc; /* number of descendants */
102 } Timer;
103 
104 typedef struct {
105  Timer **entries; /* array of timers hashed to the same value */
106  unsigned int nument; /* number of entries hashed to the same value */
107 } Hashentry;
108 
109 /* Function prototypes */
110 
111 extern int GPTLerror (const char *, ...); /* print error msg and return */
112 extern void GPTLset_abort_on_error (bool val); /* set flag to abort on error */
113 extern void *GPTLallocate (const int); /* malloc wrapper */
114 
115 extern int GPTLstart_instr (void *); /* auto-instrumented start */
116 extern int GPTLstop_instr (void *); /* auto-instrumented stop */
117 extern int GPTLis_initialized (void); /* needed by MPI_Init wrapper */
118 
119 #ifdef __cplusplus
120 extern "C" {
121 #endif
122 
123 extern void __cyg_profile_func_enter (void *, void *);
124 extern void __cyg_profile_func_exit (void *, void *);
125 
126 #ifdef __cplusplus
127 };
128 #endif
129 
130 /*
131 ** These are needed for communication between gptl.c and gptl_papi.c
132 */
133 
134 #ifdef HAVE_PAPI
135 extern int GPTL_PAPIsetoption (const int, const int);
136 extern int GPTL_PAPIinitialize (const int, const bool, int *, Entry *);
137 extern int GPTL_PAPIstart (const int, Papistats *);
138 extern int GPTL_PAPIstop (const int, Papistats *);
139 extern void GPTL_PAPIprstr (FILE *);
140 extern void GPTL_PAPIpr (FILE *, const Papistats *, const int, const int, const double);
141 extern void GPTL_PAPIadd (Papistats *, const Papistats *);
142 extern void GPTL_PAPIfinalize (int);
143 extern void GPTL_PAPIquery (const Papistats *, long long *, int);
144 extern int GPTL_PAPIget_eventvalue (const char *, const Papistats *, double *);
145 extern bool GPTL_PAPIis_multiplexed (void);
146 extern void GPTL_PAPIprintenabled (FILE *);
147 extern void read_counters100 (void);
148 extern int GPTLget_npapievents (void);
149 extern int GPTLcreate_and_start_events (const int);
150 #endif
151 
152 #ifdef ENABLE_PMPI
153 extern Timer *GPTLgetentry (const char *);
154 extern int GPTLpmpi_setoption (const int, const int);
155 extern int GPTLpr_has_been_called (void); /* needed by MPI_Finalize wrapper*/
156 #endif