Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff probes.c @ 209:0c83ea8adefc
Close to compilable version of common_ancestor -- still includes HW dep stuff
| author | Some Random Person <seanhalle@yahoo.com> |
|---|---|
| date | Sun, 04 Mar 2012 14:26:35 -0800 |
| parents | eaf7e4c58c9e |
| children |
line diff
1.1 --- a/probes.c Wed Feb 22 11:39:12 2012 -0800 1.2 +++ b/probes.c Sun Mar 04 14:26:35 2012 -0800 1.3 @@ -13,100 +13,46 @@ 1.4 1.5 1.6 //==================== Probes ================= 1.7 -#ifdef STATS__USE_TSC_PROBES 1.8 - 1.9 -int32 1.10 -VMS__create_histogram_probe( int32 numBins, float32 startValue, 1.11 - float32 binWidth, char *nameStr ) 1.12 - { IntervalProbe *newProbe; 1.13 - int32 idx; 1.14 - FloatHist *hist; 1.15 - 1.16 - idx = VMS__create_single_interval_probe( nameStr ); 1.17 - newProbe = _VMSMasterEnv->intervalProbes[ idx ]; 1.18 - 1.19 - hist = makeFloatHistogram( numBins, startValue, binWidth ); 1.20 - newProbe->hist = hist; 1.21 - return idx; 1.22 - } 1.23 - 1.24 -void 1.25 -VMS_impl__record_interval_start_in_probe( int32 probeID ) 1.26 - { IntervalProbe *probe; 1.27 - 1.28 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 1.29 - probe->startStamp = getTSCount(); 1.30 - } 1.31 - 1.32 -void 1.33 -VMS_impl__record_interval_end_in_probe( int32 probeID ) 1.34 - { IntervalProbe *probe; 1.35 - TSCount endStamp; 1.36 - 1.37 - endStamp = getTSCount(); 1.38 - 1.39 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 1.40 - probe->endStamp = endStamp; 1.41 - 1.42 - if( probe->hist != NULL ) 1.43 - { TSCount interval = probe->endStamp - probe->startStamp; 1.44 - //if the interval is sane, then add to histogram 1.45 - if( interval < probe->hist->endOfRange * 10 ) 1.46 - addToFloatHist( interval, probe->hist ); 1.47 - } 1.48 - } 1.49 - 1.50 -void 1.51 -VMS_impl__print_stats_of_probe( int32 probeID ) 1.52 - { IntervalProbe *probe; 1.53 - 1.54 - probe = _VMSMasterEnv->intervalProbes[ probeID ]; 1.55 - 1.56 - if( probe->hist == NULL ) 1.57 - { 1.58 - printf("probe: %s, interval: %.6lf\n", probe->nameStr,probe->interval); 1.59 - } 1.60 - 1.61 - else 1.62 - { 1.63 - printf( "probe: %s\n", probe->nameStr ); 1.64 - printFloatHist( probe->hist ); 1.65 - } 1.66 - } 1.67 -#else 1.68 - 1.69 /* 1.70 * In practice, probe operations are called from the app, from inside slaves 1.71 - * -- so have to be sure each probe is single-VP owned, and be sure that 1.72 + * -- so have to be sure each probe is single-Slv owned, and be sure that 1.73 * any place common structures are modified it's done inside the master. 1.74 * So -- the only place common structures are modified is during creation. 1.75 * after that, all mods are to individual instances. 1.76 * 1.77 * Thniking perhaps should change the semantics to be that probes are 1.78 * attached to the virtual processor -- and then everything is guaranteed 1.79 - * to be isolated -- except then can't take any intervals that span VPs, 1.80 - * and would have to transfer the probes to Master env when VP dissipates.. 1.81 + * to be isolated -- except then can't take any intervals that span Slvs, 1.82 + * and would have to transfer the probes to Master env when Slv dissipates.. 1.83 * gets messy.. 1.84 * 1.85 * For now, just making so that probe creation causes a suspend, so that 1.86 * the dynamic array in the master env is only modified from the master 1.87 * 1.88 */ 1.89 + 1.90 +//============================ Helpers =========================== 1.91 +inline void 1.92 +doNothing() 1.93 + { 1.94 + } 1.95 + 1.96 + 1.97 IntervalProbe * 1.98 -create_generic_probe( char *nameStr, SlaveVP *animPr ) 1.99 -{ 1.100 +create_generic_probe( char *nameStr, SlaveVP *animSlv ) 1.101 + { 1.102 VMSSemReq reqData; 1.103 1.104 reqData.reqType = createProbe; 1.105 reqData.nameStr = nameStr; 1.106 1.107 - VMS_WL__send_VMSSem_request( &reqData, animPr ); 1.108 + VMS_WL__send_VMSSem_request( &reqData, animSlv ); 1.109 1.110 - return animPr->dataRetFromReq; 1.111 + return animSlv->dataRetFromReq; 1.112 } 1.113 1.114 /*Use this version from outside VMS -- it uses external malloc, and modifies 1.115 - * dynamic array, so can't be animated in a slave VP 1.116 + * dynamic array, so can't be animated in a slave Slv 1.117 */ 1.118 IntervalProbe * 1.119 ext__create_generic_probe( char *nameStr ) 1.120 @@ -125,24 +71,38 @@ 1.121 return newProbe; 1.122 } 1.123 1.124 +//============================ Fns def in header ======================= 1.125 1.126 -/*Only call from inside master or main startup/shutdown thread 1.127 - */ 1.128 -void 1.129 -VMS_impl__free_probe( IntervalProbe *probe ) 1.130 - { if( probe->hist != NULL ) freeDblHist( probe->hist ); 1.131 - if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); 1.132 - VMS_int__free( probe ); 1.133 +int32 1.134 +VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animSlv ) 1.135 + { IntervalProbe *newProbe; 1.136 + 1.137 + newProbe = create_generic_probe( nameStr, animSlv ); 1.138 + 1.139 + return newProbe->probeID; 1.140 } 1.141 1.142 +int32 1.143 +VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 1.144 + float64 binWidth, char *nameStr, SlaveVP *animSlv ) 1.145 + { IntervalProbe *newProbe; 1.146 + DblHist *hist; 1.147 + 1.148 + newProbe = create_generic_probe( nameStr, animSlv ); 1.149 + 1.150 + hist = makeDblHistogram( numBins, startValue, binWidth ); 1.151 + newProbe->hist = hist; 1.152 + return newProbe->probeID; 1.153 + } 1.154 + 1.155 1.156 int32 1.157 -VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animPr) 1.158 +VMS_impl__record_time_point_into_new_probe( char *nameStr, SlaveVP *animSlv) 1.159 { IntervalProbe *newProbe; 1.160 struct timeval *startStamp; 1.161 float64 startSecs; 1.162 1.163 - newProbe = create_generic_probe( nameStr, animPr ); 1.164 + newProbe = create_generic_probe( nameStr, animSlv ); 1.165 newProbe->endSecs = 0; 1.166 1.167 gettimeofday( &(newProbe->startStamp), NULL); 1.168 @@ -174,30 +134,19 @@ 1.169 return newProbe->probeID; 1.170 } 1.171 1.172 -int32 1.173 -VMS_impl__create_single_interval_probe( char *nameStr, SlaveVP *animPr ) 1.174 - { IntervalProbe *newProbe; 1.175 1.176 - newProbe = create_generic_probe( nameStr, animPr ); 1.177 - 1.178 - return newProbe->probeID; 1.179 +/*Only call from inside master or main startup/shutdown thread 1.180 + */ 1.181 +void 1.182 +VMS_impl__free_probe( IntervalProbe *probe ) 1.183 + { if( probe->hist != NULL ) freeDblHist( probe->hist ); 1.184 + if( probe->nameStr != NULL) VMS_int__free( probe->nameStr ); 1.185 + VMS_int__free( probe ); 1.186 } 1.187 1.188 -int32 1.189 -VMS_impl__create_histogram_probe( int32 numBins, float64 startValue, 1.190 - float64 binWidth, char *nameStr, SlaveVP *animPr ) 1.191 - { IntervalProbe *newProbe; 1.192 - DblHist *hist; 1.193 - 1.194 - newProbe = create_generic_probe( nameStr, animPr ); 1.195 - 1.196 - hist = makeDblHistogram( numBins, startValue, binWidth ); 1.197 - newProbe->hist = hist; 1.198 - return newProbe->probeID; 1.199 - } 1.200 1.201 void 1.202 -VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animPr ) 1.203 +VMS_impl__index_probe_by_its_name( int32 probeID, SlaveVP *animSlv ) 1.204 { IntervalProbe *probe; 1.205 1.206 //TODO: fix this To be in Master -- race condition 1.207 @@ -206,8 +155,9 @@ 1.208 addValueIntoTable(probe->nameStr, probe, _VMSMasterEnv->probeNameHashTbl); 1.209 } 1.210 1.211 + 1.212 IntervalProbe * 1.213 -VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animPr ) 1.214 +VMS_impl__get_probe_by_name( char *probeName, SlaveVP *animSlv ) 1.215 { 1.216 //TODO: fix this To be in Master -- race condition 1.217 return getValueFromTable( probeName, _VMSMasterEnv->probeNameHashTbl ); 1.218 @@ -215,21 +165,21 @@ 1.219 1.220 1.221 /*Everything is local to the animating procr, so no need for request, do 1.222 - * work locally, in the anim Pr 1.223 + * work locally, in the anim Slv 1.224 */ 1.225 void 1.226 -VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingPr ) 1.227 +VMS_impl__record_sched_choice_into_probe( int32 probeID, SlaveVP *animatingSlv ) 1.228 { IntervalProbe *probe; 1.229 1.230 probe = _VMSMasterEnv->intervalProbes[ probeID ]; 1.231 probe->schedChoiceWasRecorded = TRUE; 1.232 - probe->coreNum = animatingPr->coreAnimatedBy; 1.233 - probe->procrID = animatingPr->procrID; 1.234 - probe->procrCreateSecs = animatingPr->createPtInSecs; 1.235 + probe->coreNum = animatingSlv->coreAnimatedBy; 1.236 + probe->slaveID = animatingSlv->procrID; 1.237 + probe->slaveCreateSecs = animatingSlv->createPtInSecs; 1.238 } 1.239 1.240 /*Everything is local to the animating procr, so no need for request, do 1.241 - * work locally, in the anim Pr 1.242 + * work locally, in the anim Slv 1.243 */ 1.244 void 1.245 VMS_impl__record_interval_start_in_probe( int32 probeID ) 1.246 @@ -237,44 +187,37 @@ 1.247 1.248 DEBUG( dbgProbes, "record start of interval\n" ) 1.249 probe = _VMSMasterEnv->intervalProbes[ probeID ]; 1.250 - gettimeofday( &(probe->startStamp), NULL ); 1.251 + probe->startStamp = getTSCount(); 1.252 } 1.253 1.254 1.255 /*Everything is local to the animating procr, so no need for request, do 1.256 - * work locally, in the anim Pr 1.257 + * work locally, in the anim Slv 1.258 + * 1.259 + *This should be safe to run inside SlaveVP -- weird behavior will be due 1.260 + * to the logical error of having more than one interval open in overlapped. 1.261 */ 1.262 void 1.263 VMS_impl__record_interval_end_in_probe( int32 probeID ) 1.264 { IntervalProbe *probe; 1.265 - struct timeval *endStamp, *startStamp; 1.266 - float64 startSecs, endSecs; 1.267 + TSCount endStamp; 1.268 1.269 + endStamp = getTSCount(); 1.270 + 1.271 DEBUG( dbgProbes, "record end of interval\n" ) 1.272 - //possible seg-fault if array resized by diff core right after this 1.273 - // one gets probe..? Something like that? Might be safe.. don't care 1.274 + 1.275 probe = _VMSMasterEnv->intervalProbes[ probeID ]; 1.276 - gettimeofday( &(probe->endStamp), NULL); 1.277 - 1.278 - //now turn into an interval held in a double 1.279 - startStamp = &(probe->startStamp); 1.280 - endStamp = &(probe->endStamp); 1.281 - 1.282 - startSecs = startStamp->tv_sec + ( startStamp->tv_usec / 1000000.0 ); 1.283 - endSecs = endStamp->tv_sec + ( endStamp->tv_usec / 1000000.0 ); 1.284 - 1.285 - probe->interval = endSecs - startSecs; 1.286 - probe->startSecs = startSecs; 1.287 - probe->endSecs = endSecs; 1.288 + probe->endStamp = endStamp; 1.289 1.290 if( probe->hist != NULL ) 1.291 - { 1.292 + { TSCount interval = probe->endStamp - probe->startStamp; 1.293 //if the interval is sane, then add to histogram 1.294 - if( probe->interval < probe->hist->endOfRange * 10 ) 1.295 - addToDblHist( probe->interval, probe->hist ); 1.296 + if( interval < probe->hist->endOfRange * 10 ) 1.297 + addToFloatHist( interval, probe->hist ); 1.298 } 1.299 } 1.300 1.301 + 1.302 void 1.303 print_probe_helper( IntervalProbe *probe ) 1.304 { 1.305 @@ -283,7 +226,7 @@ 1.306 1.307 if( probe->schedChoiceWasRecorded ) 1.308 { printf( "coreNum: %d, procrID: %d, procrCreated: %0.6f | ", 1.309 - probe->coreNum, probe->procrID, probe->procrCreateSecs ); 1.310 + probe->coreNum, probe->slaveID, probe->slaveCreateSecs ); 1.311 } 1.312 1.313 if( probe->endSecs == 0 ) //just a single point in time 1.314 @@ -318,22 +261,10 @@ 1.315 } 1.316 1.317 1.318 -inline void doNothing(){}; 1.319 - 1.320 -void 1.321 -generic_print_probe( void *_probe ) 1.322 - { 1.323 - IntervalProbe *probe = (IntervalProbe *)_probe; 1.324 - 1.325 - //TODO segfault in printf 1.326 - //print_probe_helper( probe ); 1.327 - } 1.328 - 1.329 void 1.330 VMS_impl__print_stats_of_all_probes() 1.331 { 1.332 forAllInDynArrayDo( _VMSMasterEnv->dynIntervalProbesInfo, 1.333 - &generic_print_probe ); 1.334 + &VMS_impl__print_stats_of_probe ); 1.335 fflush( stdout ); 1.336 } 1.337 -#endif
