# HG changeset patch # User Some Random Person # Date 1331915993 25200 # Node ID a0ac58d8201c02d25c21cc7390c7277ddf8da614 # Parent 421bde2a07d70b7f68897d24ed6a912221641dc4 cleaning -- more general rearrangement, moving things and adding comments diff -r 421bde2a07d7 -r a0ac58d8201c AnimationMaster.c --- a/AnimationMaster.c Thu Mar 15 20:47:54 2012 -0700 +++ b/AnimationMaster.c Fri Mar 16 09:39:53 2012 -0700 @@ -183,7 +183,7 @@ //put the chosen slave into slot, and adjust flags and state if( assignedSlaveVP != NULL ) { currSlot->slaveAssignedToSlot = assignedSlaveVP; - assignedSlaveVP->schedSlot = currSlot; + assignedSlaveVP->schedSlotAssignedTo = currSlot; currSlot->needsSlaveAssigned = FALSE; numSlotsFilled += 1; } diff -r 421bde2a07d7 -r a0ac58d8201c Hardware_Dependent/VMS__HW_measurement.h --- a/Hardware_Dependent/VMS__HW_measurement.h Thu Mar 15 20:47:54 2012 -0700 +++ b/Hardware_Dependent/VMS__HW_measurement.h Fri Mar 16 09:39:53 2012 -0700 @@ -10,6 +10,16 @@ #define _VMS__HW_MEASUREMENT_H #define _GNU_SOURCE + +//=================== Macros to Capture Measurements ====================== + +typedef union + { uint32 lowHigh[2]; + uint64 longVal; + } +TSCountLowHigh; + + //=================== Macros to Capture Measurements ====================== // //===== RDTSC wrapper ===== @@ -40,6 +50,9 @@ /* clobber */ : "%eax", "%edx" \ ); +inline TSCount getTSCount(); + + //For code that calculates normalization-offset between TSC counts of // different cores. //#define NUM_TSC_ROUND_TRIPS 10 diff -r 421bde2a07d7 -r a0ac58d8201c Hardware_Dependent/VMS__primitives_asm.s --- a/Hardware_Dependent/VMS__primitives_asm.s Thu Mar 15 20:47:54 2012 -0700 +++ b/Hardware_Dependent/VMS__primitives_asm.s Fri Mar 16 09:39:53 2012 -0700 @@ -7,7 +7,7 @@ //Arguments: Pointer to variable holding address .globl recordCoreCtlrReturnLabelAddr recordCoreCtlrReturnLabelAddr: - movq $coreCtlrReturn, %rcx #load label address + movq $coreCtlrReturn, %rcx #load label address movq %rcx, (%rdi) #save address to pointer ret @@ -24,24 +24,24 @@ //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 + * 0x00 stackPtr + * 0x08 framePtr + * 0x10 resumeInstrPtr + * 0x18 coreCtlrFramePtr + * 0x20 coreCtlrStackPtr * * _VMSMasterEnv offsets: - * 0x0 coreCtlrReturnPt - * 0x8 masterLock + * 0x00 coreCtlrReturnPt + * 0x08 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 + movq %rsp , 0x20(%rdi) #save core ctlr stack pointer + movq %rbp , 0x18(%rdi) #save core ctlr frame pointer + movq 0x00(%rdi), %rsp #restore stack pointer + movq 0x08(%rdi), %rbp #restore frame pointer + movq 0x10(%rdi), %rax #get jmp pointer jmp *%rax #jmp to Slv coreCtlrReturn: ret @@ -49,24 +49,24 @@ //switches to core controller. saves return address /* SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr + * 0x00 stackPtr + * 0x08 framePtr + * 0x10 resumeInstrPtr + * 0x18 coreCtlrFramePtr + * 0x20 coreCtlrStackPtr * * _VMSMasterEnv offsets: - * 0x0 coreCtlrReturnPt - * 0x8 masterLock + * 0x00 coreCtlrReturnPt + * 0x08 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 $SlvReturn, 0x10(%rdi) #store return address + movq %rsp , 0x00(%rdi) #save stack pointer + movq %rbp , 0x08(%rdi) #save frame pointer + movq 0x20(%rdi), %rsp #restore stack pointer + movq 0x18(%rdi), %rbp #restore frame pointer movq $_VMSMasterEnv, %rcx movq (%rcx), %rcx #_VMSMasterEnv is pointer to struct movq 0x00(%rcx), %rax #get CoreCtlrStartPt @@ -79,24 +79,24 @@ //switches to core controller from master. saves return address //Releases masterLock so the next AnimationMaster can be executed /* SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr + * 0x00 stackPtr + * 0x08 framePtr + * 0x10 resumeInstrPtr + * 0x18 coreCtlrFramePtr + * 0x20 coreCtlrStackPtr * * _VMSMasterEnv offsets: - * 0x0 coreCtlrReturnPt - * 0x8 masterLock + * 0x00 coreCtlrReturnPt + * 0x08 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 $MasterReturn, 0x10(%rdi) #store return address + movq %rsp , 0x00(%rdi) #save stack pointer + movq %rbp , 0x08(%rdi) #save frame pointer + movq 0x20(%rdi), %rsp #restore stack pointer + movq 0x18(%rdi), %rbp #restore frame pointer movq $_VMSMasterEnv, %rcx movq (%rcx), %rcx #_VMSMasterEnv is pointer to struct movq 0x00(%rcx), %rax #get CoreCtlr return pt @@ -115,20 +115,20 @@ *Do not save registers of Slv because this function will never return * * SlaveVP offsets: - * 0x10 stackPtr - * 0x18 framePtr - * 0x20 resumeInstrPtr - * 0x30 coreCtlrFramePtr - * 0x38 coreCtlrStackPtr + * 0x00 stackPtr + * 0x08 framePtr + * 0x10 resumeInstrPtr + * 0x18 coreCtlrFramePtr + * 0x20 coreCtlrStackPtr * * _VMSMasterEnv offsets: - * 0x0 coreCtlrReturnPt - * 0x8 masterLock + * 0x00 coreCtlrReturnPt + * 0x08 masterLock */ .globl asmTerminateCoreCtlr asmTerminateCoreCtlr: #SlaveVP ptr is in %rdi - movq 0x38(%rdi), %rsp #restore stack pointer - movq 0x30(%rdi), %rbp #restore frame pointer + movq 0x20(%rdi), %rsp #restore stack pointer + movq 0x18(%rdi), %rbp #restore frame pointer movq $terminateCoreCtlr, %rax jmp *%rax #jmp to fn that ends the pthread @@ -140,8 +140,8 @@ .globl asmTerminateCoreCtlrSeq asmTerminateCoreCtlrSeq: #SlaveVP in %rdi - movq 0x38(%rdi), %rsp #restore stack pointer - movq 0x30(%rdi), %rbp #restore frame pointer + movq 0x20(%rdi), %rsp #restore stack pointer + movq 0x18(%rdi), %rbp #restore frame pointer #argument is in %rdi call VMS_int__dissipate_slaveVP movq %rbp , %rsp #goto the coreCtlrs stack @@ -153,8 +153,8 @@ // 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 + movq 0x08(%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 @@ -162,7 +162,7 @@ // 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 + movq (%rdi), %rax #get return addr from addr passed as param + movq %rax, 0x08(%rbp) #write return addr to the stack of the caller ret diff -r 421bde2a07d7 -r a0ac58d8201c VMS.h --- a/VMS.h Thu Mar 15 20:47:54 2012 -0700 +++ b/VMS.h Fri Mar 16 09:39:53 2012 -0700 @@ -29,12 +29,7 @@ //================================ Typedefs ================================= // -typedef unsigned long long TSCount; -typedef union - { uint32 lowHigh[2]; - uint64 longVal; - } -TSCountLowHigh; +typedef unsigned long long TSCount; typedef struct _SchedSlot SchedSlot; typedef struct _VMSReqst VMSReqst; @@ -54,9 +49,6 @@ #include "Hardware_Dependent/VMS__HW_measurement.h" #include "Hardware_Dependent/VMS__primitives.h" -//============================= Statistics ================================== - -inline TSCount getTSCount(); //============= Request Related =========== // @@ -113,26 +105,29 @@ }; //SchedSlot -/*WARNING: re-arranging this data structure could cause Slv switching - * assembly code to fail -- hard-codes offsets of fields +/*This structure embodies the state of a slaveVP. It is reused for masterVP + * and shutdownVPs. */ struct _SlaveVP - { int slaveID; //each slave given a unique ID - int coreAnimatedBy; - void *startOfStack; - void *stackPtr; - void *framePtr; - void *resumeInstrPtr; - - void *coreCtlrStartPt; //allows proto-runtime to be linked later + { //The offsets of these fields are hard-coded into assembly + void *stackPtr; //save the core's stack ptr when suspend + void *framePtr; //save core's frame ptr when suspend + void *resumeInstrPtr; //save core's program-counter when suspend void *coreCtlrFramePtr; //restore before jmp back to core controller void *coreCtlrStackPtr; //restore before jmp back to core controller + + //============ below this, no fields are used in asm ============= + int slaveID; //each slave given a globally unique ID + int coreAnimatedBy; + void *startOfStack; //used to free, and to point slave to Fn + + //for comm -- between master and coreCtlr & btwn wrapper lib and plugin + SchedSlot *schedSlotAssignedTo; + VMSReqst *requests; //wrapper lib puts in requests, plugin takes out + void *dataRetFromReq;//Return vals from plugin to Wrapper Lib - SchedSlot *schedSlot; - VMSReqst *requests; - - void *semanticData; //this is live for the life of Slv - void *dataRetFromReq;//Used to return vals from plugin to Wrapper Lib + //Slave used as carrier for data + void *semanticData; //Lang saves lang-specific things in slave here //=========== MEASUREMENT STUFF ========== MEAS__Insert_Meas_Fields_into_Slave; @@ -142,14 +137,15 @@ }; //SlaveVP -/*The one and only global variable, holds many odds and ends + +/* The one and only global variable, holds many odds and ends */ typedef struct { //The offsets of these fields are hard-coded into assembly void *coreCtlrReturnPt; //offset of field used in asm int32 masterLock __align_to_cacheline__; //used in asm - //============ below this, no asm uses the field offsets ============= + //============ below this, no fields are used in asm ============= //Basic VMS infrastructure SlaveVP **masterVPs; @@ -214,6 +210,7 @@ volatile MasterEnv *_VMSMasterEnv __align_to_cacheline__; + //these are global, but only used for startup and shutdown pthread_t coreCtlrThdHandles[ NUM_CORES ]; //pthread's virt-procr state ThdParams *coreCtlrThdParams [ NUM_CORES ]; @@ -221,16 +218,28 @@ pthread_cond_t suspendCond; //========================= Function Prototypes =========================== - -/* MEANING OF WL PI SS int +/* MEANING OF WL PI SS int VMSOS * These indicate which places the function is safe to use. They stand for: - * WL: Wrapper Library - * PI: Plugin - * SS: Startup and Shutdown - * int: internal to the VMS implementation + * + * WL Wrapper Library -- wrapper lib code should only use these + * PI Plugin -- plugin code should only use these + * SS Startup and Shutdown -- designates these relate to startup & shutdown + * int internal to VMS -- should not be used in wrapper lib or plugin + * VMSOS means "OS functions for applications to use" + * + * VMS_int__ functions touch internal VMS data structs and are only safe + * to be used inside the master lock. However, occasionally, they appear + * in wrapper-lib or plugin code. In those cases, very careful analysis + * has been done to be sure no concurrency issues could arise. + * + * VMS_WL__ functions are all safe for use outside the master lock. + * + * VMSOS are only safe for applications to use -- they're like a second + * language mixed in -- but they can't be used inside plugin code, and + * aren't meant for use in wrapper libraries, because they are themselves + * wrapper-library calls! */ - -//========== Setup and shutdown ========== +//========== Startup and shutdown ========== void VMS_SS__init(); diff -r 421bde2a07d7 -r a0ac58d8201c VMS__PI.c --- a/VMS__PI.c Thu Mar 15 20:47:54 2012 -0700 +++ b/VMS__PI.c Fri Mar 16 09:39:53 2012 -0700 @@ -14,6 +14,15 @@ #include "VMS.h" +/* MEANING OF WL PI SS int + * These indicate which places the function is safe to use. They stand for: + * WL: Wrapper Library + * PI: Plugin + * SS: Startup and Shutdown + * int: internal to the VMS implementation + */ + + /* */ VMSReqst * diff -r 421bde2a07d7 -r a0ac58d8201c VMS__WL.c --- a/VMS__WL.c Thu Mar 15 20:47:54 2012 -0700 +++ b/VMS__WL.c Fri Mar 16 09:39:53 2012 -0700 @@ -14,6 +14,15 @@ #include "VMS.h" +/* MEANING OF WL PI SS int + * These indicate which places the function is safe to use. They stand for: + * WL: Wrapper Library + * PI: Plugin + * SS: Startup and Shutdown + * int: internal to the VMS implementation + */ + + /*For this implementation of VMS, it may not make much sense to have the * system of requests for creating a new processor done this way.. but over diff -r 421bde2a07d7 -r a0ac58d8201c VMS__int.c --- a/VMS__int.c Thu Mar 15 20:47:54 2012 -0700 +++ b/VMS__int.c Fri Mar 16 09:39:53 2012 -0700 @@ -14,6 +14,15 @@ #include "VMS.h" +/* MEANING OF WL PI SS int + * These indicate which places the function is safe to use. They stand for: + * WL: Wrapper Library + * PI: Plugin + * SS: Startup and Shutdown + * int: internal to the VMS implementation + */ + + inline SlaveVP * VMS_int__create_slaveVP( TopLevelFnPtr fnPtr, void *dataParam ) { SlaveVP *newSlv; @@ -70,7 +79,7 @@ //animatingSlv->resumeInstrPtr = &&ResumePt; //return ownership of the Slv and sched slot to Master virt pr - animatingSlv->schedSlot->workIsDone = TRUE; + animatingSlv->schedSlotAssignedTo->workIsDone = TRUE; MEAS__Capture_Pre_Susp_Point; switchToCoreCtlr(animatingSlv); @@ -165,7 +174,7 @@ newSlv->startOfStack = stackLocs; newSlv->slaveID = _VMSMasterEnv->numSlavesCreated++; newSlv->requests = NULL; - newSlv->schedSlot = NULL; + newSlv->schedSlotAssignedTo = NULL; VMS_int__point_slaveVP_to_Fn( newSlv, fnPtr, dataParam ); diff -r 421bde2a07d7 -r a0ac58d8201c VMS__startup_and_shutdown.c --- a/VMS__startup_and_shutdown.c Thu Mar 15 20:47:54 2012 -0700 +++ b/VMS__startup_and_shutdown.c Fri Mar 16 09:39:53 2012 -0700 @@ -17,6 +17,16 @@ #define thdAttrs NULL + +/* MEANING OF WL PI SS int + * These indicate which places the function is safe to use. They stand for: + * WL: Wrapper Library + * PI: Plugin + * SS: Startup and Shutdown + * int: internal to the VMS implementation + */ + + //=========================================================================== SchedSlot ** create_sched_slots(); @@ -486,7 +496,7 @@ schedSlots[0]->slaveAssignedToSlot = shutDownSlv; schedSlots[0]->needsSlaveAssigned = FALSE; shutDownSlv->coreAnimatedBy = coreIdx; - shutDownSlv->schedSlot = schedSlots[ 0 ]; + shutDownSlv->schedSlotAssignedTo = schedSlots[ 0 ]; } } diff -r 421bde2a07d7 -r a0ac58d8201c VMS_primitive_data_types.h --- a/VMS_primitive_data_types.h Thu Mar 15 20:47:54 2012 -0700 +++ b/VMS_primitive_data_types.h Fri Mar 16 09:39:53 2012 -0700 @@ -13,25 +13,13 @@ /*For portability, need primitive data types that have a well defined * size, and well-defined layout into bytes - *To do this, provide BLIS standard aliases for all primitive data types - *These aliases must be used in all BLIS functions instead of the ANSI types + *To do this, provide standard aliases for all primitive data types + *These aliases must be used in all functions instead of the ANSI types * - *These definitions will be replaced inside each specialization module - * according to the compiler used in that module and the hardware being - * specialized to. + *When VMS is used together with BLIS, these definitions will be replaced + * inside each specialization module according to the compiler used in + * that module and the hardware being specialized to. */ -/* -#define int8 char -#define uint8 char -#define int16 short -#define uint16 unsigned short -#define int32 int -#define uint32 unsigned int -#define int64 long long -#define uint64 unsigned long long -#define float32 float -#define float64 double -*/ typedef char bool8; typedef char int8; typedef char uint8; @@ -44,7 +32,7 @@ typedef unsigned long long uint64; typedef float float32; typedef double float64; -//typedef double double float128; +//typedef double double float128; //GCC doesn't like this #define float128 double double #define TRUE 1