diff VMS.h @ 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 a18539c0bc37
line diff
     1.1 --- a/VMS.h	Wed Feb 22 11:39:12 2012 -0800
     1.2 +++ b/VMS.h	Sun Mar 04 14:26:35 2012 -0800
     1.3 @@ -20,6 +20,10 @@
     1.4  #include <pthread.h>
     1.5  #include <sys/time.h>
     1.6  
     1.7 +#ifndef _LANG_NAME_
     1.8 +#define _LANG_NAME_ ""
     1.9 +#endif
    1.10 +
    1.11  //=================  Defines: included from separate files  =================
    1.12  //
    1.13  // Note: ALL defines are in other files, none are in here
    1.14 @@ -44,11 +48,15 @@
    1.15  typedef struct _GateStruc     GateStruc;
    1.16  
    1.17  
    1.18 -typedef SlaveVP * (*Sched_Assigner)  ( void *, int );   //semEnv, coreIdx
    1.19 -typedef void  (*RequestHandler)  ( SlaveVP *, void * ); //prWReqst, semEnv
    1.20 -typedef void  (*TopLevelFnPtr)  ( void *, SlaveVP * ); //initData, animPr
    1.21 -typedef void    TopLevelFn      ( void *, SlaveVP * ); //initData, animPr
    1.22 -typedef void  (*ResumeVPFnPtr)   ( SlaveVP *, void * );
    1.23 +typedef SlaveVP * (*Sched_Assigner) ( void *, int       ); //semEnv, coreIdx
    1.24 +typedef void      (*RequestHandler) ( SlaveVP *, void * ); //prWReqst, semEnv
    1.25 +typedef void      (*TopLevelFnPtr)  ( void *, SlaveVP * ); //initData, animSlv
    1.26 +typedef void        TopLevelFn      ( void *, SlaveVP * ); //initData, animSlv
    1.27 +typedef void      (*ResumeSlvFnPtr) ( SlaveVP *, void * );
    1.28 +
    1.29 +//============================ HW Dependent Fns ================================
    1.30 +
    1.31 +#include "VMS__HW_dependent.h"
    1.32  
    1.33  //============================= Statistics ==================================
    1.34  
    1.35 @@ -83,7 +91,7 @@
    1.36  
    1.37  typedef struct
    1.38   { enum VMSSemReqstType reqType;
    1.39 -   SlaveVP           *requestingPr;
    1.40 +   SlaveVP           *requestingSlv;
    1.41     char                *nameStr;  //for create probe
    1.42   }
    1.43   VMSSemReq;
    1.44 @@ -94,12 +102,12 @@
    1.45  struct _SchedSlot
    1.46   {
    1.47     int         workIsDone;
    1.48 -   int         needsProcrAssigned;
    1.49 -   SlaveVP  *procrAssignedToSlot;
    1.50 +   int         needsSlaveAssigned;
    1.51 +   SlaveVP  *slaveAssignedToSlot;
    1.52   };
    1.53  //SchedSlot
    1.54  
    1.55 -/*WARNING: re-arranging this data structure could cause VP switching
    1.56 +/*WARNING: re-arranging this data structure could cause Slv switching
    1.57   *         assembly code to fail -- hard-codes offsets of fields
    1.58   */
    1.59  struct _SlaveVP
    1.60 @@ -117,23 +125,11 @@
    1.61     SchedSlot  *schedSlot;
    1.62     VMSReqst   *requests;
    1.63  
    1.64 -   void       *semanticData; //this livesUSE_GNU here for the life of VP
    1.65 -   void       *dataRetFromReq;//values returned from plugin to VP go here
    1.66 +   void       *semanticData; //this livesUSE_GNU here for the life of Slv
    1.67 +   void       *dataRetFromReq;//values returned from plugin to Slv go here
    1.68  
    1.69        //=========== MEASUREMENT STUFF ==========
    1.70 -       #ifdef MEAS__TIME_STAMP_SUSP
    1.71 -       uint32  preSuspTSCLow;
    1.72 -       uint32  postSuspTSCLow;
    1.73 -       #endif
    1.74 -       #ifdef MEAS__TIME_MASTER /* in SlaveVP because multiple masterVPs*/
    1.75 -       uint32  startMasterTSCLow;USE_GNU
    1.76 -       uint32  endMasterTSCLow;
    1.77 -       #endif
    1.78 -       #ifdef MEAS__TIME_2011_SYS
    1.79 -       TSCountLowHigh  startSusp;
    1.80 -       uint64  totalSuspCycles;
    1.81 -       uint32  numGoodSusp;
    1.82 -       #endif
    1.83 +       MEAS__Insert_Meas_Fields_into_Slave;
    1.84        //========================================
    1.85     
    1.86     float64      createPtInSecs;  //have space but don't use on some configs
    1.87 @@ -141,18 +137,13 @@
    1.88  //SlaveVP
    1.89  
    1.90  
    1.91 -/*WARNING: re-arranging this data structure could cause VP-switching
    1.92 +/*WARNING: re-arranging this data structure could cause Slv-switching
    1.93   *         assembly code to fail -- hard-codes offsets of fields
    1.94   *         (because -O3 messes with things otherwise)
    1.95   */
    1.96  typedef struct
    1.97   {
    1.98 -   union{ //adds padding to put masterLock on its own cache-line to elim
    1.99 -          // false sharing (masterLock is most-accessed var in VMS)
   1.100 -        volatile int32   masterLock;
   1.101 -        char             padding[CACHE_LINE_SZ];    
   1.102 -   } masterLockUnion;
   1.103 -   Sched_Assigner   slaveSchedAssigner;
   1.104 +   Sched_Assigner   slaveAssigner;
   1.105     RequestHandler   requestHandler;
   1.106     
   1.107     SchedSlot     ***allSchedSlots;
   1.108 @@ -161,17 +152,19 @@
   1.109  
   1.110     void            *semanticEnv;
   1.111     void            *OSEventStruc;   //for future, when add I/O to BLIS
   1.112 -   MallocArrays    *freeLists;
   1.113 +   MallocArrays   *freeLists;
   1.114     int32            amtOfOutstandingMem; //total currently allocated
   1.115  
   1.116     void            *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
   1.117  
   1.118     int32            setupComplete;
   1.119 -   //int32            numMasterInARow[NUM_CORES];//detect back-to-back masterVP
   1.120 +   int32            numMasterInARow[NUM_CORES];//detect back-to-back masterVP
   1.121 +   int32            masterLock __align_to_cacheline__;
   1.122     GateStruc       *workStealingGates[ NUM_CORES ]; //concurrent work-steal
   1.123     int32            workStealingLock;
   1.124     
   1.125 -   int32            numVPsCreated; //gives ordering to processor creation
   1.126 +   int32            numSlavesCreated; //gives ordering to processor creation
   1.127 +   int32            numSlavesAlive;   //used to detect when to shutdown
   1.128  
   1.129        //=========== MEASUREMENT STUFF =============
   1.130         IntervalProbe   **intervalProbes;
   1.131 @@ -181,28 +174,12 @@
   1.132         float64           createPtInSecs;
   1.133         Histogram       **measHists;
   1.134         PrivDynArrayInfo *measHistsInfo;
   1.135 -       #ifdef MEAS__TIME_PLUGIN
   1.136 -       Histogram       *reqHdlrLowTimeHist;
   1.137 -       Histogram       *reqHdlrHighTimeHist;
   1.138 -       #endif
   1.139 -       #ifdef MEAS__TIME_MALLOC
   1.140 -       Histogram       *mallocTimeHist;
   1.141 -       Histogram       *freeTimeHist;
   1.142 -       #endif
   1.143 -       #ifdef MEAS__TIME_MASTER_LOCK
   1.144 -       Histogram       *masterLockLowTimeHist;
   1.145 -       Histogram       *masterLockHighTimeHist;
   1.146 -       #endif
   1.147 -       #ifdef MEAS__TIME_2011_SYS
   1.148 -       TSCountLowHigh   startMaster;
   1.149 -       uint64           totalMasterCycles;
   1.150 -       uint32           numMasterAnimations;
   1.151 -       TSCountLowHigh   startReqHdlr;
   1.152 -       uint64           totalPluginCycles;
   1.153 -       uint32           numPluginAnimations;
   1.154 -       uint64           cyclesTillStartMasterLoop;
   1.155 -       TSCountLowHigh   endMasterLoop;
   1.156 -       #endif
   1.157 +       MEAS__Insert_Susp_Meas_Fields_into_MasterEnv;
   1.158 +       MEAS__Insert_Master_Meas_Fields_into_MasterEnv;
   1.159 +       MEAS__Insert_Master_Lock_Meas_Fields_into_MasterEnv;
   1.160 +       MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv;
   1.161 +       MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv;
   1.162 +       MEAS__Insert_System_Meas_Fields_into_MasterEnv;
   1.163        //==========================================
   1.164   }
   1.165  MasterEnv;
   1.166 @@ -237,28 +214,32 @@
   1.167   }
   1.168  ThdParams;
   1.169  
   1.170 +//=============================  Global Vars ================================
   1.171 +
   1.172  pthread_t       coreLoopThdHandles[ NUM_CORES ];  //pthread's virt-procr state
   1.173  ThdParams      *coreLoopThdParams [ NUM_CORES ];
   1.174  pthread_mutex_t suspendLock;
   1.175  pthread_cond_t  suspend_cond;
   1.176  
   1.177 -
   1.178 -
   1.179 -//=============================  Global Vars ================================
   1.180 -
   1.181  volatile MasterEnv      *_VMSMasterEnv __align_to_cacheline__;
   1.182  
   1.183  
   1.184 -
   1.185 -
   1.186  //=========================  Function Prototypes  ===========================
   1.187  
   1.188 +/* MEANING OF   WL  PI  SS  int
   1.189 + * These indicate which places the function is safe to use.  They stand for:
   1.190 + * WL: Wrapper Library
   1.191 + * PI: Plugin 
   1.192 + * SS: Startup and Shutdown
   1.193 + * int: internal to the VMS implementation
   1.194 + */
   1.195  
   1.196  //========== Setup and shutdown ==========
   1.197  void
   1.198 -VMS_int__init();
   1.199 +VMS_SS__init();
   1.200  
   1.201 -Fix seed-procr creation -- put box around language, have lang register stuff
   1.202 +//Fix; 
   1.203 +/*seed-procr creation -- put box around language, have lang register stuff
   1.204          with VMS.
   1.205          have main program explicitly INIT Lang! -- makes more sense to
   1.206          C programmers -- makes it clear that there's a transition.
   1.207 @@ -289,77 +270,83 @@
   1.208          lang's sync constructs -- VMS uses message system to establish tie-pt,
   1.209          each lang defines what a tie-point means to it..  (work with the
   1.210          diff semantics?)
   1.211 +*/
   1.212  void
   1.213 -VMS_WL__start_the_work_then_wait_until_done();
   1.214 +VMS_SS__start_the_work_then_wait_until_done();
   1.215  
   1.216  void
   1.217 -VMS_int__shutdown();
   1.218 +VMS_SS__shutdown();
   1.219  
   1.220  void
   1.221 -VMS_int__cleanup_at_end_of_shutdown();
   1.222 +VMS_SS__cleanup_at_end_of_shutdown();
   1.223  
   1.224  
   1.225  //==============    ===============
   1.226  
   1.227  inline SlaveVP *
   1.228 -VMS_int__create_procr( TopLevelFnPtr fnPtr, void *dataParam );
   1.229 +VMS_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
   1.230 +#define VMS_PI__create_slaveVP VMS_int__create_slaveVP
   1.231 +#define VMS_WL__create_slaveVP VMS_int__create_slaveVP
   1.232  
   1.233  inline void
   1.234 -VMS_int__point_slave_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr,
   1.235 +VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr,
   1.236                              void    *dataParam);
   1.237 +#define VMS_PI__point_slaveVP_to_Fn  VMS_int__point_slaveVP_to_Fn
   1.238 +#define VMS_WL__point_slaveVP_to_Fn  VMS_int__point_slaveVP_to_Fn
   1.239  
   1.240  void
   1.241 -VMS_int__save_return_addr_into_ptd_to_loc(void *ptrToReturnAddrHoldingLoc);
   1.242 -
   1.243 -void
   1.244 -VMS_int__write_return_addr_from_ptd_to_loc(void *ptrToReturnAddrHoldingLoc);
   1.245 -
   1.246 -void
   1.247 -VMS_int__dissipate_procr( SlaveVP *procrToDissipate );
   1.248 +VMS_int__dissipate_SlaveVP( SlaveVP *slaveToDissipate );
   1.249 +#define VMS_PI__dissipate_SlaveVP VMS_int__dissipateSlaveVP
   1.250 +//From WL, dissipate a SlaveVP by sending a request
   1.251  
   1.252     //Use this to create processor inside entry point & other places outside
   1.253     // the VMS system boundary (IE, not run in slave nor Master)
   1.254  SlaveVP *
   1.255 -VMS_ext__create_procr( TopLevelFnPtr fnPtr, void *dataParam );
   1.256 +VMS_ext__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam );
   1.257  
   1.258  void
   1.259 -VMS_ext__dissipate_procr( SlaveVP *procrToDissipate );
   1.260 +VMS_ext__dissipate_slaveVP( SlaveVP *slaveToDissipate );
   1.261  
   1.262  void
   1.263 -VMS_PI__throw_exception( char *msgStr, SlaveVP *reqstPr, VMSExcp *excpData );
   1.264 +VMS_int__throw_exception( char *msgStr, SlaveVP *reqstSlv, VMSExcp *excpData );
   1.265 +#define VMS_PI__throw_exception VMS_int__throw_exception
   1.266 +#define VMS_WL__throw_exception VMS_int__throw_exception
   1.267  
   1.268  void *
   1.269 -VMS_WL__give_sem_env_for( SlaveVP *animPr );
   1.270 +VMS_int__give_sem_env_for( SlaveVP *animSlv );
   1.271 +#define VMS_PI__give_sem_env_for  VMS_int__give_sem_env_for
   1.272 +#define VMS_SS__give_sem_env_for  VMS_int__give_sem_env_for
   1.273 +//No WL version -- not safe!  if use in WL, be sure data rd & wr is stable
   1.274  
   1.275  //==============  Request Related  ===============
   1.276  
   1.277  void
   1.278 -VMS_int__suspend_procr( SlaveVP *callingPr );
   1.279 +VMS_int__suspend_slaveVP_and_send_req( SlaveVP *callingSlv );
   1.280  
   1.281  inline void
   1.282 -VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingPr );
   1.283 +VMS_WL__add_sem_request_in_mallocd_VMSReqst( void *semReqData, SlaveVP *callingSlv );
   1.284  
   1.285  inline void
   1.286 -VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingPr );
   1.287 +VMS_WL__send_sem_request( void *semReqData, SlaveVP *callingSlv );
   1.288  
   1.289  void
   1.290 -VMS_WL__send_create_procr_req( void *semReqData, SlaveVP *reqstingPr );
   1.291 +VMS_WL__send_create_slaveVP_req( void *semReqData, SlaveVP *reqstingSlv );
   1.292  
   1.293  void inline
   1.294  VMS_WL__send_dissipate_req( SlaveVP *prToDissipate );
   1.295  
   1.296  inline void
   1.297 -VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingPr );
   1.298 +VMS_WL__send_VMSSem_request( void *semReqData, SlaveVP *callingSlv );
   1.299  
   1.300  VMSReqst *
   1.301 -VMS_PI__take_next_request_out_of( SlaveVP *procrWithReq );
   1.302 +VMS_PI__take_next_request_out_of( SlaveVP *slaveWithReq );
   1.303  
   1.304  inline void *
   1.305  VMS_PI__take_sem_reqst_from( VMSReqst *req );
   1.306  
   1.307  void inline
   1.308 -VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingPr, void *semEnv,
   1.309 -                       ResumeVPFnPtr resumePrFnPtr );
   1.310 +VMS_PI__handle_VMSSemReq( VMSReqst *req, SlaveVP *requestingSlv, void *semEnv,
   1.311 +                       ResumeSlvFnPtr resumeSlvFnPtr );
   1.312  
   1.313  //======================== MEASUREMENT ======================
   1.314  uint64
   1.315 @@ -368,8 +355,6 @@
   1.316  VMS_WL__give_num_plugin_animations();
   1.317  
   1.318  
   1.319 -
   1.320 -#include "VMS__HW_dependent.h"
   1.321  #include "probes.h"
   1.322  #include "vutilities.h"
   1.323