diff VMS.h @ 178:c1784868dcea

testing hgeol -- see if it fixes line-ending issues -- commit line endings
author Me@portablequad
date Wed, 04 Jan 2012 16:10:11 -0800
parents 9661b8cc8318
children 7523ee70d66c 1738f190b7bb
line diff
     1.1 --- a/VMS.h	Thu Oct 06 16:24:17 2011 +0200
     1.2 +++ b/VMS.h	Wed Jan 04 16:10:11 2012 -0800
     1.3 @@ -1,579 +1,579 @@
     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 _VMS_H
    1.13 -#define	_VMS_H
    1.14 -#define _GNU_SOURCE
    1.15 -
    1.16 -#include "VMS_primitive_data_types.h"
    1.17 -#include "Queue_impl/PrivateQueue.h"
    1.18 -#include "Histogram/Histogram.h"
    1.19 -#include "DynArray/DynArray.h"
    1.20 -#include "Hash_impl/PrivateHash.h"
    1.21 -#include "vmalloc.h"
    1.22 -
    1.23 -#include <pthread.h>
    1.24 -#include <sys/time.h>
    1.25 -
    1.26 -
    1.27 -//===============================  Debug  ===================================
    1.28 -//
    1.29 -//When SEQUENTIAL is defined, VMS does sequential exe in the main thread
    1.30 -// It still does co-routines and all the mechanisms are the same, it just
    1.31 -// has only a single thread and animates VPs one at a time
    1.32 -//#define SEQUENTIAL
    1.33 -
    1.34 -//#define USE_WORK_STEALING
    1.35 -
    1.36 -//turns on the probe-instrumentation in the application -- when not
    1.37 -// defined, the calls to the probe functions turn into comments
    1.38 -#define STATS__ENABLE_PROBES
    1.39 -//#define TURN_ON_DEBUG_PROBES
    1.40 -
    1.41 -//These defines turn types of bug messages on and off
    1.42 -// be sure debug messages are un-commented (next block of defines)
    1.43 -#define dbgAppFlow   TRUE /* Top level flow of application code -- general*/
    1.44 -#define dbgProbes    FALSE /* for issues inside probes themselves*/
    1.45 -#define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/
    1.46 -#define dbgRqstHdlr  FALSE /* in request handler code*/
    1.47 -
    1.48 -//Comment or un- the substitute half to turn on/off types of debug message
    1.49 -#define DEBUG(  bool, msg)         \
    1.50 -//  if( bool){ printf(msg); fflush(stdin);}
    1.51 -#define DEBUG1( bool, msg, param)  \
    1.52 -//   if(bool){printf(msg, param); fflush(stdin);}
    1.53 -#define DEBUG2( bool, msg, p1, p2) \
    1.54 -//   if(bool) {printf(msg, p1, p2); fflush(stdin);}
    1.55 -
    1.56 -#define ERROR(msg) printf(msg);
    1.57 -#define ERROR1(msg, param) printf(msg, param); 
    1.58 -#define ERROR2(msg, p1, p2) printf(msg, p1, p2);
    1.59 -
    1.60 -//===========================  STATS =======================
    1.61 -
    1.62 -   //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and
    1.63 -   // compiled-in that saves the low part of the time stamp count just before
    1.64 -   // suspending a processor and just after resuming that processorsrc/VPThread_lib/VMS/VMS.h:322: warning: previous declaration of ‘VMS__create_procr’ was here.  It is
    1.65 -   // saved into a field added to VirtProcr.  Have to sanity-check for
    1.66 -   // rollover of low portion into high portion.
    1.67 -//#define MEAS__TIME_STAMP_SUSP
    1.68 -//#define MEAS__TIME_MASTER
    1.69 -#define MEAS__TIME_PLUGIN
    1.70 -#define MEAS__TIME_MALLOC
    1.71 -//#define MEAS__TIME_MASTER_LOCK
    1.72 -#define MEAS__NUM_TIMES_TO_RUN 100000
    1.73 -
    1.74 -   //For code that calculates normalization-offset between TSC counts of
    1.75 -   // different cores.
    1.76 -#define NUM_TSC_ROUND_TRIPS 10
    1.77 -
    1.78 -
    1.79 -//=========================  Hardware related Constants =====================
    1.80 -   //This value is the number of hardware threads in the shared memory
    1.81 -   // machine
    1.82 -//#define NUM_CORES        8
    1.83 -
    1.84 -   // tradeoff amortizing master fixed overhead vs imbalance potential
    1.85 -   // when work-stealing, can make bigger, at risk of losing cache affinity
    1.86 -#define NUM_SCHED_SLOTS  5
    1.87 -
    1.88 -#define MIN_WORK_UNIT_CYCLES 20000
    1.89 -
    1.90 -#define MASTERLOCK_RETRIES 10000
    1.91 -
    1.92 -   // stack size in virtual processors created
    1.93 -#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
    1.94 -
    1.95 -   // memory for VMS__malloc
    1.96 -#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */
    1.97 -
    1.98 -#define CACHE_LINE 64
    1.99 -#define PAGE_SIZE 4096
   1.100 -
   1.101 -
   1.102 -//==============================
   1.103 -
   1.104 -#define SUCCESS 0
   1.105 -
   1.106 -#define writeVMSQ     writePrivQ
   1.107 -#define readVMSQ      readPrivQ
   1.108 -#define makeVMSQ      makeVMSPrivQ
   1.109 -#define numInVMSQ     numInPrivQ
   1.110 -#define VMSQueueStruc PrivQueueStruc
   1.111 -
   1.112 -
   1.113 -
   1.114 -//===========================================================================
   1.115 -typedef unsigned long long TSCount;
   1.116 -
   1.117 -typedef struct _SchedSlot     SchedSlot;
   1.118 -typedef struct _VMSReqst      VMSReqst;
   1.119 -typedef struct _VirtProcr     VirtProcr;
   1.120 -typedef struct _IntervalProbe IntervalProbe;
   1.121 -typedef struct _GateStruc     GateStruc;
   1.122 -
   1.123 -
   1.124 -typedef VirtProcr * (*SlaveScheduler)  ( void *, int );   //semEnv, coreIdx
   1.125 -typedef void  (*RequestHandler)  ( VirtProcr *, void * ); //prWReqst, semEnv
   1.126 -typedef void  (*VirtProcrFnPtr)  ( void *, VirtProcr * ); //initData, animPr
   1.127 -typedef void    VirtProcrFn      ( void *, VirtProcr * ); //initData, animPr
   1.128 -typedef void  (*ResumePrFnPtr)   ( VirtProcr *, void * );
   1.129 -
   1.130 -
   1.131 -//============= Requests ===========
   1.132 -//
   1.133 -
   1.134 -enum VMSReqstType   //avoid starting enums at 0, for debug reasons
   1.135 - {
   1.136 -   semantic = 1,
   1.137 -   createReq,
   1.138 -   dissipate,
   1.139 -   VMSSemantic      //goes with VMSSemReqst below
   1.140 - };
   1.141 -
   1.142 -struct _VMSReqst
   1.143 - {
   1.144 -   enum VMSReqstType  reqType;//used for dissipate and in future for IO requests
   1.145 -   void              *semReqData;
   1.146 -
   1.147 -   VMSReqst *nextReqst;
   1.148 - };
   1.149 -//VMSReqst
   1.150 -
   1.151 -enum VMSSemReqstType   //These are equivalent to semantic requests, but for
   1.152 - {                     // VMS's services available directly to app, like OS
   1.153 -   createProbe = 1,    // and probe services -- like a VMS-wide built-in lang
   1.154 -   openFile,
   1.155 -   otherIO
   1.156 - };
   1.157 -
   1.158 -typedef struct
   1.159 - { enum VMSSemReqstType reqType;
   1.160 -   VirtProcr           *requestingPr;
   1.161 -   char                *nameStr;  //for create probe
   1.162 - }
   1.163 - VMSSemReq;
   1.164 -
   1.165 -
   1.166 -//====================  Core data structures  ===================
   1.167 -
   1.168 -struct _SchedSlot
   1.169 - {
   1.170 -   int         workIsDone;
   1.171 -   int         needsProcrAssigned;
   1.172 -   VirtProcr  *procrAssignedToSlot;
   1.173 - };
   1.174 -//SchedSlot
   1.175 -
   1.176 -/*WARNING: re-arranging this data structure could cause VP switching
   1.177 - *         assembly code to fail -- hard-codes offsets of fields
   1.178 - */
   1.179 -struct _VirtProcr
   1.180 - { int         procrID;  //for debugging -- count up each time create
   1.181 -   int         coreAnimatedBy;
   1.182 -   void       *startOfStack;
   1.183 -   void       *stackPtr;
   1.184 -   void       *framePtr;
   1.185 -   void       *nextInstrPt;
   1.186 -   
   1.187 -   void       *coreLoopStartPt;  //allows proto-runtime to be linked later
   1.188 -   void       *coreLoopFramePtr; //restore before jmp back to core loop
   1.189 -   void       *coreLoopStackPtr; //restore before jmp back to core loop
   1.190 -
   1.191 -   void       *initialData;
   1.192 -
   1.193 -   SchedSlot  *schedSlot;
   1.194 -   VMSReqst   *requests;
   1.195 -
   1.196 -   void       *semanticData; //this livesUSE_GNU here for the life of VP
   1.197 -   void       *dataRetFromReq;//values returned from plugin to VP go here
   1.198 -
   1.199 -      //=========== MEASUREMENT STUFF ==========
   1.200 -   #ifdef MEAS__TIME_STAMP_SUSP
   1.201 -   unsigned int preSuspTSCLow;
   1.202 -   unsigned int postSuspTSCLow;
   1.203 -   #endif
   1.204 -   #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
   1.205 -   unsigned int startMasterTSCLow;USE_GNU
   1.206 -   unsigned int endMasterTSCLow;
   1.207 -   #endif
   1.208 -      //========================================
   1.209 -   
   1.210 -   float64      createPtInSecs;  //have space but don't use on some configs
   1.211 - };
   1.212 -//VirtProcr
   1.213 -
   1.214 -
   1.215 -/*WARNING: re-arranging this data structure could cause VP-switching
   1.216 - *         assembly code to fail -- hard-codes offsets of fields
   1.217 - *         (because -O3 messes with things otherwise)
   1.218 - */
   1.219 -typedef struct
   1.220 - {
   1.221 -   SlaveScheduler   slaveScheduler;
   1.222 -   RequestHandler   requestHandler;
   1.223 -   
   1.224 -   SchedSlot     ***allSchedSlots;
   1.225 -   VMSQueueStruc **readyToAnimateQs;
   1.226 -   VirtProcr      **masterVPs;
   1.227 -
   1.228 -   void            *semanticEnv;
   1.229 -   void            *OSEventStruc;   //for future, when add I/O to BLIS
   1.230 -   MallocProlog    *freeListHead;
   1.231 -   int32            amtOfOutstandingMem; //total currently allocated
   1.232 -
   1.233 -   void            *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
   1.234 -
   1.235 -   int32            setupComplete;
   1.236 -   volatile int32   masterLock;
   1.237 -
   1.238 -   int32            numMasterInARow[NUM_CORES];//detect back-to-back masterVP
   1.239 -   GateStruc       *workStealingGates[ NUM_CORES ]; //concurrent work-steal
   1.240 -   int32            workStealingLock;
   1.241 -   
   1.242 -   int32            numProcrsCreated; //gives ordering to processor creation
   1.243 -
   1.244 -      //=========== MEASUREMENT STUFF =============
   1.245 -   IntervalProbe  **intervalProbes;
   1.246 -   PrivDynArrayInfo    *dynIntervalProbesInfo;
   1.247 -   HashTable       *probeNameHashTbl;
   1.248 -   int32            masterCreateProbeID;
   1.249 -   float64          createPtInSecs;
   1.250 -   Histogram      **measHists;
   1.251 -   PrivDynArrayInfo *measHistsInfo;
   1.252 -   #ifdef MEAS__TIME_PLUGIN
   1.253 -   Histogram       *reqHdlrLowTimeHist;
   1.254 -   Histogram       *reqHdlrHighTimeHist;
   1.255 -   #endif
   1.256 -   #ifdef MEAS__TIME_MALLOC
   1.257 -   Histogram       *mallocTimeHist;
   1.258 -   Histogram       *freeTimeHist;
   1.259 -   #endif
   1.260 -   #ifdef MEAS__TIME_MASTER_LOCK
   1.261 -   Histogram       *masterLockLowTimeHist;
   1.262 -   Histogram       *masterLockHighTimeHist;
   1.263 -   #endif
   1.264 - }
   1.265 -MasterEnv;
   1.266 -
   1.267 -//=========================  Extra Stuff Data Strucs  =======================
   1.268 -typedef struct
   1.269 - {
   1.270 -
   1.271 - }
   1.272 -VMSExcp;
   1.273 -
   1.274 -struct _GateStruc
   1.275 - {
   1.276 -   int32 gateClosed;
   1.277 -   int32 preGateProgress;
   1.278 -   int32 waitProgress;
   1.279 -   int32 exitProgress;
   1.280 - };
   1.281 -//GateStruc
   1.282 -
   1.283 -//=======================  OS Thread related  ===============================
   1.284 -
   1.285 -void * coreLoop( void *paramsIn );  //standard PThreads fn prototype
   1.286 -void * coreLoop_Seq( void *paramsIn );  //standard PThreads fn prototype
   1.287 -void masterLoop( void *initData, VirtProcr *masterPr );
   1.288 -
   1.289 -
   1.290 -typedef struct
   1.291 - {
   1.292 -   void           *endThdPt;
   1.293 -   unsigned int    coreNum;
   1.294 - }
   1.295 -ThdParams;
   1.296 -
   1.297 -pthread_t       coreLoopThdHandles[ NUM_CORES ];  //pthread's virt-procr state
   1.298 -ThdParams      *coreLoopThdParams [ NUM_CORES ];
   1.299 -pthread_mutex_t suspendLock;
   1.300 -pthread_cond_t  suspend_cond;
   1.301 -
   1.302 -
   1.303 -
   1.304 -//=====================  Global Vars ===================
   1.305 -
   1.306 -volatile MasterEnv      *_VMSMasterEnv;
   1.307 -
   1.308 -
   1.309 -
   1.310 -
   1.311 -//===========================  Function Prototypes  =========================
   1.312 -
   1.313 -
   1.314 -//========== Setup and shutdown ==========
   1.315 -void
   1.316 -VMS__init();
   1.317 -
   1.318 -void
   1.319 -VMS__init_Seq();
   1.320 -
   1.321 -void
   1.322 -VMS__start_the_work_then_wait_until_done();
   1.323 -
   1.324 -void
   1.325 -VMS__start_the_work_then_wait_until_done_Seq();
   1.326 -
   1.327 -inline VirtProcr *
   1.328 -VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
   1.329 -
   1.330 -void
   1.331 -VMS__dissipate_procr( VirtProcr *procrToDissipate );
   1.332 -
   1.333 -   //Use this to create processor inside entry point & other places outside
   1.334 -   // the VMS system boundary (IE, not run in slave nor Master)
   1.335 -VirtProcr *
   1.336 -VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
   1.337 -
   1.338 -void
   1.339 -VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
   1.340 -
   1.341 -void
   1.342 -VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
   1.343 -
   1.344 -void
   1.345 -VMS__shutdown();
   1.346 -
   1.347 -void
   1.348 -VMS__cleanup_at_end_of_shutdown();
   1.349 -
   1.350 -void *
   1.351 -VMS__give_sem_env_for( VirtProcr *animPr );
   1.352 -
   1.353 -
   1.354 -//==============  Request Related  ===============
   1.355 -
   1.356 -void
   1.357 -VMS__suspend_procr( VirtProcr *callingPr );
   1.358 -
   1.359 -inline void
   1.360 -VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
   1.361 -
   1.362 -inline void
   1.363 -VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
   1.364 -
   1.365 -void
   1.366 -VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
   1.367 -
   1.368 -void inline
   1.369 -VMS__send_dissipate_req( VirtProcr *prToDissipate );
   1.370 -
   1.371 -inline void
   1.372 -VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
   1.373 -
   1.374 -VMSReqst *
   1.375 -VMS__take_next_request_out_of( VirtProcr *procrWithReq );
   1.376 -
   1.377 -inline void *
   1.378 -VMS__take_sem_reqst_from( VMSReqst *req );
   1.379 -
   1.380 -void inline
   1.381 -VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
   1.382 -                       ResumePrFnPtr resumePrFnPtr );
   1.383 -
   1.384 -//======================== STATS ======================
   1.385 -
   1.386 -//===== RDTSC wrapper ===== //Also runs with x86_64 code
   1.387 -
   1.388 -#define saveTimeStampCountInto(low, high) \
   1.389 -   asm volatile("RDTSC;                   \
   1.390 -                 movl %%eax, %0;          \
   1.391 -                 movl %%edx, %1;"         \
   1.392 -   /* outputs */ : "=m" (low), "=m" (high)\
   1.393 -   /* inputs  */ :                        \
   1.394 -   /* clobber */ : "%eax", "%edx"         \
   1.395 -                );
   1.396 -
   1.397 -#define saveLowTimeStampCountInto(low)    \
   1.398 -   asm volatile("RDTSC;                   \
   1.399 -                 movl %%eax, %0;"         \
   1.400 -   /* outputs */ : "=m" (low)             \
   1.401 -   /* inputs  */ :                        \
   1.402 -   /* clobber */ : "%eax", "%edx"         \
   1.403 -                );
   1.404 -
   1.405 -//====================
   1.406 -#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \
   1.407 -   makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \
   1.408 -   _VMSMasterEnv->measHists[idx] =  \
   1.409 -                       makeFixedBinHist( numBins, startVal, binWidth, name );
   1.410 -
   1.411 -
   1.412 -#define MEAS__SUB_CREATE  /*turn on/off subtraction of create from plugin*/
   1.413 -
   1.414 -#ifdef VPTHREAD
   1.415 -
   1.416 -//VPThread
   1.417 -#define createHistIdx      0
   1.418 -#define mutexLockHistIdx   1
   1.419 -#define mutexUnlockHistIdx 2
   1.420 -#define condWaitHistIdx    3
   1.421 -#define condSignalHistIdx  4
   1.422 -
   1.423 -#define MakeTheMeasHists() \
   1.424 -   _VMSMasterEnv->measHistsInfo = \
   1.425 -              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
   1.426 -   makeAMeasHist( createHistIdx,      "create",        250, 0, 100 ) \
   1.427 -   makeAMeasHist( mutexLockHistIdx,   "mutex_lock",    50, 0, 100 ) \
   1.428 -   makeAMeasHist( mutexUnlockHistIdx, "mutex_unlock",  50, 0, 100 ) \
   1.429 -   makeAMeasHist( condWaitHistIdx,    "cond_wait",     50, 0, 100 ) \
   1.430 -   makeAMeasHist( condSignalHistIdx,  "cond_signal",   50, 0, 100 )
   1.431 -
   1.432 -#endif
   1.433 -
   1.434 -
   1.435 -#ifdef VCILK
   1.436 -
   1.437 -//VCilk
   1.438 -#define spawnHistIdx      0
   1.439 -#define syncHistIdx       1
   1.440 -
   1.441 -#define MakeTheMeasHists() \
   1.442 -   _VMSMasterEnv->measHistsInfo = \
   1.443 -              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
   1.444 -    makeAMeasHist( spawnHistIdx,      "Spawn",        50, 0, 200 ) \
   1.445 -    makeAMeasHist( syncHistIdx,       "Sync",         50, 0, 200 )
   1.446 -
   1.447 -
   1.448 -#endif
   1.449 -
   1.450 -#ifdef SSR
   1.451 -
   1.452 -//SSR
   1.453 -#define SendFromToHistIdx      0
   1.454 -#define SendOfTypeHistIdx      1
   1.455 -#define ReceiveFromToHistIdx   2
   1.456 -#define ReceiveOfTypeHistIdx   3
   1.457 -
   1.458 -#define MakeTheMeasHists() \
   1.459 -   _VMSMasterEnv->measHistsInfo = \
   1.460 -              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
   1.461 -    makeAMeasHist( SendFromToHistIdx,   "SendFromTo",    50, 0, 100 ) \
   1.462 -    makeAMeasHist( SendOfTypeHistIdx,   "SendOfType",    50, 0, 100 ) \
   1.463 -    makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \
   1.464 -    makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 )
   1.465 -
   1.466 -#endif
   1.467 -
   1.468 -//===========================================================================
   1.469 -//VPThread
   1.470 -
   1.471 -
   1.472 -#define Meas_startCreate \
   1.473 -    int32 startStamp, endStamp; \
   1.474 -    saveLowTimeStampCountInto( startStamp ); \
   1.475 -
   1.476 -#define Meas_endCreate \
   1.477 -    saveLowTimeStampCountInto( endStamp ); \
   1.478 -    addIntervalToHist( startStamp, endStamp, \
   1.479 -                                 _VMSMasterEnv->measHists[ createHistIdx ] );
   1.480 -
   1.481 -#define Meas_startMutexLock \
   1.482 -    int32 startStamp, endStamp; \
   1.483 -    saveLowTimeStampCountInto( startStamp ); \
   1.484 -
   1.485 -#define Meas_endMutexLock \
   1.486 -    saveLowTimeStampCountInto( endStamp ); \
   1.487 -    addIntervalToHist( startStamp, endStamp, \
   1.488 -                              _VMSMasterEnv->measHists[ mutexLockHistIdx ] );
   1.489 -
   1.490 -#define Meas_startMutexUnlock \
   1.491 -    int32 startStamp, endStamp; \
   1.492 -    saveLowTimeStampCountInto( startStamp ); \
   1.493 -
   1.494 -#define Meas_endMutexUnlock \
   1.495 -    saveLowTimeStampCountInto( endStamp ); \
   1.496 -    addIntervalToHist( startStamp, endStamp, \
   1.497 -                            _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] );
   1.498 -
   1.499 -#define Meas_startCondWait \
   1.500 -    int32 startStamp, endStamp; \
   1.501 -    saveLowTimeStampCountInto( startStamp ); \
   1.502 -
   1.503 -#define Meas_endCondWait \
   1.504 -    saveLowTimeStampCountInto( endStamp ); \
   1.505 -    addIntervalToHist( startStamp, endStamp, \
   1.506 -                               _VMSMasterEnv->measHists[ condWaitHistIdx ] );
   1.507 -
   1.508 -#define Meas_startCondSignal \
   1.509 -    int32 startStamp, endStamp; \
   1.510 -    saveLowTimeStampCountInto( startStamp ); \
   1.511 -
   1.512 -#define Meas_endCondSignal \
   1.513 -    saveLowTimeStampCountInto( endStamp ); \
   1.514 -    addIntervalToHist( startStamp, endStamp, \
   1.515 -                             _VMSMasterEnv->measHists[ condSignalHistIdx ] );
   1.516 -
   1.517 -//===========================================================================
   1.518 -// VCilk
   1.519 -#define Meas_startSpawn \
   1.520 -    int32 startStamp, endStamp; \
   1.521 -    saveLowTimeStampCountInto( startStamp ); \
   1.522 -
   1.523 -#define Meas_endSpawn \
   1.524 -    saveLowTimeStampCountInto( endStamp ); \
   1.525 -    addIntervalToHist( startStamp, endStamp, \
   1.526 -                             _VMSMasterEnv->measHists[ spawnHistIdx ] );
   1.527 -
   1.528 -#define Meas_startSync \
   1.529 -    int32 startStamp, endStamp; \
   1.530 -    saveLowTimeStampCountInto( startStamp ); \
   1.531 -
   1.532 -#define Meas_endSync \
   1.533 -    saveLowTimeStampCountInto( endStamp ); \
   1.534 -    addIntervalToHist( startStamp, endStamp, \
   1.535 -                             _VMSMasterEnv->measHists[ syncHistIdx ] );
   1.536 -
   1.537 -//===========================================================================
   1.538 -// SSR
   1.539 -#define Meas_startSendFromTo \
   1.540 -    int32 startStamp, endStamp; \
   1.541 -    saveLowTimeStampCountInto( startStamp ); \
   1.542 -
   1.543 -#define Meas_endSendFromTo \
   1.544 -    saveLowTimeStampCountInto( endStamp ); \
   1.545 -    addIntervalToHist( startStamp, endStamp, \
   1.546 -                             _VMSMasterEnv->measHists[ SendFromToHistIdx ] );
   1.547 -
   1.548 -#define Meas_startSendOfType \
   1.549 -    int32 startStamp, endStamp; \
   1.550 -    saveLowTimeStampCountInto( startStamp ); \
   1.551 -
   1.552 -#define Meas_endSendOfType \
   1.553 -    saveLowTimeStampCountInto( endStamp ); \
   1.554 -    addIntervalToHist( startStamp, endStamp, \
   1.555 -                             _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] );
   1.556 -
   1.557 -#define Meas_startReceiveFromTo \
   1.558 -    int32 startStamp, endStamp; \
   1.559 -    saveLowTimeStampCountInto( startStamp ); \
   1.560 -
   1.561 -#define Meas_endReceiveFromTo \
   1.562 -    saveLowTimeStampCountInto( endStamp ); \
   1.563 -    addIntervalToHist( startStamp, endStamp, \
   1.564 -                             _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] );
   1.565 -
   1.566 -#define Meas_startReceiveOfType \
   1.567 -    int32 startStamp, endStamp; \
   1.568 -    saveLowTimeStampCountInto( startStamp ); \
   1.569 -
   1.570 -#define Meas_endReceiveOfType \
   1.571 -    saveLowTimeStampCountInto( endStamp ); \
   1.572 -    addIntervalToHist( startStamp, endStamp, \
   1.573 -                             _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] );
   1.574 -
   1.575 -//=====
   1.576 -
   1.577 -#include "ProcrContext.h"
   1.578 -#include "probes.h"
   1.579 -#include "vutilities.h"
   1.580 -
   1.581 -#endif	/* _VMS_H */
   1.582 -
   1.583 +/*
   1.584 + *  Copyright 2009 OpenSourceStewardshipFoundation.org
   1.585 + *  Licensed under GNU General Public License version 2
   1.586 + *
   1.587 + * Author: seanhalle@yahoo.com
   1.588 + * 
   1.589 + */
   1.590 +
   1.591 +#ifndef _VMS_H
   1.592 +#define	_VMS_H
   1.593 +#define _GNU_SOURCE
   1.594 +
   1.595 +#include "VMS_primitive_data_types.h"
   1.596 +#include "Queue_impl/PrivateQueue.h"
   1.597 +#include "Histogram/Histogram.h"
   1.598 +#include "DynArray/DynArray.h"
   1.599 +#include "Hash_impl/PrivateHash.h"
   1.600 +#include "vmalloc.h"
   1.601 +
   1.602 +#include <pthread.h>
   1.603 +#include <sys/time.h>
   1.604 +
   1.605 +
   1.606 +//===============================  Debug  ===================================
   1.607 +//
   1.608 +//When SEQUENTIAL is defined, VMS does sequential exe in the main thread
   1.609 +// It still does co-routines and all the mechanisms are the same, it just
   1.610 +// has only a single thread and animates VPs one at a time
   1.611 +//#define SEQUENTIAL
   1.612 +
   1.613 +//#define USE_WORK_STEALING
   1.614 +
   1.615 +//turns on the probe-instrumentation in the application -- when not
   1.616 +// defined, the calls to the probe functions turn into comments
   1.617 +#define STATS__ENABLE_PROBES
   1.618 +//#define TURN_ON_DEBUG_PROBES
   1.619 +
   1.620 +//These defines turn types of bug messages on and off
   1.621 +// be sure debug messages are un-commented (next block of defines)
   1.622 +#define dbgAppFlow   TRUE /* Top level flow of application code -- general*/
   1.623 +#define dbgProbes    FALSE /* for issues inside probes themselves*/
   1.624 +#define dbgB2BMaster FALSE /* in coreloop, back to back master VPs*/
   1.625 +#define dbgRqstHdlr  FALSE /* in request handler code*/
   1.626 +
   1.627 +//Comment or un- the substitute half to turn on/off types of debug message
   1.628 +#define DEBUG(  bool, msg)         \
   1.629 +//  if( bool){ printf(msg); fflush(stdin);}
   1.630 +#define DEBUG1( bool, msg, param)  \
   1.631 +//   if(bool){printf(msg, param); fflush(stdin);}
   1.632 +#define DEBUG2( bool, msg, p1, p2) \
   1.633 +//   if(bool) {printf(msg, p1, p2); fflush(stdin);}
   1.634 +
   1.635 +#define ERROR(msg) printf(msg);
   1.636 +#define ERROR1(msg, param) printf(msg, param); 
   1.637 +#define ERROR2(msg, p1, p2) printf(msg, p1, p2);
   1.638 +
   1.639 +//===========================  STATS =======================
   1.640 +
   1.641 +   //when MEAS__TIME_STAMP_SUSP is defined, causes code to be inserted and
   1.642 +   // compiled-in that saves the low part of the time stamp count just before
   1.643 +   // suspending a processor and just after resuming that processorsrc/VPThread_lib/VMS/VMS.h:322: warning: previous declaration of ‘VMS__create_procr’ was here.  It is
   1.644 +   // saved into a field added to VirtProcr.  Have to sanity-check for
   1.645 +   // rollover of low portion into high portion.
   1.646 +//#define MEAS__TIME_STAMP_SUSP
   1.647 +//#define MEAS__TIME_MASTER
   1.648 +#define MEAS__TIME_PLUGIN
   1.649 +#define MEAS__TIME_MALLOC
   1.650 +//#define MEAS__TIME_MASTER_LOCK
   1.651 +#define MEAS__NUM_TIMES_TO_RUN 100000
   1.652 +
   1.653 +   //For code that calculates normalization-offset between TSC counts of
   1.654 +   // different cores.
   1.655 +#define NUM_TSC_ROUND_TRIPS 10
   1.656 +
   1.657 +
   1.658 +//=========================  Hardware related Constants =====================
   1.659 +   //This value is the number of hardware threads in the shared memory
   1.660 +   // machine
   1.661 +//#define NUM_CORES        8
   1.662 +
   1.663 +   // tradeoff amortizing master fixed overhead vs imbalance potential
   1.664 +   // when work-stealing, can make bigger, at risk of losing cache affinity
   1.665 +#define NUM_SCHED_SLOTS  5
   1.666 +
   1.667 +#define MIN_WORK_UNIT_CYCLES 20000
   1.668 +
   1.669 +#define MASTERLOCK_RETRIES 10000
   1.670 +
   1.671 +   // stack size in virtual processors created
   1.672 +#define VIRT_PROCR_STACK_SIZE 0x8000 /* 32K */
   1.673 +
   1.674 +   // memory for VMS__malloc
   1.675 +#define MALLOC_ADDITIONAL_MEM_FROM_OS_SIZE 0x10000000 /* 256M */
   1.676 +
   1.677 +#define CACHE_LINE 64
   1.678 +#define PAGE_SIZE 4096
   1.679 +
   1.680 +
   1.681 +//==============================
   1.682 +
   1.683 +#define SUCCESS 0
   1.684 +
   1.685 +#define writeVMSQ     writePrivQ
   1.686 +#define readVMSQ      readPrivQ
   1.687 +#define makeVMSQ      makeVMSPrivQ
   1.688 +#define numInVMSQ     numInPrivQ
   1.689 +#define VMSQueueStruc PrivQueueStruc
   1.690 +
   1.691 +
   1.692 +
   1.693 +//===========================================================================
   1.694 +typedef unsigned long long TSCount;
   1.695 +
   1.696 +typedef struct _SchedSlot     SchedSlot;
   1.697 +typedef struct _VMSReqst      VMSReqst;
   1.698 +typedef struct _VirtProcr     VirtProcr;
   1.699 +typedef struct _IntervalProbe IntervalProbe;
   1.700 +typedef struct _GateStruc     GateStruc;
   1.701 +
   1.702 +
   1.703 +typedef VirtProcr * (*SlaveScheduler)  ( void *, int );   //semEnv, coreIdx
   1.704 +typedef void  (*RequestHandler)  ( VirtProcr *, void * ); //prWReqst, semEnv
   1.705 +typedef void  (*VirtProcrFnPtr)  ( void *, VirtProcr * ); //initData, animPr
   1.706 +typedef void    VirtProcrFn      ( void *, VirtProcr * ); //initData, animPr
   1.707 +typedef void  (*ResumePrFnPtr)   ( VirtProcr *, void * );
   1.708 +
   1.709 +
   1.710 +//============= Requests ===========
   1.711 +//
   1.712 +
   1.713 +enum VMSReqstType   //avoid starting enums at 0, for debug reasons
   1.714 + {
   1.715 +   semantic = 1,
   1.716 +   createReq,
   1.717 +   dissipate,
   1.718 +   VMSSemantic      //goes with VMSSemReqst below
   1.719 + };
   1.720 +
   1.721 +struct _VMSReqst
   1.722 + {
   1.723 +   enum VMSReqstType  reqType;//used for dissipate and in future for IO requests
   1.724 +   void              *semReqData;
   1.725 +
   1.726 +   VMSReqst *nextReqst;
   1.727 + };
   1.728 +//VMSReqst
   1.729 +
   1.730 +enum VMSSemReqstType   //These are equivalent to semantic requests, but for
   1.731 + {                     // VMS's services available directly to app, like OS
   1.732 +   createProbe = 1,    // and probe services -- like a VMS-wide built-in lang
   1.733 +   openFile,
   1.734 +   otherIO
   1.735 + };
   1.736 +
   1.737 +typedef struct
   1.738 + { enum VMSSemReqstType reqType;
   1.739 +   VirtProcr           *requestingPr;
   1.740 +   char                *nameStr;  //for create probe
   1.741 + }
   1.742 + VMSSemReq;
   1.743 +
   1.744 +
   1.745 +//====================  Core data structures  ===================
   1.746 +
   1.747 +struct _SchedSlot
   1.748 + {
   1.749 +   int         workIsDone;
   1.750 +   int         needsProcrAssigned;
   1.751 +   VirtProcr  *procrAssignedToSlot;
   1.752 + };
   1.753 +//SchedSlot
   1.754 +
   1.755 +/*WARNING: re-arranging this data structure could cause VP switching
   1.756 + *         assembly code to fail -- hard-codes offsets of fields
   1.757 + */
   1.758 +struct _VirtProcr
   1.759 + { int         procrID;  //for debugging -- count up each time create
   1.760 +   int         coreAnimatedBy;
   1.761 +   void       *startOfStack;
   1.762 +   void       *stackPtr;
   1.763 +   void       *framePtr;
   1.764 +   void       *nextInstrPt;
   1.765 +   
   1.766 +   void       *coreLoopStartPt;  //allows proto-runtime to be linked later
   1.767 +   void       *coreLoopFramePtr; //restore before jmp back to core loop
   1.768 +   void       *coreLoopStackPtr; //restore before jmp back to core loop
   1.769 +
   1.770 +   void       *initialData;
   1.771 +
   1.772 +   SchedSlot  *schedSlot;
   1.773 +   VMSReqst   *requests;
   1.774 +
   1.775 +   void       *semanticData; //this livesUSE_GNU here for the life of VP
   1.776 +   void       *dataRetFromReq;//values returned from plugin to VP go here
   1.777 +
   1.778 +      //=========== MEASUREMENT STUFF ==========
   1.779 +   #ifdef MEAS__TIME_STAMP_SUSP
   1.780 +   unsigned int preSuspTSCLow;
   1.781 +   unsigned int postSuspTSCLow;
   1.782 +   #endif
   1.783 +   #ifdef MEAS__TIME_MASTER /* in VirtProcr because multiple masterVPs*/
   1.784 +   unsigned int startMasterTSCLow;USE_GNU
   1.785 +   unsigned int endMasterTSCLow;
   1.786 +   #endif
   1.787 +      //========================================
   1.788 +   
   1.789 +   float64      createPtInSecs;  //have space but don't use on some configs
   1.790 + };
   1.791 +//VirtProcr
   1.792 +
   1.793 +
   1.794 +/*WARNING: re-arranging this data structure could cause VP-switching
   1.795 + *         assembly code to fail -- hard-codes offsets of fields
   1.796 + *         (because -O3 messes with things otherwise)
   1.797 + */
   1.798 +typedef struct
   1.799 + {
   1.800 +   SlaveScheduler   slaveScheduler;
   1.801 +   RequestHandler   requestHandler;
   1.802 +   
   1.803 +   SchedSlot     ***allSchedSlots;
   1.804 +   VMSQueueStruc **readyToAnimateQs;
   1.805 +   VirtProcr      **masterVPs;
   1.806 +
   1.807 +   void            *semanticEnv;
   1.808 +   void            *OSEventStruc;   //for future, when add I/O to BLIS
   1.809 +   MallocProlog    *freeListHead;
   1.810 +   int32            amtOfOutstandingMem; //total currently allocated
   1.811 +
   1.812 +   void            *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
   1.813 +
   1.814 +   int32            setupComplete;
   1.815 +   volatile int32   masterLock;
   1.816 +
   1.817 +   int32            numMasterInARow[NUM_CORES];//detect back-to-back masterVP
   1.818 +   GateStruc       *workStealingGates[ NUM_CORES ]; //concurrent work-steal
   1.819 +   int32            workStealingLock;
   1.820 +   
   1.821 +   int32            numProcrsCreated; //gives ordering to processor creation
   1.822 +
   1.823 +      //=========== MEASUREMENT STUFF =============
   1.824 +   IntervalProbe  **intervalProbes;
   1.825 +   PrivDynArrayInfo    *dynIntervalProbesInfo;
   1.826 +   HashTable       *probeNameHashTbl;
   1.827 +   int32            masterCreateProbeID;
   1.828 +   float64          createPtInSecs;
   1.829 +   Histogram      **measHists;
   1.830 +   PrivDynArrayInfo *measHistsInfo;
   1.831 +   #ifdef MEAS__TIME_PLUGIN
   1.832 +   Histogram       *reqHdlrLowTimeHist;
   1.833 +   Histogram       *reqHdlrHighTimeHist;
   1.834 +   #endif
   1.835 +   #ifdef MEAS__TIME_MALLOC
   1.836 +   Histogram       *mallocTimeHist;
   1.837 +   Histogram       *freeTimeHist;
   1.838 +   #endif
   1.839 +   #ifdef MEAS__TIME_MASTER_LOCK
   1.840 +   Histogram       *masterLockLowTimeHist;
   1.841 +   Histogram       *masterLockHighTimeHist;
   1.842 +   #endif
   1.843 + }
   1.844 +MasterEnv;
   1.845 +
   1.846 +//=========================  Extra Stuff Data Strucs  =======================
   1.847 +typedef struct
   1.848 + {
   1.849 +
   1.850 + }
   1.851 +VMSExcp;
   1.852 +
   1.853 +struct _GateStruc
   1.854 + {
   1.855 +   int32 gateClosed;
   1.856 +   int32 preGateProgress;
   1.857 +   int32 waitProgress;
   1.858 +   int32 exitProgress;
   1.859 + };
   1.860 +//GateStruc
   1.861 +
   1.862 +//=======================  OS Thread related  ===============================
   1.863 +
   1.864 +void * coreLoop( void *paramsIn );  //standard PThreads fn prototype
   1.865 +void * coreLoop_Seq( void *paramsIn );  //standard PThreads fn prototype
   1.866 +void masterLoop( void *initData, VirtProcr *masterPr );
   1.867 +
   1.868 +
   1.869 +typedef struct
   1.870 + {
   1.871 +   void           *endThdPt;
   1.872 +   unsigned int    coreNum;
   1.873 + }
   1.874 +ThdParams;
   1.875 +
   1.876 +pthread_t       coreLoopThdHandles[ NUM_CORES ];  //pthread's virt-procr state
   1.877 +ThdParams      *coreLoopThdParams [ NUM_CORES ];
   1.878 +pthread_mutex_t suspendLock;
   1.879 +pthread_cond_t  suspend_cond;
   1.880 +
   1.881 +
   1.882 +
   1.883 +//=====================  Global Vars ===================
   1.884 +
   1.885 +volatile MasterEnv      *_VMSMasterEnv;
   1.886 +
   1.887 +
   1.888 +
   1.889 +
   1.890 +//===========================  Function Prototypes  =========================
   1.891 +
   1.892 +
   1.893 +//========== Setup and shutdown ==========
   1.894 +void
   1.895 +VMS__init();
   1.896 +
   1.897 +void
   1.898 +VMS__init_Seq();
   1.899 +
   1.900 +void
   1.901 +VMS__start_the_work_then_wait_until_done();
   1.902 +
   1.903 +void
   1.904 +VMS__start_the_work_then_wait_until_done_Seq();
   1.905 +
   1.906 +inline VirtProcr *
   1.907 +VMS__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
   1.908 +
   1.909 +void
   1.910 +VMS__dissipate_procr( VirtProcr *procrToDissipate );
   1.911 +
   1.912 +   //Use this to create processor inside entry point & other places outside
   1.913 +   // the VMS system boundary (IE, not run in slave nor Master)
   1.914 +VirtProcr *
   1.915 +VMS_ext__create_procr( VirtProcrFnPtr fnPtr, void *initialData );
   1.916 +
   1.917 +void
   1.918 +VMS_ext__dissipate_procr( VirtProcr *procrToDissipate );
   1.919 +
   1.920 +void
   1.921 +VMS__throw_exception( char *msgStr, VirtProcr *reqstPr, VMSExcp *excpData );
   1.922 +
   1.923 +void
   1.924 +VMS__shutdown();
   1.925 +
   1.926 +void
   1.927 +VMS__cleanup_at_end_of_shutdown();
   1.928 +
   1.929 +void *
   1.930 +VMS__give_sem_env_for( VirtProcr *animPr );
   1.931 +
   1.932 +
   1.933 +//==============  Request Related  ===============
   1.934 +
   1.935 +void
   1.936 +VMS__suspend_procr( VirtProcr *callingPr );
   1.937 +
   1.938 +inline void
   1.939 +VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr );
   1.940 +
   1.941 +inline void
   1.942 +VMS__send_sem_request( void *semReqData, VirtProcr *callingPr );
   1.943 +
   1.944 +void
   1.945 +VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr );
   1.946 +
   1.947 +void inline
   1.948 +VMS__send_dissipate_req( VirtProcr *prToDissipate );
   1.949 +
   1.950 +inline void
   1.951 +VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr );
   1.952 +
   1.953 +VMSReqst *
   1.954 +VMS__take_next_request_out_of( VirtProcr *procrWithReq );
   1.955 +
   1.956 +inline void *
   1.957 +VMS__take_sem_reqst_from( VMSReqst *req );
   1.958 +
   1.959 +void inline
   1.960 +VMS__handle_VMSSemReq( VMSReqst *req, VirtProcr *requestingPr, void *semEnv,
   1.961 +                       ResumePrFnPtr resumePrFnPtr );
   1.962 +
   1.963 +//======================== STATS ======================
   1.964 +
   1.965 +//===== RDTSC wrapper ===== //Also runs with x86_64 code
   1.966 +
   1.967 +#define saveTimeStampCountInto(low, high) \
   1.968 +   asm volatile("RDTSC;                   \
   1.969 +                 movl %%eax, %0;          \
   1.970 +                 movl %%edx, %1;"         \
   1.971 +   /* outputs */ : "=m" (low), "=m" (high)\
   1.972 +   /* inputs  */ :                        \
   1.973 +   /* clobber */ : "%eax", "%edx"         \
   1.974 +                );
   1.975 +
   1.976 +#define saveLowTimeStampCountInto(low)    \
   1.977 +   asm volatile("RDTSC;                   \
   1.978 +                 movl %%eax, %0;"         \
   1.979 +   /* outputs */ : "=m" (low)             \
   1.980 +   /* inputs  */ :                        \
   1.981 +   /* clobber */ : "%eax", "%edx"         \
   1.982 +                );
   1.983 +
   1.984 +//====================
   1.985 +#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \
   1.986 +   makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \
   1.987 +   _VMSMasterEnv->measHists[idx] =  \
   1.988 +                       makeFixedBinHist( numBins, startVal, binWidth, name );
   1.989 +
   1.990 +
   1.991 +#define MEAS__SUB_CREATE  /*turn on/off subtraction of create from plugin*/
   1.992 +
   1.993 +#ifdef VPTHREAD
   1.994 +
   1.995 +//VPThread
   1.996 +#define createHistIdx      0
   1.997 +#define mutexLockHistIdx   1
   1.998 +#define mutexUnlockHistIdx 2
   1.999 +#define condWaitHistIdx    3
  1.1000 +#define condSignalHistIdx  4
  1.1001 +
  1.1002 +#define MakeTheMeasHists() \
  1.1003 +   _VMSMasterEnv->measHistsInfo = \
  1.1004 +              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
  1.1005 +   makeAMeasHist( createHistIdx,      "create",        250, 0, 100 ) \
  1.1006 +   makeAMeasHist( mutexLockHistIdx,   "mutex_lock",    50, 0, 100 ) \
  1.1007 +   makeAMeasHist( mutexUnlockHistIdx, "mutex_unlock",  50, 0, 100 ) \
  1.1008 +   makeAMeasHist( condWaitHistIdx,    "cond_wait",     50, 0, 100 ) \
  1.1009 +   makeAMeasHist( condSignalHistIdx,  "cond_signal",   50, 0, 100 )
  1.1010 +
  1.1011 +#endif
  1.1012 +
  1.1013 +
  1.1014 +#ifdef VCILK
  1.1015 +
  1.1016 +//VCilk
  1.1017 +#define spawnHistIdx      0
  1.1018 +#define syncHistIdx       1
  1.1019 +
  1.1020 +#define MakeTheMeasHists() \
  1.1021 +   _VMSMasterEnv->measHistsInfo = \
  1.1022 +              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
  1.1023 +    makeAMeasHist( spawnHistIdx,      "Spawn",        50, 0, 200 ) \
  1.1024 +    makeAMeasHist( syncHistIdx,       "Sync",         50, 0, 200 )
  1.1025 +
  1.1026 +
  1.1027 +#endif
  1.1028 +
  1.1029 +#ifdef SSR
  1.1030 +
  1.1031 +//SSR
  1.1032 +#define SendFromToHistIdx      0
  1.1033 +#define SendOfTypeHistIdx      1
  1.1034 +#define ReceiveFromToHistIdx   2
  1.1035 +#define ReceiveOfTypeHistIdx   3
  1.1036 +
  1.1037 +#define MakeTheMeasHists() \
  1.1038 +   _VMSMasterEnv->measHistsInfo = \
  1.1039 +              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
  1.1040 +    makeAMeasHist( SendFromToHistIdx,   "SendFromTo",    50, 0, 100 ) \
  1.1041 +    makeAMeasHist( SendOfTypeHistIdx,   "SendOfType",    50, 0, 100 ) \
  1.1042 +    makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \
  1.1043 +    makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 )
  1.1044 +
  1.1045 +#endif
  1.1046 +
  1.1047 +//===========================================================================
  1.1048 +//VPThread
  1.1049 +
  1.1050 +
  1.1051 +#define Meas_startCreate \
  1.1052 +    int32 startStamp, endStamp; \
  1.1053 +    saveLowTimeStampCountInto( startStamp ); \
  1.1054 +
  1.1055 +#define Meas_endCreate \
  1.1056 +    saveLowTimeStampCountInto( endStamp ); \
  1.1057 +    addIntervalToHist( startStamp, endStamp, \
  1.1058 +                                 _VMSMasterEnv->measHists[ createHistIdx ] );
  1.1059 +
  1.1060 +#define Meas_startMutexLock \
  1.1061 +    int32 startStamp, endStamp; \
  1.1062 +    saveLowTimeStampCountInto( startStamp ); \
  1.1063 +
  1.1064 +#define Meas_endMutexLock \
  1.1065 +    saveLowTimeStampCountInto( endStamp ); \
  1.1066 +    addIntervalToHist( startStamp, endStamp, \
  1.1067 +                              _VMSMasterEnv->measHists[ mutexLockHistIdx ] );
  1.1068 +
  1.1069 +#define Meas_startMutexUnlock \
  1.1070 +    int32 startStamp, endStamp; \
  1.1071 +    saveLowTimeStampCountInto( startStamp ); \
  1.1072 +
  1.1073 +#define Meas_endMutexUnlock \
  1.1074 +    saveLowTimeStampCountInto( endStamp ); \
  1.1075 +    addIntervalToHist( startStamp, endStamp, \
  1.1076 +                            _VMSMasterEnv->measHists[ mutexUnlockHistIdx ] );
  1.1077 +
  1.1078 +#define Meas_startCondWait \
  1.1079 +    int32 startStamp, endStamp; \
  1.1080 +    saveLowTimeStampCountInto( startStamp ); \
  1.1081 +
  1.1082 +#define Meas_endCondWait \
  1.1083 +    saveLowTimeStampCountInto( endStamp ); \
  1.1084 +    addIntervalToHist( startStamp, endStamp, \
  1.1085 +                               _VMSMasterEnv->measHists[ condWaitHistIdx ] );
  1.1086 +
  1.1087 +#define Meas_startCondSignal \
  1.1088 +    int32 startStamp, endStamp; \
  1.1089 +    saveLowTimeStampCountInto( startStamp ); \
  1.1090 +
  1.1091 +#define Meas_endCondSignal \
  1.1092 +    saveLowTimeStampCountInto( endStamp ); \
  1.1093 +    addIntervalToHist( startStamp, endStamp, \
  1.1094 +                             _VMSMasterEnv->measHists[ condSignalHistIdx ] );
  1.1095 +
  1.1096 +//===========================================================================
  1.1097 +// VCilk
  1.1098 +#define Meas_startSpawn \
  1.1099 +    int32 startStamp, endStamp; \
  1.1100 +    saveLowTimeStampCountInto( startStamp ); \
  1.1101 +
  1.1102 +#define Meas_endSpawn \
  1.1103 +    saveLowTimeStampCountInto( endStamp ); \
  1.1104 +    addIntervalToHist( startStamp, endStamp, \
  1.1105 +                             _VMSMasterEnv->measHists[ spawnHistIdx ] );
  1.1106 +
  1.1107 +#define Meas_startSync \
  1.1108 +    int32 startStamp, endStamp; \
  1.1109 +    saveLowTimeStampCountInto( startStamp ); \
  1.1110 +
  1.1111 +#define Meas_endSync \
  1.1112 +    saveLowTimeStampCountInto( endStamp ); \
  1.1113 +    addIntervalToHist( startStamp, endStamp, \
  1.1114 +                             _VMSMasterEnv->measHists[ syncHistIdx ] );
  1.1115 +
  1.1116 +//===========================================================================
  1.1117 +// SSR
  1.1118 +#define Meas_startSendFromTo \
  1.1119 +    int32 startStamp, endStamp; \
  1.1120 +    saveLowTimeStampCountInto( startStamp ); \
  1.1121 +
  1.1122 +#define Meas_endSendFromTo \
  1.1123 +    saveLowTimeStampCountInto( endStamp ); \
  1.1124 +    addIntervalToHist( startStamp, endStamp, \
  1.1125 +                             _VMSMasterEnv->measHists[ SendFromToHistIdx ] );
  1.1126 +
  1.1127 +#define Meas_startSendOfType \
  1.1128 +    int32 startStamp, endStamp; \
  1.1129 +    saveLowTimeStampCountInto( startStamp ); \
  1.1130 +
  1.1131 +#define Meas_endSendOfType \
  1.1132 +    saveLowTimeStampCountInto( endStamp ); \
  1.1133 +    addIntervalToHist( startStamp, endStamp, \
  1.1134 +                             _VMSMasterEnv->measHists[ SendOfTypeHistIdx ] );
  1.1135 +
  1.1136 +#define Meas_startReceiveFromTo \
  1.1137 +    int32 startStamp, endStamp; \
  1.1138 +    saveLowTimeStampCountInto( startStamp ); \
  1.1139 +
  1.1140 +#define Meas_endReceiveFromTo \
  1.1141 +    saveLowTimeStampCountInto( endStamp ); \
  1.1142 +    addIntervalToHist( startStamp, endStamp, \
  1.1143 +                             _VMSMasterEnv->measHists[ ReceiveFromToHistIdx ] );
  1.1144 +
  1.1145 +#define Meas_startReceiveOfType \
  1.1146 +    int32 startStamp, endStamp; \
  1.1147 +    saveLowTimeStampCountInto( startStamp ); \
  1.1148 +
  1.1149 +#define Meas_endReceiveOfType \
  1.1150 +    saveLowTimeStampCountInto( endStamp ); \
  1.1151 +    addIntervalToHist( startStamp, endStamp, \
  1.1152 +                             _VMSMasterEnv->measHists[ReceiveOfTypeHistIdx ] );
  1.1153 +
  1.1154 +//=====
  1.1155 +
  1.1156 +#include "ProcrContext.h"
  1.1157 +#include "probes.h"
  1.1158 +#include "vutilities.h"
  1.1159 +
  1.1160 +#endif	/* _VMS_H */
  1.1161 +