changeset 73:d8f12351f7cc

generic VMS lib
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 02 Jun 2011 12:36:14 +0200
parents 5ff1631c26ed
children 77df6692bb29
files CoreLoop.c VMS.h contextSwitch.s
diffstat 3 files changed, 50 insertions(+), 49 deletions(-) [+]
line diff
     1.1 --- a/CoreLoop.c	Mon May 30 18:28:41 2011 +0200
     1.2 +++ b/CoreLoop.c	Thu Jun 02 12:36:14 2011 +0200
     1.3 @@ -75,21 +75,8 @@
     1.4     if(errorCode){ printf("\nset affinity failure\n"); exit(0); }
     1.5  
     1.6     
     1.7 -      //Save addr of "end core loop" label - jump to it to shut down coreloop
     1.8 -      //To get label addr in non-gcc compiler, can trick it by making a call
     1.9 -      // to a fn that does asm that pulls the "return"
    1.10 -      // addr off the stack and stores it in a pointed-to location.
    1.11 -   saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopStartPt));
    1.12 -   
    1.13 -      //Core loop has no values live upon CoreLoopStartPt except
    1.14 -      // _VMSMasterEnv
    1.15 -      // every value in the code is defined by a statement in core loop,
    1.16 -      // after the start point -- with the one exception of _VMSMasterEnv
    1.17 - 
    1.18 -   
    1.19 -      // Get to work!  --  virt procr jumps back here when suspends
    1.20 -      //Note, have to restore the frame-pointer before jump to here, to get
    1.21 -      // this code to work right (readyToAnimateQ and so forth are frame-ptr relative)
    1.22 +   //Save the return address in the SwitchVP function
    1.23 +   saveCoreLoopReturnAddr(&(_VMSMasterEnv->coreLoopReturnPt));
    1.24 
    1.25     
    1.26     while(1){
    1.27     
    1.28 @@ -160,7 +147,7 @@
    1.29      }
    1.30  
    1.31     
    1.32 -   switchToVP(currPr);
    1.33 +   switchToVP(currPr); //The VPs return in here
    1.34     flushRegisters();
    1.35     }//CoreLoop      
    1.36   }
     2.1 --- a/VMS.h	Mon May 30 18:28:41 2011 +0200
     2.2 +++ b/VMS.h	Thu Jun 02 12:36:14 2011 +0200
     2.3 @@ -225,8 +225,7 @@
     2.4     MallocProlog    *freeListHead;
     2.5     int32            amtOfOutstandingMem; //total currently allocated
     2.6  
     2.7 -   void            *coreLoopStartPt;//addr to jump to to re-enter coreLoop
     2.8 -   void            *coreLoopEndPt;  //addr to jump to to shut down a coreLoop
     2.9 +   void            *coreLoopReturnPt;//addr to jump to to re-enter coreLoop
    2.10  
    2.11     int32            setupComplete;
    2.12     volatile int32   masterLock;
    2.13 @@ -403,6 +402,8 @@
    2.14  
    2.15  #define MEAS__SUB_CREATE  /*turn on/off subtraction of create from plugin*/
    2.16  
    2.17 +#ifdef VPTHREAD
    2.18 +
    2.19  //VPThread
    2.20  #define createHistIdx      1
    2.21  #define mutexLockHistIdx   2
    2.22 @@ -410,34 +411,50 @@
    2.23  #define condWaitHistIdx    4
    2.24  #define condSignalHistIdx  5
    2.25  
    2.26 +#define MakeTheMeasHists \
    2.27 +   _VMSMasterEnv->measHistsInfo = \
    2.28 +              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
    2.29 +   makeAMeasHist( createHistIdx,      "Create",        50, 0, 100 ) \
    2.30 +   makeAMeasHist( mutexLockHistIdx,   "mutex lock",    50, 0, 100 ) \
    2.31 +   makeAMeasHist( mutexUnlockHistIdx, "mutex unlock",  50, 0, 100 ) \
    2.32 +   makeAMeasHist( condWaitHistIdx,    "cond wait",     50, 0, 100 ) \
    2.33 +   makeAMeasHist( condSignalHistIdx,  "cond signal",   50, 0, 100 )
    2.34 +
    2.35 +#endif
    2.36 +
    2.37 +
    2.38 +#ifdef VCILK
    2.39 +
    2.40  //VCilk
    2.41  #define spawnHistIdx      1
    2.42  #define syncHistIdx       2
    2.43  
    2.44 +#define MakeTheMeasHists \
    2.45 +   _VMSMasterEnv->measHistsInfo = \
    2.46 +              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
    2.47 +    makeAMeasHist( spawnHistIdx,      "Spawn",        50, 0, 200 ) \
    2.48 +    makeAMeasHist( syncHistIdx,       "Sync",         50, 0, 200 )
    2.49 +
    2.50 +
    2.51 +#endif
    2.52 +
    2.53 +#ifdef SSR
    2.54 +
    2.55  //SSR
    2.56  #define SendFromToHistIdx      1
    2.57  #define SendOfTypeHistIdx      2
    2.58  #define ReceiveFromToHistIdx   3
    2.59  #define ReceiveOfTypeHistIdx   4
    2.60  
    2.61 -
    2.62  #define MakeTheMeasHists \
    2.63     _VMSMasterEnv->measHistsInfo = \
    2.64 -              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200);\
    2.65 -   makeAMeasHist( spawnHistIdx,      "Spawn",        50, 0, 200 ) \
    2.66 -   makeAMeasHist( syncHistIdx,       "Sync",         50, 0, 200 )
    2.67 +              makePrivDynArrayOfSize( (void***)&(_VMSMasterEnv->measHists), 200); \
    2.68 +    makeAMeasHist( SendFromToHistIdx,   "SendFromTo",    50, 0, 100 ) \
    2.69 +    makeAMeasHist( SendOfTypeHistIdx,   "SendOfType",    50, 0, 100 ) \
    2.70 +    makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \
    2.71 +    makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 )
    2.72  
    2.73 -//   makeAMeasHist( createHistIdx,      "Create",        50, 0, 100 ) \
    2.74 -//   makeAMeasHist( mutexLockHistIdx,   "mutex lock",    50, 0, 100 ) \
    2.75 -//   makeAMeasHist( mutexUnlockHistIdx, "mutex unlock",  50, 0, 100 ) \
    2.76 -//   makeAMeasHist( condWaitHistIdx,    "cond wait",     50, 0, 100 ) \
    2.77 -//   makeAMeasHist( condSignalHistIdx,  "cond signal",   50, 0, 100 )
    2.78 -
    2.79 -//   makeAMeasHist( SendFromToHistIdx,   "SendFromTo",    50, 0, 100 ) \
    2.80 -//   makeAMeasHist( SendOfTypeHistIdx,   "SendOfType",    50, 0, 100 ) \
    2.81 -//   makeAMeasHist( ReceiveFromToHistIdx,"ReceiveFromTo", 50, 0, 100 ) \
    2.82 -//   makeAMeasHist( ReceiveOfTypeHistIdx,"ReceiveOfType", 50, 0, 100 )
    2.83 -
    2.84 +#endif
    2.85  
    2.86  //===========================================================================
    2.87  //VPThread
     3.1 --- a/contextSwitch.s	Mon May 30 18:28:41 2011 +0200
     3.2 +++ b/contextSwitch.s	Thu Jun 02 12:36:14 2011 +0200
     3.3 @@ -1,5 +1,3 @@
     3.4 -#include "VMS.h"
     3.5 -
     3.6  .data
     3.7  
     3.8  
     3.9 @@ -26,9 +24,8 @@
    3.10   * 0x20 coreLoopStackPtr
    3.11   *
    3.12   * _VMSMasterEnv  offsets:
    3.13 - * 0x24 coreLoopStartPt
    3.14 - * 0x28 coreLoopEndPt
    3.15 - * 0x30 masterLock
    3.16 + * 0x24 coreLoopReturnPt
    3.17 + * 0x2c masterLock
    3.18   */
    3.19  .globl switchToVP
    3.20  switchToVP:
    3.21 @@ -52,9 +49,9 @@
    3.22   * 0x20 coreLoopStackPtr
    3.23   *
    3.24   * _VMSMasterEnv  offsets:
    3.25 - * 0x24 coreLoopStartPt
    3.26 + * 0x24 coreLoopReturnPt
    3.27   * 0x28 coreLoopEndPt
    3.28 - * 0x30 masterLock
    3.29 + * 0x2c masterLock
    3.30   */
    3.31  .globl switchToCoreLoop
    3.32  switchToCoreLoop:
    3.33 @@ -74,6 +71,7 @@
    3.34  
    3.35  
    3.36  //switches to core loop from master. saves return address
    3.37 +//Releases masterLock so the next MasterLoop can be executed
    3.38  /* VirtProcr  offsets:
    3.39   * 0xc  stackPtr
    3.40   * 0x10 framePtr
    3.41 @@ -82,9 +80,8 @@
    3.42   * 0x20 coreLoopStackPtr
    3.43   *
    3.44   * _VMSMasterEnv  offsets:
    3.45 - * 0x24 coreLoopStartPt
    3.46 - * 0x28 coreLoopEndPt
    3.47 - * 0x30 masterLock
    3.48 + * 0x24 coreLoopReturnPt
    3.49 + * 0x2c masterLock
    3.50   */
    3.51  .globl masterSwitchToCoreLoop
    3.52  masterSwitchToCoreLoop:
    3.53 @@ -97,15 +94,16 @@
    3.54      movl    $_VMSMasterEnv, %ecx
    3.55      movl    (%ecx)    , %ecx
    3.56      movl    0x24(%ecx), %eax         #get CoreLoopStartPt
    3.57 -    movl    $0x0      , 0x30(%ecx)   #release lock
    3.58 +    movl    $0x0      , 0x2c(%ecx)   #release lock
    3.59      jmp     *%eax                    #jmp to CoreLoop
    3.60  MasterReturn:
    3.61      ret
    3.62  
    3.63  
    3.64  //Switch to terminateCoreLoop
    3.65 -//no need to call because the stack is already set up for switchVP
    3.66 -//do not save register of VP because this function will never return
    3.67 +// no need to call because the stack is already set up for switchVP
    3.68 +// and both functions have the same argument.
    3.69 +// do not save register of VP because this function will never return
    3.70  /* VirtProcr  offsets:
    3.71   * 0xc  stackPtr
    3.72   * 0x10 framePtr
    3.73 @@ -114,9 +112,8 @@
    3.74   * 0x20 coreLoopStackPtr
    3.75   *
    3.76   * _VMSMasterEnv  offsets:
    3.77 - * 0x24 coreLoopStartPt
    3.78 - * 0x28 coreLoopEndPt
    3.79 - * 0x30 masterLock
    3.80 + * 0x24 coreLoopReturnPt
    3.81 + * 0x2c masterLock
    3.82   */
    3.83  .globl asmTerminateCoreLoop
    3.84  asmTerminateCoreLoop: