diff probes.h @ 146:a49f02980151

fixed: hist index error, zero devision
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 12 May 2011 14:23:41 +0200
parents 13b22ffb8a2f
children c11b9dcf6d24
line diff
     1.1 --- a/probes.h	Sat Nov 20 08:19:05 2010 +0100
     1.2 +++ b/probes.h	Thu May 12 14:23:41 2011 +0200
     1.3 @@ -1,195 +1,195 @@
     1.4 -/*
     1.5 - *  Copyright 2009 OpenSourceStewardshipFoundation.org
     1.6 - *  Licensed under GNU General Public License version 2
     1.7 - *
     1.8 - * Author: seanhalle@yahoo.com
     1.9 - * 
    1.10 - */
    1.11 -
    1.12 -#ifndef _PROBES_H
    1.13 -#define	_PROBES_H
    1.14 -#define __USE_GNU
    1.15 -
    1.16 -#include "VMS_primitive_data_types.h"
    1.17 -
    1.18 -#include <sys/time.h>
    1.19 -
    1.20 -
    1.21 -   //when STATS__TURN_ON_PROBES is defined allows using probes to measure
    1.22 -   // time intervals.  The probes are macros that only compile to something
    1.23 -   // when STATS__TURN_ON_PROBES is defined.  The probes are saved in the
    1.24 -   // master env -- but only when this is defined.
    1.25 -   //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday
    1.26 -#define STATS__TURN_ON_PROBES
    1.27 -//#define STATS__USE_TSC_PROBES
    1.28 -#define STATS__USE_DBL_PROBES
    1.29 -
    1.30 -//typedef struct _IntervalProbe IntervalProbe; //in VMS.h
    1.31 -
    1.32 -struct _IntervalProbe
    1.33 - {
    1.34 -   char           *nameStr;
    1.35 -   int32           probeID;
    1.36 -
    1.37 -   int32           schedChoiceWasRecorded;
    1.38 -   int32           coreNum;
    1.39 -   int32           procrID;
    1.40 -   float64         procrCreateSecs;
    1.41 -
    1.42 -   #ifdef STATS__USE_TSC_PROBES
    1.43 -   TSCount    startStamp;
    1.44 -   TSCount    endStamp;
    1.45 -   #else
    1.46 -   struct timeval  startStamp;
    1.47 -   struct timeval  endStamp;
    1.48 -   #endif
    1.49 -   float64         startSecs;
    1.50 -   float64         endSecs;
    1.51 -   float64         interval;
    1.52 -   DblHist        *hist;//if NULL, then is single interval probe
    1.53 - };
    1.54 -
    1.55 -
    1.56 -//============================= Statistics ==================================
    1.57 -
    1.58 -   //Frequency of TS counts
    1.59 -   //TODO: change freq for each machine
    1.60 -#define TSCOUNT_FREQ 3180000000
    1.61 -
    1.62 -inline TSCount getTSCount();
    1.63 -
    1.64 -
    1.65 -//======================== Probes =============================
    1.66 -//
    1.67 -// Use macros to allow turning probes off with a #define switch
    1.68 -#ifdef STATS__ENABLE_PROBES
    1.69 -int32
    1.70 -VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr);
    1.71 -#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \
    1.72 -        VMS_impl__record_time_point_in_new_probe( nameStr, animPr )
    1.73 -
    1.74 -int32
    1.75 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr );
    1.76 -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \
    1.77 -        VMS_ext_impl__record_time_point_into_new_probe( nameStr )
    1.78 -
    1.79 -
    1.80 -int32
    1.81 -VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr );
    1.82 -#define VMS__create_single_interval_probe( nameStr, animPr ) \
    1.83 -        VMS_impl__create_single_interval_probe( nameStr, animPr )
    1.84 -
    1.85 -
    1.86 -int32
    1.87 -VMS_impl__create_histogram_probe( int32   numBins, float64    startValue,
    1.88 -               float64 binWidth, char    *nameStr, VirtProcr *animPr );
    1.89 -#define VMS__create_histogram_probe(      numBins, startValue,              \
    1.90 -                                          binWidth, nameStr, animPr )       \
    1.91 -        VMS_impl__create_histogram_probe( numBins, startValue,              \
    1.92 -                                          binWidth, nameStr, animPr )
    1.93 -void
    1.94 -VMS_impl__free_probe( IntervalProbe *probe );
    1.95 -#define VMS__free_probe( probe ) \
    1.96 -        VMS_impl__free_probe( probe )
    1.97 -
    1.98 -void
    1.99 -VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr );
   1.100 -#define VMS__index_probe_by_its_name( probeID, animPr ) \
   1.101 -        VMS_impl__index_probe_by_its_name( probeID, animPr )
   1.102 -
   1.103 -IntervalProbe *
   1.104 -VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr );
   1.105 -#define VMS__get_probe_by_name( probeID, animPr ) \
   1.106 -        VMS_impl__get_probe_by_name( probeName, animPr )
   1.107 -
   1.108 -void
   1.109 -VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr );
   1.110 -#define VMS__record_sched_choice_into_probe( probeID, animPr ) \
   1.111 -        VMS_impl__record_sched_choice_into_probe( probeID, animPr )
   1.112 -
   1.113 -void
   1.114 -VMS_impl__record_interval_start_in_probe( int32 probeID );
   1.115 -#define VMS__record_interval_start_in_probe( probeID ) \
   1.116 -        VMS_impl__record_interval_start_in_probe( probeID )
   1.117 -
   1.118 -void
   1.119 -VMS_impl__record_interval_end_in_probe( int32 probeID );
   1.120 -#define VMS__record_interval_end_in_probe( probeID ) \
   1.121 -        VMS_impl__record_interval_end_in_probe( probeID )
   1.122 -
   1.123 -void
   1.124 -VMS_impl__print_stats_of_probe( int32 probeID );
   1.125 -#define VMS__print_stats_of_probe( probeID ) \
   1.126 -        VMS_impl__print_stats_of_probe( probeID )
   1.127 -
   1.128 -void
   1.129 -VMS_impl__print_stats_of_all_probes();
   1.130 -#define VMS__print_stats_of_all_probes \
   1.131 -        VMS_impl__print_stats_of_all_probes
   1.132 -
   1.133 -
   1.134 -#else
   1.135 -int32
   1.136 -VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr);
   1.137 -#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \
   1.138 -       0 /* do nothing */
   1.139 -
   1.140 -int32
   1.141 -VMS_ext_impl__record_time_point_into_new_probe( char *nameStr );
   1.142 -#define VMS_ext__record_time_point_into_new_probe( nameStr ) \
   1.143 -       0 /* do nothing */
   1.144 -
   1.145 -
   1.146 -int32
   1.147 -VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr );
   1.148 -#define VMS__create_single_interval_probe( nameStr, animPr ) \
   1.149 -       0 /* do nothing */
   1.150 -
   1.151 -
   1.152 -int32
   1.153 -VMS_impl__create_histogram_probe( int32   numBins, float64    startValue,
   1.154 -               float64 binWidth, char    *nameStr, VirtProcr *animPr );
   1.155 -#define VMS__create_histogram_probe(      numBins, startValue,              \
   1.156 -                                          binWidth, nameStr, animPr )       \
   1.157 -       0 /* do nothing */
   1.158 -
   1.159 -void
   1.160 -VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr );
   1.161 -#define VMS__index_probe_by_its_name( probeID, animPr ) \
   1.162 -        /* do nothing */
   1.163 -
   1.164 -IntervalProbe *
   1.165 -VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr );
   1.166 -#define VMS__get_probe_by_name( probeID, animPr ) \
   1.167 -       NULL /* do nothing */
   1.168 -
   1.169 -void
   1.170 -VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr );
   1.171 -#define VMS__record_sched_choice_into_probe( probeID, animPr ) \
   1.172 -        /* do nothing */
   1.173 -
   1.174 -void
   1.175 -VMS_impl__record_interval_start_in_probe( int32 probeID );
   1.176 -#define VMS__record_interval_start_in_probe( probeID ) \
   1.177 -        /* do nothing */
   1.178 -
   1.179 -void
   1.180 -VMS_impl__record_interval_end_in_probe( int32 probeID );
   1.181 -#define VMS__record_interval_end_in_probe( probeID ) \
   1.182 -        /* do nothing */
   1.183 -
   1.184 -inline void doNothing();
   1.185 -void
   1.186 -VMS_impl__print_stats_of_probe( int32 probeID );
   1.187 -#define VMS__print_stats_of_probe( probeID ) \
   1.188 -        doNothing/* do nothing */
   1.189 -
   1.190 -void
   1.191 -VMS_impl__print_stats_of_all_probes();
   1.192 -#define VMS__print_stats_of_all_probes \
   1.193 -        doNothing/* do nothing */
   1.194 -
   1.195 -#endif   /* defined STATS__ENABLE_PROBES */
   1.196 -
   1.197 -#endif	/* _PROBES_H */
   1.198 -
   1.199 +/*
   1.200 + *  Copyright 2009 OpenSourceStewardshipFoundation.org
   1.201 + *  Licensed under GNU General Public License version 2
   1.202 + *
   1.203 + * Author: seanhalle@yahoo.com
   1.204 + * 
   1.205 + */
   1.206 +
   1.207 +#ifndef _PROBES_H
   1.208 +#define	_PROBES_H
   1.209 +#define __USE_GNU
   1.210 +
   1.211 +#include "VMS_primitive_data_types.h"
   1.212 +
   1.213 +#include <sys/time.h>
   1.214 +
   1.215 +
   1.216 +   //when STATS__TURN_ON_PROBES is defined allows using probes to measure
   1.217 +   // time intervals.  The probes are macros that only compile to something
   1.218 +   // when STATS__TURN_ON_PROBES is defined.  The probes are saved in the
   1.219 +   // master env -- but only when this is defined.
   1.220 +   //The TSC probes use RDTSC instr, can be unreliable, Dbl uses gettimeofday
   1.221 +#define STATS__TURN_ON_PROBES
   1.222 +//#define STATS__USE_TSC_PROBES
   1.223 +#define STATS__USE_DBL_PROBES
   1.224 +
   1.225 +//typedef struct _IntervalProbe IntervalProbe; //in VMS.h
   1.226 +
   1.227 +struct _IntervalProbe
   1.228 + {
   1.229 +   char           *nameStr;
   1.230 +   int32           probeID;
   1.231 +
   1.232 +   int32           schedChoiceWasRecorded;
   1.233 +   int32           coreNum;
   1.234 +   int32           procrID;
   1.235 +   float64         procrCreateSecs;
   1.236 +
   1.237 +   #ifdef STATS__USE_TSC_PROBES
   1.238 +   TSCount    startStamp;
   1.239 +   TSCount    endStamp;
   1.240 +   #else
   1.241 +   struct timeval  startStamp;
   1.242 +   struct timeval  endStamp;
   1.243 +   #endif
   1.244 +   float64         startSecs;
   1.245 +   float64         endSecs;
   1.246 +   float64         interval;
   1.247 +   DblHist        *hist;//if NULL, then is single interval probe
   1.248 + };
   1.249 +
   1.250 +
   1.251 +//============================= Statistics ==================================
   1.252 +
   1.253 +   //Frequency of TS counts
   1.254 +   //TODO: change freq for each machine
   1.255 +#define TSCOUNT_FREQ 3180000000
   1.256 +
   1.257 +inline TSCount getTSCount();
   1.258 +
   1.259 +
   1.260 +//======================== Probes =============================
   1.261 +//
   1.262 +// Use macros to allow turning probes off with a #define switch
   1.263 +#ifdef STATS__ENABLE_PROBES
   1.264 +int32
   1.265 +VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr);
   1.266 +#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \
   1.267 +        VMS_impl__record_time_point_in_new_probe( nameStr, animPr )
   1.268 +
   1.269 +int32
   1.270 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr );
   1.271 +#define VMS_ext__record_time_point_into_new_probe( nameStr ) \
   1.272 +        VMS_ext_impl__record_time_point_into_new_probe( nameStr )
   1.273 +
   1.274 +
   1.275 +int32
   1.276 +VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr );
   1.277 +#define VMS__create_single_interval_probe( nameStr, animPr ) \
   1.278 +        VMS_impl__create_single_interval_probe( nameStr, animPr )
   1.279 +
   1.280 +
   1.281 +int32
   1.282 +VMS_impl__create_histogram_probe( int32   numBins, float64    startValue,
   1.283 +               float64 binWidth, char    *nameStr, VirtProcr *animPr );
   1.284 +#define VMS__create_histogram_probe(      numBins, startValue,              \
   1.285 +                                          binWidth, nameStr, animPr )       \
   1.286 +        VMS_impl__create_histogram_probe( numBins, startValue,              \
   1.287 +                                          binWidth, nameStr, animPr )
   1.288 +void
   1.289 +VMS_impl__free_probe( IntervalProbe *probe );
   1.290 +#define VMS__free_probe( probe ) \
   1.291 +        VMS_impl__free_probe( probe )
   1.292 +
   1.293 +void
   1.294 +VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr );
   1.295 +#define VMS__index_probe_by_its_name( probeID, animPr ) \
   1.296 +        VMS_impl__index_probe_by_its_name( probeID, animPr )
   1.297 +
   1.298 +IntervalProbe *
   1.299 +VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr );
   1.300 +#define VMS__get_probe_by_name( probeID, animPr ) \
   1.301 +        VMS_impl__get_probe_by_name( probeName, animPr )
   1.302 +
   1.303 +void
   1.304 +VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr );
   1.305 +#define VMS__record_sched_choice_into_probe( probeID, animPr ) \
   1.306 +        VMS_impl__record_sched_choice_into_probe( probeID, animPr )
   1.307 +
   1.308 +void
   1.309 +VMS_impl__record_interval_start_in_probe( int32 probeID );
   1.310 +#define VMS__record_interval_start_in_probe( probeID ) \
   1.311 +        VMS_impl__record_interval_start_in_probe( probeID )
   1.312 +
   1.313 +void
   1.314 +VMS_impl__record_interval_end_in_probe( int32 probeID );
   1.315 +#define VMS__record_interval_end_in_probe( probeID ) \
   1.316 +        VMS_impl__record_interval_end_in_probe( probeID )
   1.317 +
   1.318 +void
   1.319 +VMS_impl__print_stats_of_probe( int32 probeID );
   1.320 +#define VMS__print_stats_of_probe( probeID ) \
   1.321 +        VMS_impl__print_stats_of_probe( probeID )
   1.322 +
   1.323 +void
   1.324 +VMS_impl__print_stats_of_all_probes();
   1.325 +#define VMS__print_stats_of_all_probes \
   1.326 +        VMS_impl__print_stats_of_all_probes
   1.327 +
   1.328 +
   1.329 +#else
   1.330 +int32
   1.331 +VMS_impl__record_time_point_into_new_probe( char *nameStr,VirtProcr *animPr);
   1.332 +#define VMS__record_time_point_into_new_probe( nameStr, animPr ) \
   1.333 +       0 /* do nothing */
   1.334 +
   1.335 +int32
   1.336 +VMS_ext_impl__record_time_point_into_new_probe( char *nameStr );
   1.337 +#define VMS_ext__record_time_point_into_new_probe( nameStr ) \
   1.338 +       0 /* do nothing */
   1.339 +
   1.340 +
   1.341 +int32
   1.342 +VMS_impl__create_single_interval_probe( char *nameStr, VirtProcr *animPr );
   1.343 +#define VMS__create_single_interval_probe( nameStr, animPr ) \
   1.344 +       0 /* do nothing */
   1.345 +
   1.346 +
   1.347 +int32
   1.348 +VMS_impl__create_histogram_probe( int32   numBins, float64    startValue,
   1.349 +               float64 binWidth, char    *nameStr, VirtProcr *animPr );
   1.350 +#define VMS__create_histogram_probe(      numBins, startValue,              \
   1.351 +                                          binWidth, nameStr, animPr )       \
   1.352 +       0 /* do nothing */
   1.353 +
   1.354 +void
   1.355 +VMS_impl__index_probe_by_its_name( int32 probeID, VirtProcr *animPr );
   1.356 +#define VMS__index_probe_by_its_name( probeID, animPr ) \
   1.357 +        /* do nothing */
   1.358 +
   1.359 +IntervalProbe *
   1.360 +VMS_impl__get_probe_by_name( char *probeName, VirtProcr *animPr );
   1.361 +#define VMS__get_probe_by_name( probeID, animPr ) \
   1.362 +       NULL /* do nothing */
   1.363 +
   1.364 +void
   1.365 +VMS_impl__record_sched_choice_into_probe( int32 probeID, VirtProcr *animPr );
   1.366 +#define VMS__record_sched_choice_into_probe( probeID, animPr ) \
   1.367 +        /* do nothing */
   1.368 +
   1.369 +void
   1.370 +VMS_impl__record_interval_start_in_probe( int32 probeID );
   1.371 +#define VMS__record_interval_start_in_probe( probeID ) \
   1.372 +        /* do nothing */
   1.373 +
   1.374 +void
   1.375 +VMS_impl__record_interval_end_in_probe( int32 probeID );
   1.376 +#define VMS__record_interval_end_in_probe( probeID ) \
   1.377 +        /* do nothing */
   1.378 +
   1.379 +inline void doNothing();
   1.380 +void
   1.381 +VMS_impl__print_stats_of_probe( int32 probeID );
   1.382 +#define VMS__print_stats_of_probe( probeID ) \
   1.383 +        doNothing/* do nothing */
   1.384 +
   1.385 +void
   1.386 +VMS_impl__print_stats_of_all_probes();
   1.387 +#define VMS__print_stats_of_all_probes \
   1.388 +        doNothing/* do nothing */
   1.389 +
   1.390 +#endif   /* defined STATS__ENABLE_PROBES */
   1.391 +
   1.392 +#endif	/* _PROBES_H */
   1.393 +