# HG changeset patch # User Some Random Person # Date 1331555887 25200 # Node ID 8059fb8d5465aba70aa50a537b60d55f25b8d3f8 # Parent 82f7defac8517258c324bf033d091f50f27245bd changed name VMS_primitives.s to VMS_primitives_asm.s and fiddled with includes diff -r 82f7defac851 -r 8059fb8d5465 CoreLoop.c --- a/CoreLoop.c Sat Mar 10 21:48:53 2012 -0800 +++ b/CoreLoop.c Mon Mar 12 05:38:07 2012 -0700 @@ -72,7 +72,7 @@ SlaveVP *currVP; SchedSlot *currSlot, **schedSlots; int32 currSlotIdx; - int32 *addrOfMasterLock; + volatile int32 *addrOfMasterLock; //thing pointed to is volatile, not ptr SlaveVP *thisCoresMasterVP; //Variables used for pthread related things ThdParams *coreCtlrThdParams; diff -r 82f7defac851 -r 8059fb8d5465 Defines/VMS_defs__DEBUG.h --- a/Defines/VMS_defs__DEBUG.h Sat Mar 10 21:48:53 2012 -0800 +++ b/Defines/VMS_defs__DEBUG.h Mon Mar 12 05:38:07 2012 -0700 @@ -6,7 +6,7 @@ * */ -#ifndef _VMS_DEFS_DEBUG_H +#ifndef _VMS_DEFS_DEBUG_H #define _VMS_DEFS_DEBUG_H #define _GNU_SOURCE diff -r 82f7defac851 -r 8059fb8d5465 Defines/VMS_defs__MEAS.h --- a/Defines/VMS_defs__MEAS.h Sat Mar 10 21:48:53 2012 -0800 +++ b/Defines/VMS_defs__MEAS.h Mon Mar 12 05:38:07 2012 -0700 @@ -6,7 +6,7 @@ * */ -#ifndef _VMS_DEFS_MEAS_H +#ifndef _VMS_DEFS_MEAS_H #define _VMS_DEFS_MEAS_H #define _GNU_SOURCE @@ -312,15 +312,10 @@ #define MEAS__Make_Meas_Hists_for_Language #endif - -#ifdef MEAS__TURN_ON_MAKE_HISTS - #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ +#define makeAMeasHist( idx, name, numBins, startVal, binWidth ) \ makeHighestDynArrayIndexBeAtLeast( _VMSMasterEnv->measHistsInfo, idx ); \ _VMSMasterEnv->measHists[idx] = \ makeFixedBinHist( numBins, startVal, binWidth, name ); -#else - #define makeAMeasHist( idx, name, numBins, startVal, binWidth ) -#endif //============================== Probes =================================== diff -r 82f7defac851 -r 8059fb8d5465 Defines/VMS_defs__main.h --- a/Defines/VMS_defs__main.h Sat Mar 10 21:48:53 2012 -0800 +++ b/Defines/VMS_defs__main.h Mon Mar 12 05:38:07 2012 -0700 @@ -6,7 +6,7 @@ * */ -#ifndef _VMS_DEFS_MAIN_H +#ifndef _VMS_DEFS_MAIN_H #define _VMS_DEFS_MAIN_H #define _GNU_SOURCE diff -r 82f7defac851 -r 8059fb8d5465 Hardware_Dependent/VMS__primitives.c --- a/Hardware_Dependent/VMS__primitives.c Sat Mar 10 21:48:53 2012 -0800 +++ b/Hardware_Dependent/VMS__primitives.c Mon Mar 12 05:38:07 2012 -0700 @@ -18,7 +18,7 @@ */ inline void VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, - void *dataParam) + void *dataParam) { void *stackPtr; // Start of Hardware dependent part diff -r 82f7defac851 -r 8059fb8d5465 Hardware_Dependent/VMS__primitives.h --- a/Hardware_Dependent/VMS__primitives.h Sat Mar 10 21:48:53 2012 -0800 +++ b/Hardware_Dependent/VMS__primitives.h Mon Mar 12 05:38:07 2012 -0700 @@ -6,7 +6,7 @@ * */ -#ifndef _VMS__PRIMITIVES_H +#ifndef _VMS__PRIMITIVES_H #define _VMS__PRIMITIVES_H #define _GNU_SOURCE diff -r 82f7defac851 -r 8059fb8d5465 Hardware_Dependent/VMS__primitives.s --- a/Hardware_Dependent/VMS__primitives.s Sat Mar 10 21:48:53 2012 -0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,167 +0,0 @@ -.data - - -.text - -//Save return label address for the coreCtlr to pointer -//Arguments: Pointer to variable holding address -.globl recordCoreCtlrReturnLabelAddr -recordCoreCtlrReturnLabelAddr: - movq $coreCtlrReturn, %rcx #load label address - movq %rcx, (%rdi) #save address to pointer - ret - - -//Trick for 64 bit arch -- copies args from stack into regs, then does jmp to -// the top-level function, which was pointed to by the stack-ptr -.globl startUpTopLevelFn -startUpTopLevelFn: - movq %rdi , %rsi #get second argument from first argument of switchSlv - movq 0x08(%rsp), %rdi #get first argument from stack - movq (%rsp) , %rax #get top-level function's addr from stack - jmp *%rax #jump to the top-level function - -//Switches form CoreCtlr to either a normal Slv VP or the Master VP -//switch to VP's stack and frame ptr then jump to VP's next-instr-ptr -/* SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr - * - * _VMSMasterEnv offsets: - * 0x48 coreCtlrReturnPt - * 0x54 masterLock - */ -.globl switchToSlv -switchToSlv: - #SlaveVP in %rdi - movq %rsp , 0x38(%rdi) #save core ctlr stack pointer - movq %rbp , 0x30(%rdi) #save core ctlr frame pointer - movq 0x10(%rdi), %rsp #restore stack pointer - movq 0x18(%rdi), %rbp #restore frame pointer - movq 0x20(%rdi), %rax #get jmp pointer - jmp *%rax #jmp to Slv -coreCtlrReturn: - ret - - -//switches to core controller. saves return address -/* SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr - * - * _VMSMasterEnv offsets: - * 0x48 coreCtlrReturnPt - * 0x54 masterLock - */ -.globl switchToCoreCtlr -switchToCoreCtlr: - #SlaveVP in %rdi - movq $SlvReturn, 0x20(%rdi) #store return address - movq %rsp , 0x10(%rdi) #save stack pointer - movq %rbp , 0x18(%rdi) #save frame pointer - movq 0x38(%rdi), %rsp #restore stack pointer - movq 0x30(%rdi), %rbp #restore frame pointer - movq $_VMSMasterEnv, %rcx - movq (%rcx) , %rcx - movq 0x48(%rcx), %rax #get CoreCtlrStartPt - jmp *%rax #jmp to CoreCtlr -SlvReturn: - ret - - - -//switches to core controller from master. saves return address -//Releases masterLock so the next MasterLoop can be executed -/* SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr - * - * _VMSMasterEnv offsets: - * 0x48 coreCtlrReturnPt - * 0x54 masterLock - */ -.globl masterSwitchToCoreCtlr -masterSwitchToCoreCtlr: - #SlaveVP in %rdi - movq $MasterReturn, 0x20(%rdi) #store return address - movq %rsp , 0x10(%rdi) #save stack pointer - movq %rbp , 0x18(%rdi) #save frame pointer - movq 0x38(%rdi), %rsp #restore stack pointer - movq 0x30(%rdi), %rbp #restore frame pointer - movq $_VMSMasterEnv, %rcx - movq (%rcx) , %rcx - movq 0x48(%rcx), %rax #get CoreCtlr return pt - movl $0x0 , 0x54(%rcx) #release lock - jmp *%rax #jmp to CoreCtlr -MasterReturn: - ret - - -//Switch to terminateCoreCtlr -//therefor switch to coreCtlr context from master context -// no need to call because the stack is already set up for switchSlv -// and Slv is in %rdi -// and both functions have the same argument. -// do not save register of Slv because this function will never return -/* SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr - * - * _VMSMasterEnv offsets: - * 0x48 coreCtlrReturnPt - * 0x58 masterLock - */ -.globl asmTerminateCoreCtlr -asmTerminateCoreCtlr: - #SlaveVP in %rdi - movq 0x38(%rdi), %rsp #restore stack pointer - movq 0x30(%rdi), %rbp #restore frame pointer - movq $terminateCoreCtlr, %rax - jmp *%rax #jmp to CoreCtlr - - -/* - * This one for the sequential version is special. It discards the current stack - * and returns directly from the coreCtlr after VMS_WL__dissipate_slaveVP was called - */ -.globl asmTerminateCoreCtlrSeq -asmTerminateCoreCtlrSeq: - #SlaveVP in %rdi - movq 0x38(%rdi), %rsp #restore stack pointer - movq 0x30(%rdi), %rbp #restore frame pointer - #argument is in %rdi - call VMS_int__dissipate_slaveVP - movq %rbp , %rsp #goto the coreCtlrs stack - pop %rbp #restore the old framepointer - ret #return from core controller - - -//Takes the return addr off the stack and saves into the loc pointed to by -// by the parameter passed in via rdi. Return addr is at 0x8(%rbp) for 64bit -.globl VMS_int__save_return_into_ptd_to_loc_then_do_ret -VMS_int__save_return_into_ptd_to_loc_then_do_ret: - movq 0x8(%rbp), %rax #get ret address, rbp is the same as in the calling function - movq %rax, (%rdi) #write ret addr into addr passed as param field - ret - - -//Assembly code changes the return addr on the stack to the one -// pointed to by the parameter, then returns. Stack's return addr is at 0x8(%rbp) -.globl VMS_int__return_to_addr_in_ptd_to_loc -VMS_int__return_to_addr_in_ptd_to_loc: - movq (%rdi), %rax #get return addr from addr passed as param - movq %rax, 0x8(%rbp) #write return addr to the stack of the caller - ret - diff -r 82f7defac851 -r 8059fb8d5465 Hardware_Dependent/VMS__primitives_asm.s --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/Hardware_Dependent/VMS__primitives_asm.s Mon Mar 12 05:38:07 2012 -0700 @@ -0,0 +1,167 @@ +.data + + +.text + +//Save return label address for the coreCtlr to pointer +//Arguments: Pointer to variable holding address +.globl recordCoreCtlrReturnLabelAddr +recordCoreCtlrReturnLabelAddr: + movq $coreCtlrReturn, %rcx #load label address + movq %rcx, (%rdi) #save address to pointer + ret + + +//Trick for 64 bit arch -- copies args from stack into regs, then does jmp to +// the top-level function, which was pointed to by the stack-ptr +.globl startUpTopLevelFn +startUpTopLevelFn: + movq %rdi , %rsi #get second argument from first argument of switchSlv + movq 0x08(%rsp), %rdi #get first argument from stack + movq (%rsp) , %rax #get top-level function's addr from stack + jmp *%rax #jump to the top-level function + +//Switches form CoreCtlr to either a normal Slv VP or the Master VP +//switch to VP's stack and frame ptr then jump to VP's next-instr-ptr +/* SlaveVP offsets: + * 0x10 stackPtr + * 0x18 framePtr + * 0x20 resumeInstrPtr + * 0x30 coreCtlrFramePtr + * 0x38 coreCtlrStackPtr + * + * _VMSMasterEnv offsets: + * 0x48 coreCtlrReturnPt + * 0x54 masterLock + */ +.globl switchToSlv +switchToSlv: + #SlaveVP in %rdi + movq %rsp , 0x38(%rdi) #save core ctlr stack pointer + movq %rbp , 0x30(%rdi) #save core ctlr frame pointer + movq 0x10(%rdi), %rsp #restore stack pointer + movq 0x18(%rdi), %rbp #restore frame pointer + movq 0x20(%rdi), %rax #get jmp pointer + jmp *%rax #jmp to Slv +coreCtlrReturn: + ret + + +//switches to core controller. saves return address +/* SlaveVP offsets: + * 0x10 stackPtr + * 0x18 framePtr + * 0x20 resumeInstrPtr + * 0x30 coreCtlrFramePtr + * 0x38 coreCtlrStackPtr + * + * _VMSMasterEnv offsets: + * 0x48 coreCtlrReturnPt + * 0x54 masterLock + */ +.globl switchToCoreCtlr +switchToCoreCtlr: + #SlaveVP in %rdi + movq $SlvReturn, 0x20(%rdi) #store return address + movq %rsp , 0x10(%rdi) #save stack pointer + movq %rbp , 0x18(%rdi) #save frame pointer + movq 0x38(%rdi), %rsp #restore stack pointer + movq 0x30(%rdi), %rbp #restore frame pointer + movq $_VMSMasterEnv, %rcx + movq (%rcx) , %rcx + movq 0x48(%rcx), %rax #get CoreCtlrStartPt + jmp *%rax #jmp to CoreCtlr +SlvReturn: + ret + + + +//switches to core controller from master. saves return address +//Releases masterLock so the next MasterLoop can be executed +/* SlaveVP offsets: + * 0x10 stackPtr + * 0x18 framePtr + * 0x20 resumeInstrPtr + * 0x30 coreCtlrFramePtr + * 0x38 coreCtlrStackPtr + * + * _VMSMasterEnv offsets: + * 0x48 coreCtlrReturnPt + * 0x54 masterLock + */ +.globl masterSwitchToCoreCtlr +masterSwitchToCoreCtlr: + #SlaveVP in %rdi + movq $MasterReturn, 0x20(%rdi) #store return address + movq %rsp , 0x10(%rdi) #save stack pointer + movq %rbp , 0x18(%rdi) #save frame pointer + movq 0x38(%rdi), %rsp #restore stack pointer + movq 0x30(%rdi), %rbp #restore frame pointer + movq $_VMSMasterEnv, %rcx + movq (%rcx) , %rcx + movq 0x48(%rcx), %rax #get CoreCtlr return pt + movl $0x0 , 0x54(%rcx) #release lock + jmp *%rax #jmp to CoreCtlr +MasterReturn: + ret + + +//Switch to terminateCoreCtlr +//therefor switch to coreCtlr context from master context +// no need to call because the stack is already set up for switchSlv +// and Slv is in %rdi +// and both functions have the same argument. +// do not save register of Slv because this function will never return +/* SlaveVP offsets: + * 0x10 stackPtr + * 0x18 framePtr + * 0x20 resumeInstrPtr + * 0x30 coreCtlrFramePtr + * 0x38 coreCtlrStackPtr + * + * _VMSMasterEnv offsets: + * 0x48 coreCtlrReturnPt + * 0x58 masterLock + */ +.globl asmTerminateCoreCtlr +asmTerminateCoreCtlr: + #SlaveVP in %rdi + movq 0x38(%rdi), %rsp #restore stack pointer + movq 0x30(%rdi), %rbp #restore frame pointer + movq $terminateCoreCtlr, %rax + jmp *%rax #jmp to CoreCtlr + + +/* + * This one for the sequential version is special. It discards the current stack + * and returns directly from the coreCtlr after VMS_WL__dissipate_slaveVP was called + */ +.globl asmTerminateCoreCtlrSeq +asmTerminateCoreCtlrSeq: + #SlaveVP in %rdi + movq 0x38(%rdi), %rsp #restore stack pointer + movq 0x30(%rdi), %rbp #restore frame pointer + #argument is in %rdi + call VMS_int__dissipate_slaveVP + movq %rbp , %rsp #goto the coreCtlrs stack + pop %rbp #restore the old framepointer + ret #return from core controller + + +//Takes the return addr off the stack and saves into the loc pointed to by +// by the parameter passed in via rdi. Return addr is at 0x8(%rbp) for 64bit +.globl VMS_int__save_return_into_ptd_to_loc_then_do_ret +VMS_int__save_return_into_ptd_to_loc_then_do_ret: + movq 0x8(%rbp), %rax #get ret address, rbp is the same as in the calling function + movq %rax, (%rdi) #write ret addr into addr passed as param field + ret + + +//Assembly code changes the return addr on the stack to the one +// pointed to by the parameter, then returns. Stack's return addr is at 0x8(%rbp) +.globl VMS_int__return_to_addr_in_ptd_to_loc +VMS_int__return_to_addr_in_ptd_to_loc: + movq (%rdi), %rax #get return addr from addr passed as param + movq %rax, 0x8(%rbp) #write return addr to the stack of the caller + ret + diff -r 82f7defac851 -r 8059fb8d5465 Probes/probes.c --- a/Probes/probes.c Sat Mar 10 21:48:53 2012 -0800 +++ b/Probes/probes.c Mon Mar 12 05:38:07 2012 -0700 @@ -284,17 +284,11 @@ } } -//TODO: change so pass around pointer to probe instead of its array-index.. -// will eliminate chance for timing of resize to cause problems with the -// lookup -- even though don't think it actually can cause problems.. -// there's no need to pass index around -- have hash table for names, and -// only need it once, then have ptr to probe.. the thing about enum the -// index and use that as name is clunky in practice -- just hash. void -VMS_impl__print_stats_of_probe( int32 probeID ) - { IntervalProbe *probe; +VMS_impl__print_stats_of_probe( IntervalProbe *probe ) + { - probe = _VMSMasterEnv->intervalProbes[ probeID ]; +// probe = _VMSMasterEnv->intervalProbes[ probeID ]; print_probe_helper( probe ); } @@ -307,3 +301,4 @@ &VMS_impl__print_stats_of_probe ); fflush( stdout ); } +typedef void (*DynArrayFnPtr) ( void * ); //fn has to cast void * diff -r 82f7defac851 -r 8059fb8d5465 Probes/probes.h --- a/Probes/probes.h Sat Mar 10 21:48:53 2012 -0800 +++ b/Probes/probes.h Mon Mar 12 05:38:07 2012 -0700 @@ -107,7 +107,7 @@ VMS_impl__record_interval_end_in_probe( int32 probeID ); void -VMS_impl__print_stats_of_probe( int32 probeID ); +VMS_impl__print_stats_of_probe( IntervalProbe *probe ) void VMS_impl__print_stats_of_all_probes(); diff -r 82f7defac851 -r 8059fb8d5465 VMS.h --- a/VMS.h Sat Mar 10 21:48:53 2012 -0800 +++ b/VMS.h Mon Mar 12 05:38:07 2012 -0700 @@ -217,7 +217,7 @@ pthread_t coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state ThdParams *coreCtlrThdParams [ NUM_CORES ]; -pthread_mutex_t suspendLock = PTHREAD_MUTEX_INITIALIZER; +pthread_mutex_t suspendLock = PTHREAD_MUTEX_INITIALIZER; pthread_cond_t suspendCond = PTHREAD_COND_INITIALIZER; //========================= Function Prototypes =========================== @@ -295,7 +295,7 @@ inline void VMS_int__point_slaveVP_to_Fn( SlaveVP *slaveVP, TopLevelFnPtr fnPtr, - void *dataParam); + void *dataParam); void VMS_int__dissipate_slaveVP( SlaveVP *slaveToDissipate ); diff -r 82f7defac851 -r 8059fb8d5465 VMS__int.c --- a/VMS__int.c Sat Mar 10 21:48:53 2012 -0800 +++ b/VMS__int.c Mon Mar 12 05:38:07 2012 -0700 @@ -181,9 +181,9 @@ VMS_int__strDup( char *str ) { char *retStr; - retStr = VMS_int__malloc( strlen(str) + 1 ); + retStr = (char *)VMS_int__malloc( strlen(str) + 1 ); if( str == NULL ) return str; strcpy( retStr, str ); - return retStr; + return (char *)retStr; } diff -r 82f7defac851 -r 8059fb8d5465 VMS_primitive_data_types.h --- a/VMS_primitive_data_types.h Sat Mar 10 21:48:53 2012 -0800 +++ b/VMS_primitive_data_types.h Mon Mar 12 05:38:07 2012 -0700 @@ -7,8 +7,8 @@ */ -#ifndef _BLIS_PRIMITIVE_DATA_TYPES_H -#define _BLIS_PRIMITIVE_DATA_TYPES_H +#ifndef _PRIMITIVE_DATA_TYPES_H +#define _PRIMITIVE_DATA_TYPES_H /*For portability, need primitive data types that have a well defined @@ -50,5 +50,5 @@ #define TRUE 1 #define FALSE 0 -#endif /* _BLIS_PRIMITIVE_DATA_TYPES_H */ +#endif /* _PRIMITIVE_DATA_TYPES_H */