changeset 6:ce4ad44fcc23

make hardware independent and port to 64bit
author Merten Sach <msach@mailbox.tu-berlin.de>
date Thu, 16 Jun 2011 14:39:38 +0200
parents f36e9ab2e030
children 778e36c0aa61
files VPThread.h VPThread.s VPThread_PluginFns.c VPThread_Request_Handlers.c VPThread_helper.c VPThread_helper.h VPThread_lib.c
diffstat 7 files changed, 91 insertions(+), 63 deletions(-) [+]
line diff
     1.1 --- a/VPThread.h	Mon Jun 06 18:30:00 2011 +0200
     1.2 +++ b/VPThread.h	Thu Jun 16 14:39:38 2011 +0200
     1.3 @@ -75,7 +75,7 @@
     1.4     VirtProcrFnPtr       fnPtr;
     1.5     int32                coreToScheduleOnto;
     1.6  
     1.7 -   int32                sizeToMalloc;
     1.8 +   size_t                sizeToMalloc;
     1.9     void                *ptrToFree;
    1.10  
    1.11     int32              singletonID;
    1.12 @@ -240,6 +240,9 @@
    1.13  
    1.14  //=======================
    1.15  
    1.16 +void *
    1.17 +VPThread__malloc( size_t sizeToMalloc, VirtProcr *animPr );
    1.18 +
    1.19  void
    1.20  VPThread__init();
    1.21  
     2.1 --- a/VPThread.s	Mon Jun 06 18:30:00 2011 +0200
     2.2 +++ b/VPThread.s	Thu Jun 16 14:39:38 2011 +0200
     2.3 @@ -4,9 +4,8 @@
     2.4  // "endInstrAddr" field, and the return addr is at 0x4(%ebp)
     2.5  .globl asm_save_ret_to_singleton
     2.6  asm_save_ret_to_singleton:
     2.7 -    movl 0x4(%ebp),     %eax   #get ret address, ebp is the same as in the calling function
     2.8 -    movl 0x4(%esp),     %edx   #get argument(singletonPtrAddr) from stack
     2.9 -    movl      %eax,     (%edx) #write ret addr to endInstrAddr field
    2.10 +    movq 0x8(%rbp),     %rax   #get ret address, ebp is the same as in the calling function
    2.11 +    movq     %rax,     (%rdi) #write ret addr to endInstrAddr field
    2.12      ret
    2.13  
    2.14  
    2.15 @@ -15,9 +14,8 @@
    2.16  //The stack's return addr is at 0x4(%%ebp)
    2.17  .globl asm_write_ret_from_singleton
    2.18  asm_write_ret_from_singleton:
    2.19 -    movl 0x4(%esp),    %edx  #get singleton addr from stack
    2.20 -    movl    (%edx),    %eax  #get endInstrAddr field
    2.21 -    movl      %eax,    0x4(%ebp) #write return addr to the stack of the caller
    2.22 +    movq    (%rdi),    %rax  #get endInstrAddr field
    2.23 +    movq      %rax,    0x8(%rbp) #write return addr to the stack of the caller
    2.24      ret
    2.25  
    2.26  
     3.1 --- a/VPThread_PluginFns.c	Mon Jun 06 18:30:00 2011 +0200
     3.2 +++ b/VPThread_PluginFns.c	Thu Jun 16 14:39:38 2011 +0200
     3.3 @@ -11,6 +11,7 @@
     3.4  #include "VMS/Queue_impl/PrivateQueue.h"
     3.5  #include "VPThread.h"
     3.6  #include "VPThread_Request_Handlers.h"
     3.7 +#include "VPThread_helper.h"
     3.8  
     3.9  //=========================== Local Fn Prototypes ===========================
    3.10  
    3.11 @@ -148,49 +149,6 @@
    3.12      }
    3.13   }
    3.14  
    3.15 -/*Re-use this in the entry-point fn
    3.16 - */
    3.17 -inline VirtProcr *
    3.18 -VPThread__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData,
    3.19 -                          VPThdSemEnv *semEnv,    int32 coreToScheduleOnto )
    3.20 - { VirtProcr      *newPr;
    3.21 -   VPThdSemData   *semData;
    3.22 -
    3.23 -      //This is running in master, so use internal version
    3.24 -   newPr = VMS__create_procr( fnPtr, initData );
    3.25 -
    3.26 -   semEnv->numVirtPr += 1;
    3.27 -
    3.28 -   semData = VMS__malloc( sizeof(VPThdSemData) );
    3.29 -   semData->highestTransEntered = -1;
    3.30 -   semData->lastTransEntered    = NULL;
    3.31 -
    3.32 -   newPr->semanticData = semData;
    3.33 -
    3.34 -   //=================== Assign new processor to a core =====================
    3.35 -   #ifdef SEQUENTIAL
    3.36 -   newPr->coreAnimatedBy = 0;
    3.37 -
    3.38 -   #else
    3.39 -
    3.40 -   if(coreToScheduleOnto < 0 || coreToScheduleOnto >= NUM_CORES )
    3.41 -    {    //out-of-range, so round-robin assignment
    3.42 -      newPr->coreAnimatedBy = semEnv->nextCoreToGetNewPr;
    3.43 -
    3.44 -      if( semEnv->nextCoreToGetNewPr >= NUM_CORES - 1 )
    3.45 -          semEnv->nextCoreToGetNewPr  = 0;
    3.46 -      else
    3.47 -          semEnv->nextCoreToGetNewPr += 1;
    3.48 -    }
    3.49 -   else //core num in-range, so use it
    3.50 -    { newPr->coreAnimatedBy = coreToScheduleOnto;
    3.51 -    }
    3.52 -   #endif
    3.53 -   //========================================================================
    3.54 -
    3.55 -   return newPr;
    3.56 - }
    3.57 -
    3.58  inline void
    3.59  handleCreate( VMSReqst *req, VirtProcr *requestingPr, VPThdSemEnv *semEnv  )
    3.60   { VPThdSemReq *semReq;
     4.1 --- a/VPThread_Request_Handlers.c	Mon Jun 06 18:30:00 2011 +0200
     4.2 +++ b/VPThread_Request_Handlers.c	Thu Jun 16 14:39:38 2011 +0200
     4.3 @@ -12,6 +12,7 @@
     4.4  #include "VMS/Queue_impl/PrivateQueue.h"
     4.5  #include "VMS/Hash_impl/PrivateHash.h"
     4.6  #include "VPThread.h"
     4.7 +#include "VMS/vmalloc.h"
     4.8  
     4.9  
    4.10  
    4.11 @@ -33,7 +34,7 @@
    4.12     newMutex->mutexIdx = addToDynArray( newMutex, semEnv->mutexDynArrayInfo );
    4.13  
    4.14        //Now communicate the mutex's identifying int back to requesting procr
    4.15 -   semReq->requestingPr->dataRetFromReq = newMutex->mutexIdx;
    4.16 +   semReq->requestingPr->dataRetFromReq = (void*)newMutex->mutexIdx; //mutexIdx is 32 bit
    4.17  
    4.18        //re-animate the requester
    4.19     resume_procr( requestingPr, semEnv );
    4.20 @@ -120,7 +121,7 @@
    4.21     newCond->condIdx = addToDynArray( newCond, semEnv->condDynArrayInfo );
    4.22  
    4.23        //Now communicate the cond's identifying int back to requesting procr
    4.24 -   semReq->requestingPr->dataRetFromReq = newCond->condIdx;
    4.25 +   semReq->requestingPr->dataRetFromReq = (void*)newCond->condIdx; //condIdx is 32 bit
    4.26     
    4.27        //re-animate the requester
    4.28     resume_procr( requestingPr, semEnv );
    4.29 @@ -162,7 +163,7 @@
    4.30  handleCondSignal( VPThdSemReq *semReq, VPThdSemEnv *semEnv)
    4.31   { VPThdCond   *cond;
    4.32     VPThdMutex  *mutex;
    4.33 -   VirtProcr  *waitingPr, *pr;
    4.34 +   VirtProcr  *waitingPr;
    4.35  
    4.36           Meas_startCondSignal
    4.37        //get cond struc out of array of them that's in the sem env
     5.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     5.2 +++ b/VPThread_helper.c	Thu Jun 16 14:39:38 2011 +0200
     5.3 @@ -0,0 +1,48 @@
     5.4 +
     5.5 +#include <stddef.h>
     5.6 +
     5.7 +#include "VMS/VMS.h"
     5.8 +#include "VPThread.h"
     5.9 +
    5.10 +/*Re-use this in the entry-point fn
    5.11 + */
    5.12 +inline VirtProcr *
    5.13 +VPThread__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData,
    5.14 +                          VPThdSemEnv *semEnv,    int32 coreToScheduleOnto )
    5.15 + { VirtProcr      *newPr;
    5.16 +   VPThdSemData   *semData;
    5.17 +
    5.18 +      //This is running in master, so use internal version
    5.19 +   newPr = VMS__create_procr( fnPtr, initData );
    5.20 +
    5.21 +   semEnv->numVirtPr += 1;
    5.22 +
    5.23 +   semData = VMS__malloc( sizeof(VPThdSemData) );
    5.24 +   semData->highestTransEntered = -1;
    5.25 +   semData->lastTransEntered    = NULL;
    5.26 +
    5.27 +   newPr->semanticData = semData;
    5.28 +
    5.29 +   //=================== Assign new processor to a core =====================
    5.30 +   #ifdef SEQUENTIAL
    5.31 +   newPr->coreAnimatedBy = 0;
    5.32 +
    5.33 +   #else
    5.34 +
    5.35 +   if(coreToScheduleOnto < 0 || coreToScheduleOnto >= NUM_CORES )
    5.36 +    {    //out-of-range, so round-robin assignment
    5.37 +      newPr->coreAnimatedBy = semEnv->nextCoreToGetNewPr;
    5.38 +
    5.39 +      if( semEnv->nextCoreToGetNewPr >= NUM_CORES - 1 )
    5.40 +          semEnv->nextCoreToGetNewPr  = 0;
    5.41 +      else
    5.42 +          semEnv->nextCoreToGetNewPr += 1;
    5.43 +    }
    5.44 +   else //core num in-range, so use it
    5.45 +    { newPr->coreAnimatedBy = coreToScheduleOnto;
    5.46 +    }
    5.47 +   #endif
    5.48 +   //========================================================================
    5.49 +
    5.50 +   return newPr;
    5.51 + }
    5.52 \ No newline at end of file
     6.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.2 +++ b/VPThread_helper.h	Thu Jun 16 14:39:38 2011 +0200
     6.3 @@ -0,0 +1,19 @@
     6.4 +/* 
     6.5 + * File:   VPThread_helper.h
     6.6 + * Author: msach
     6.7 + *
     6.8 + * Created on June 10, 2011, 12:20 PM
     6.9 + */
    6.10 +
    6.11 +#include "VMS/VMS.h"
    6.12 +#include "VPThread.h"
    6.13 +
    6.14 +#ifndef VPTHREAD_HELPER_H
    6.15 +#define	VPTHREAD_HELPER_H
    6.16 +
    6.17 +inline VirtProcr *
    6.18 +VPThread__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData,
    6.19 +                          VPThdSemEnv *semEnv,    int32 coreToScheduleOnto );
    6.20 +
    6.21 +#endif	/* VPTHREAD_HELPER_H */
    6.22 +
     7.1 --- a/VPThread_lib.c	Mon Jun 06 18:30:00 2011 +0200
     7.2 +++ b/VPThread_lib.c	Thu Jun 16 14:39:38 2011 +0200
     7.3 @@ -10,6 +10,7 @@
     7.4  
     7.5  #include "VMS/VMS.h"
     7.6  #include "VPThread.h"
     7.7 +#include "VPThread_helper.h"
     7.8  #include "VMS/Queue_impl/PrivateQueue.h"
     7.9  #include "VMS/Hash_impl/PrivateHash.h"
    7.10  
    7.11 @@ -159,7 +160,7 @@
    7.12     //masterEnv, a global var, now is partially set up by init_VMS
    7.13     
    7.14     //Moved here from VMS.c because this is not parallel construct independent
    7.15 -   MakeTheMeasHists
    7.16 +   MakeTheMeasHists();
    7.17  
    7.18     VPThread__init_Helper();
    7.19   }
    7.20 @@ -205,10 +206,10 @@
    7.21     semanticEnv->nextCoreToGetNewPr = 0;
    7.22  
    7.23     semanticEnv->mutexDynArrayInfo  =
    7.24 -      makePrivDynArrayOfSize( &(semanticEnv->mutexDynArray), INIT_NUM_MUTEX );
    7.25 +      makePrivDynArrayOfSize( (void*)&(semanticEnv->mutexDynArray), INIT_NUM_MUTEX );
    7.26  
    7.27     semanticEnv->condDynArrayInfo   =
    7.28 -      makePrivDynArrayOfSize( &(semanticEnv->condDynArray),  INIT_NUM_COND );
    7.29 +      makePrivDynArrayOfSize( (void*)&(semanticEnv->condDynArray),  INIT_NUM_COND );
    7.30     
    7.31     //TODO: bug -- turn these arrays into dyn arrays to eliminate limit
    7.32     //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( );
    7.33 @@ -228,10 +229,10 @@
    7.34   */
    7.35  void
    7.36  VPThread__cleanup_after_shutdown()
    7.37 - { VPThdSemEnv *semEnv;
    7.38 + { /*VPThdSemEnv *semEnv;
    7.39     int32           coreIdx,     idx,   highestIdx;
    7.40     VPThdMutex      **mutexArray, *mutex;
    7.41 -   VPThdCond       **condArray, *cond;
    7.42 +   VPThdCond       **condArray, *cond; */
    7.43   
    7.44   /* It's all allocated inside VMS's big chunk -- that's about to be freed, so
    7.45   *  nothing to do here
    7.46 @@ -330,7 +331,7 @@
    7.47  //===========================================================================
    7.48  
    7.49  void *
    7.50 -VPThread__malloc( int32 sizeToMalloc, VirtProcr *animPr )
    7.51 +VPThread__malloc( size_t sizeToMalloc, VirtProcr *animPr )
    7.52   { VPThdSemReq  reqData;
    7.53  
    7.54     reqData.reqType      = malloc_req;
    7.55 @@ -384,7 +385,7 @@
    7.56  
    7.57     VMS__send_sem_request( &reqData, animPr );
    7.58  
    7.59 -   return animPr->dataRetFromReq;
    7.60 +   return (int32)animPr->dataRetFromReq; //mutexid is 32bit wide
    7.61   }
    7.62  
    7.63  inline void
    7.64 @@ -421,7 +422,7 @@
    7.65  
    7.66     VMS__send_sem_request( &reqData, animPr );
    7.67  
    7.68 -   return animPr->dataRetFromReq;
    7.69 +   return (int32)animPr->dataRetFromReq; //condIdx is 32 bit wide
    7.70   }
    7.71  
    7.72  inline void
    7.73 @@ -460,8 +461,8 @@
    7.74   */
    7.75  
    7.76  /*asm function declarations*/
    7.77 -void asm_save_ret_to_singleton(VPThdSingleton **singletonPtrAddr);
    7.78 -void asm_write_ret_from_singleton(VPThdSingleton **singletonPtrAddr);
    7.79 +void asm_save_ret_to_singleton(VPThdSingleton *singletonPtrAddr);
    7.80 +void asm_write_ret_from_singleton(VPThdSingleton *singletonPtrAddr);
    7.81  
    7.82  /*Fn singleton uses ID as index into array of singleton structs held in the
    7.83   * semantic environment.