# HG changeset patch # User Merten Sach # Date 1308227978 -7200 # Node ID ce4ad44fcc23c341191f2321adebfca1650bfc06 # Parent f36e9ab2e0302d0e64569d21d6640d63032acb3d make hardware independent and port to 64bit diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread.h --- a/VPThread.h Mon Jun 06 18:30:00 2011 +0200 +++ b/VPThread.h Thu Jun 16 14:39:38 2011 +0200 @@ -75,7 +75,7 @@ VirtProcrFnPtr fnPtr; int32 coreToScheduleOnto; - int32 sizeToMalloc; + size_t sizeToMalloc; void *ptrToFree; int32 singletonID; @@ -240,6 +240,9 @@ //======================= +void * +VPThread__malloc( size_t sizeToMalloc, VirtProcr *animPr ); + void VPThread__init(); diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread.s --- a/VPThread.s Mon Jun 06 18:30:00 2011 +0200 +++ b/VPThread.s Thu Jun 16 14:39:38 2011 +0200 @@ -4,9 +4,8 @@ // "endInstrAddr" field, and the return addr is at 0x4(%ebp) .globl asm_save_ret_to_singleton asm_save_ret_to_singleton: - movl 0x4(%ebp), %eax #get ret address, ebp is the same as in the calling function - movl 0x4(%esp), %edx #get argument(singletonPtrAddr) from stack - movl %eax, (%edx) #write ret addr to endInstrAddr field + movq 0x8(%rbp), %rax #get ret address, ebp is the same as in the calling function + movq %rax, (%rdi) #write ret addr to endInstrAddr field ret @@ -15,9 +14,8 @@ //The stack's return addr is at 0x4(%%ebp) .globl asm_write_ret_from_singleton asm_write_ret_from_singleton: - movl 0x4(%esp), %edx #get singleton addr from stack - movl (%edx), %eax #get endInstrAddr field - movl %eax, 0x4(%ebp) #write return addr to the stack of the caller + movq (%rdi), %rax #get endInstrAddr field + movq %rax, 0x8(%rbp) #write return addr to the stack of the caller ret diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread_PluginFns.c --- a/VPThread_PluginFns.c Mon Jun 06 18:30:00 2011 +0200 +++ b/VPThread_PluginFns.c Thu Jun 16 14:39:38 2011 +0200 @@ -11,6 +11,7 @@ #include "VMS/Queue_impl/PrivateQueue.h" #include "VPThread.h" #include "VPThread_Request_Handlers.h" +#include "VPThread_helper.h" //=========================== Local Fn Prototypes =========================== @@ -148,49 +149,6 @@ } } -/*Re-use this in the entry-point fn - */ -inline VirtProcr * -VPThread__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData, - VPThdSemEnv *semEnv, int32 coreToScheduleOnto ) - { VirtProcr *newPr; - VPThdSemData *semData; - - //This is running in master, so use internal version - newPr = VMS__create_procr( fnPtr, initData ); - - semEnv->numVirtPr += 1; - - semData = VMS__malloc( sizeof(VPThdSemData) ); - semData->highestTransEntered = -1; - semData->lastTransEntered = NULL; - - newPr->semanticData = semData; - - //=================== Assign new processor to a core ===================== - #ifdef SEQUENTIAL - newPr->coreAnimatedBy = 0; - - #else - - if(coreToScheduleOnto < 0 || coreToScheduleOnto >= NUM_CORES ) - { //out-of-range, so round-robin assignment - newPr->coreAnimatedBy = semEnv->nextCoreToGetNewPr; - - if( semEnv->nextCoreToGetNewPr >= NUM_CORES - 1 ) - semEnv->nextCoreToGetNewPr = 0; - else - semEnv->nextCoreToGetNewPr += 1; - } - else //core num in-range, so use it - { newPr->coreAnimatedBy = coreToScheduleOnto; - } - #endif - //======================================================================== - - return newPr; - } - inline void handleCreate( VMSReqst *req, VirtProcr *requestingPr, VPThdSemEnv *semEnv ) { VPThdSemReq *semReq; diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread_Request_Handlers.c --- a/VPThread_Request_Handlers.c Mon Jun 06 18:30:00 2011 +0200 +++ b/VPThread_Request_Handlers.c Thu Jun 16 14:39:38 2011 +0200 @@ -12,6 +12,7 @@ #include "VMS/Queue_impl/PrivateQueue.h" #include "VMS/Hash_impl/PrivateHash.h" #include "VPThread.h" +#include "VMS/vmalloc.h" @@ -33,7 +34,7 @@ newMutex->mutexIdx = addToDynArray( newMutex, semEnv->mutexDynArrayInfo ); //Now communicate the mutex's identifying int back to requesting procr - semReq->requestingPr->dataRetFromReq = newMutex->mutexIdx; + semReq->requestingPr->dataRetFromReq = (void*)newMutex->mutexIdx; //mutexIdx is 32 bit //re-animate the requester resume_procr( requestingPr, semEnv ); @@ -120,7 +121,7 @@ newCond->condIdx = addToDynArray( newCond, semEnv->condDynArrayInfo ); //Now communicate the cond's identifying int back to requesting procr - semReq->requestingPr->dataRetFromReq = newCond->condIdx; + semReq->requestingPr->dataRetFromReq = (void*)newCond->condIdx; //condIdx is 32 bit //re-animate the requester resume_procr( requestingPr, semEnv ); @@ -162,7 +163,7 @@ handleCondSignal( VPThdSemReq *semReq, VPThdSemEnv *semEnv) { VPThdCond *cond; VPThdMutex *mutex; - VirtProcr *waitingPr, *pr; + VirtProcr *waitingPr; Meas_startCondSignal //get cond struc out of array of them that's in the sem env diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread_helper.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VPThread_helper.c Thu Jun 16 14:39:38 2011 +0200 @@ -0,0 +1,48 @@ + +#include + +#include "VMS/VMS.h" +#include "VPThread.h" + +/*Re-use this in the entry-point fn + */ +inline VirtProcr * +VPThread__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData, + VPThdSemEnv *semEnv, int32 coreToScheduleOnto ) + { VirtProcr *newPr; + VPThdSemData *semData; + + //This is running in master, so use internal version + newPr = VMS__create_procr( fnPtr, initData ); + + semEnv->numVirtPr += 1; + + semData = VMS__malloc( sizeof(VPThdSemData) ); + semData->highestTransEntered = -1; + semData->lastTransEntered = NULL; + + newPr->semanticData = semData; + + //=================== Assign new processor to a core ===================== + #ifdef SEQUENTIAL + newPr->coreAnimatedBy = 0; + + #else + + if(coreToScheduleOnto < 0 || coreToScheduleOnto >= NUM_CORES ) + { //out-of-range, so round-robin assignment + newPr->coreAnimatedBy = semEnv->nextCoreToGetNewPr; + + if( semEnv->nextCoreToGetNewPr >= NUM_CORES - 1 ) + semEnv->nextCoreToGetNewPr = 0; + else + semEnv->nextCoreToGetNewPr += 1; + } + else //core num in-range, so use it + { newPr->coreAnimatedBy = coreToScheduleOnto; + } + #endif + //======================================================================== + + return newPr; + } \ No newline at end of file diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread_helper.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/VPThread_helper.h Thu Jun 16 14:39:38 2011 +0200 @@ -0,0 +1,19 @@ +/* + * File: VPThread_helper.h + * Author: msach + * + * Created on June 10, 2011, 12:20 PM + */ + +#include "VMS/VMS.h" +#include "VPThread.h" + +#ifndef VPTHREAD_HELPER_H +#define VPTHREAD_HELPER_H + +inline VirtProcr * +VPThread__create_procr_helper( VirtProcrFnPtr fnPtr, void *initData, + VPThdSemEnv *semEnv, int32 coreToScheduleOnto ); + +#endif /* VPTHREAD_HELPER_H */ + diff -r f36e9ab2e030 -r ce4ad44fcc23 VPThread_lib.c --- a/VPThread_lib.c Mon Jun 06 18:30:00 2011 +0200 +++ b/VPThread_lib.c Thu Jun 16 14:39:38 2011 +0200 @@ -10,6 +10,7 @@ #include "VMS/VMS.h" #include "VPThread.h" +#include "VPThread_helper.h" #include "VMS/Queue_impl/PrivateQueue.h" #include "VMS/Hash_impl/PrivateHash.h" @@ -159,7 +160,7 @@ //masterEnv, a global var, now is partially set up by init_VMS //Moved here from VMS.c because this is not parallel construct independent - MakeTheMeasHists + MakeTheMeasHists(); VPThread__init_Helper(); } @@ -205,10 +206,10 @@ semanticEnv->nextCoreToGetNewPr = 0; semanticEnv->mutexDynArrayInfo = - makePrivDynArrayOfSize( &(semanticEnv->mutexDynArray), INIT_NUM_MUTEX ); + makePrivDynArrayOfSize( (void*)&(semanticEnv->mutexDynArray), INIT_NUM_MUTEX ); semanticEnv->condDynArrayInfo = - makePrivDynArrayOfSize( &(semanticEnv->condDynArray), INIT_NUM_COND ); + makePrivDynArrayOfSize( (void*)&(semanticEnv->condDynArray), INIT_NUM_COND ); //TODO: bug -- turn these arrays into dyn arrays to eliminate limit //semanticEnv->singletonHasBeenExecutedFlags = makeDynArrayInfo( ); @@ -228,10 +229,10 @@ */ void VPThread__cleanup_after_shutdown() - { VPThdSemEnv *semEnv; + { /*VPThdSemEnv *semEnv; int32 coreIdx, idx, highestIdx; VPThdMutex **mutexArray, *mutex; - VPThdCond **condArray, *cond; + VPThdCond **condArray, *cond; */ /* It's all allocated inside VMS's big chunk -- that's about to be freed, so * nothing to do here @@ -330,7 +331,7 @@ //=========================================================================== void * -VPThread__malloc( int32 sizeToMalloc, VirtProcr *animPr ) +VPThread__malloc( size_t sizeToMalloc, VirtProcr *animPr ) { VPThdSemReq reqData; reqData.reqType = malloc_req; @@ -384,7 +385,7 @@ VMS__send_sem_request( &reqData, animPr ); - return animPr->dataRetFromReq; + return (int32)animPr->dataRetFromReq; //mutexid is 32bit wide } inline void @@ -421,7 +422,7 @@ VMS__send_sem_request( &reqData, animPr ); - return animPr->dataRetFromReq; + return (int32)animPr->dataRetFromReq; //condIdx is 32 bit wide } inline void @@ -460,8 +461,8 @@ */ /*asm function declarations*/ -void asm_save_ret_to_singleton(VPThdSingleton **singletonPtrAddr); -void asm_write_ret_from_singleton(VPThdSingleton **singletonPtrAddr); +void asm_save_ret_to_singleton(VPThdSingleton *singletonPtrAddr); +void asm_write_ret_from_singleton(VPThdSingleton *singletonPtrAddr); /*Fn singleton uses ID as index into array of singleton structs held in the * semantic environment.