comparison probes.h @ 50:8f7141a9272e

Added VMS__malloc and probes, and major re-factoring to separate mallocs
author Me
date Sat, 30 Oct 2010 20:54:36 -0700
parents
children f59cfa31a579
comparison
equal deleted inserted replaced
-1:000000000000 0:a375da5a9992
1 /*
2 * Copyright 2009 OpenSourceStewardshipFoundation.org
3 * Licensed under GNU General Public License version 2
4 *
5 * Author: seanhalle@yahoo.com
6 *
7 */
8
9 #ifndef _PROBES_H
10 #define _PROBES_H
11 #define __USE_GNU
12
13 #include "VMS_primitive_data_types.h"
14
15 #include <sys/time.h>
16
17 //turns on the probe-instrumentation in the application -- when not
18 // defined, the calls to the probe functions turn into comments
19 //#define STATS__ENABLE_PROBES
20
21 //when STATS__TURN_ON_PROBES is defined allows using probes to measure
22 // time intervals. The probes are macros that only compile to something
23 // when STATS__TURN_ON_PROBES is defined. The probes are saved in the
24 // master env -- but only when this is defined.
25 //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday
26 #define STATS__TURN_ON_PROBES
27 //#define STATS__USE_TSC_PROBES
28 #define STATS__USE_DBL_PROBES
29
30 //typedef struct _IntervalProbe IntervalProbe; //in VMS.h
31
32 struct _IntervalProbe
33 {
34 char *nameStr;
35 int32 probeID;
36
37 int32 schedChoiceWasRecorded;
38 int32 coreNum;
39 int32 procrID;
40 float64 procrCreateSecs;
41
42 #ifdef STATS__USE_TSC_PROBES
43 TSCount startStamp;
44 TSCount endStamp;
45 #else
46 struct timeval startStamp;
47 struct timeval endStamp;
48 #endif
49 float64 startSecs;
50 float64 endSecs;
51 float64 interval;
52 DblHist *hist;//if NULL, then is single interval probe
53 };
54
55
56 //============================= Statistics ==================================
57
58 //Frequency of TS counts
59 //TODO: change freq for each machine
60 #define TSCOUNT_FREQ 3180000000
61
62 inline TSCount getTSCount();
63
64
65 //======================== Probes =============================
66 //
67 // Use macros to allow turning probes off with a #define switch
68 #ifdef STATS__ENABLE_PROBES
69 int32
70 VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr);
71 #define VMS__record_time_point_into_new_probe( nameStr, animPr ) \
72 VMS_impl__record_time_point_in_new_probe( nameStr, animPr )
73
74 int32
75 VMS_ext_impl__record_time_point_into_new_probe( char *nameStr, VirtProcr *animPr);
76 #define VMS_ext__record_time_point_into_new_probe( nameStr ) \
77 VMS_ext_impl__record_time_point_into_new_probe_impl( nameStr )
78
79
80 int32
81 VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr );
82 #define VMS__create_single_interval_probe( nameStr, animPr ) \
83 VMS_impl__create_single_interval_probe( nameStr, animPr )
84
85
86 int32
87 VMS_impl__create_histogram_probe( int32 numBins, float64 startValue,
88 float64 binWidth, char *nameStr, VirtProcr *animPr );
89 #define VMS__create_histogram_probe( numBins, startValue, \
90 binWidth, nameStr, animPr ) \
91 VMS_impl__create_histogram_probe( numBins, startValue, \
92 binWidth, nameStr, animPr )
93
94 void
95 VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr );
96 #define VMS__index_probe_by_its_name( probeID, animPr ) \
97 VMS_impl__index_probe_by_its_name( probeID, animPr )
98
99 IntervalProbe *
100 VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr );
101 #define VMS__get_probe_by_name( probeID, animPr ) \
102 VMS_impl__get_probe_by_name( probeName, animPr )
103
104 void
105 VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr );
106 #define VMS__record_sched_choice_into_probe( probeID, animPr ) \
107 VMS_impl__record_sched_choice_into_probe( probeID, animPr )
108
109 void
110 VMS_impl__record_interval_start_in_probe( int32 probeID );
111 #define VMS__record_interval_start_in_probe( probeID ) \
112 VMS_impl__record_interval_start_in_probe( probeID )
113
114 void
115 VMS_impl__record_interval_end_in_probe( int32 probeID );
116 #define VMS__record_interval_end_in_probe( probeID ) \
117 VMS_impl__record_interval_end_in_probe( probeID )
118
119 void
120 VMS_impl__print_stats_of_probe( int32 probeID );
121 #define VMS__print_stats_of_probe( probeID ) \
122 VMS_impl__print_stats_of_probe( probeID )
123
124 void
125 VMS_impl__print_stats_of_all_probes();
126 #define VMS__print_stats_of_all_probes \
127 VMS_impl__print_stats_of_all_probes
128
129
130 #else
131 int32
132 VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr);
133 #define VMS__record_time_point_into_new_probe( nameStr, animPr ) \
134 0 /* do nothing */
135
136 int32
137 VMS_ext_impl__record_time_point_into_new_probe( char *nameStr, VirtProcr *animPr);
138 #define VMS_ext__record_time_point_into_new_probe( nameStr ) \
139 0 /* do nothing */
140
141
142 int32
143 VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr );
144 #define VMS__create_single_interval_probe( nameStr, animPr ) \
145 0 /* do nothing */
146
147
148 int32
149 VMS_impl__create_histogram_probe( int32 numBins, float64 startValue,
150 float64 binWidth, char *nameStr, VirtProcr *animPr );
151 #define VMS__create_histogram_probe( numBins, startValue, \
152 binWidth, nameStr, animPr ) \
153 0 /* do nothing */
154
155 void
156 VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr );
157 #define VMS__index_probe_by_its_name( probeID, animPr ) \
158 /* do nothing */
159
160 IntervalProbe *
161 VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr );
162 #define VMS__get_probe_by_name( probeID, animPr ) \
163 NULL /* do nothing */
164
165 void
166 VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr );
167 #define VMS__record_sched_choice_into_probe( probeID, animPr ) \
168 /* do nothing */
169
170 void
171 VMS_impl__record_interval_start_in_probe( int32 probeID );
172 #define VMS__record_interval_start_in_probe( probeID ) \
173 /* do nothing */
174
175 void
176 VMS_impl__record_interval_end_in_probe( int32 probeID );
177 #define VMS__record_interval_end_in_probe( probeID ) \
178 /* do nothing */
179
180 void
181 VMS_impl__print_stats_of_probe( int32 probeID );
182 #define VMS__print_stats_of_probe( probeID ) \
183 /* do nothing */
184
185 void
186 VMS_impl__print_stats_of_all_probes();
187 #define VMS__print_stats_of_all_probes \
188 /* do nothing */
189
190 #endif /* defined STATS__ENABLE_PROBES */
191
192 #endif /* _PROBES_H */
193