# HG changeset patch # User Some Random Person # Date 1331919795 25200 # Node ID 0ee1a3c8972db6178edab0df366dcbeae843093f # Parent a0ac58d8201c02d25c21cc7390c7277ddf8da614# Parent 5bb234f93cf6b77b1d33e0f186a95e3928ee14db Merged Nina's fix of assembly with Sean's comments and cleanup diff -r a0ac58d8201c -r 0ee1a3c8972d Defines/VMS_defs__HW_constants.h --- a/Defines/VMS_defs__HW_constants.h Fri Mar 16 09:39:53 2012 -0700 +++ b/Defines/VMS_defs__HW_constants.h Fri Mar 16 10:43:15 2012 -0700 @@ -18,7 +18,7 @@ // tradeoff amortizing master fixed overhead vs imbalance potential // when work-stealing, can make bigger, at risk of losing cache affinity -#define NUM_SCHED_SLOTS 3 +#define NUM_SCHED_SLOTS 1 //These are for backoff inside core-loop, which reduces lock contention #define NUM_REPS_W_NO_WORK_BEFORE_YIELD 10 diff -r a0ac58d8201c -r 0ee1a3c8972d Defines/VMS_defs__turn_on_and_off.h --- a/Defines/VMS_defs__turn_on_and_off.h Fri Mar 16 09:39:53 2012 -0700 +++ b/Defines/VMS_defs__turn_on_and_off.h Fri Mar 16 10:43:15 2012 -0700 @@ -21,7 +21,7 @@ /*turns on the probe-instrumentation in the application -- when not * defined, the calls to the probe functions turn into comments */ -#define DEBUG__TURN_ON_DEBUG_PRINT +//#define DEBUG__TURN_ON_DEBUG_PRINT /*These defines turn types of bug messages on and off */ @@ -60,6 +60,9 @@ /*turn on/off subtraction of create measurements from plugin meas*/ //#define MEAS__TURN_ON_EXCLUDE_CREATION_TIME +#define HOLISTIC__TURN_ON_PERF_COUNTERS +#define HOLISTIC__TURN_ON_OBSERVE_UCC +#define DETECT_LOOP_GRAPH //=================== Turn on or off system options ======================= // diff -r a0ac58d8201c -r 0ee1a3c8972d Hardware_Dependent/VMS__HW_measurement.h --- a/Hardware_Dependent/VMS__HW_measurement.h Fri Mar 16 09:39:53 2012 -0700 +++ b/Hardware_Dependent/VMS__HW_measurement.h Fri Mar 16 10:43:15 2012 -0700 @@ -57,6 +57,6 @@ // different cores. //#define NUM_TSC_ROUND_TRIPS 10 - +void setup_perf_counters(); #endif /* */ diff -r a0ac58d8201c -r 0ee1a3c8972d Hardware_Dependent/VMS__primitives_asm.s --- a/Hardware_Dependent/VMS__primitives_asm.s Fri Mar 16 09:39:53 2012 -0700 +++ b/Hardware_Dependent/VMS__primitives_asm.s Fri Mar 16 10:43:15 2012 -0700 @@ -100,7 +100,7 @@ movq $_VMSMasterEnv, %rcx movq (%rcx), %rcx #_VMSMasterEnv is pointer to struct movq 0x00(%rcx), %rax #get CoreCtlr return pt - movl $0x0 , 0x08(%rcx) #release lock + movl $0x0 , 0x100(%rcx) #release lock jmp *%rax #jmp to CoreCtlr MasterReturn: ret diff -r a0ac58d8201c -r 0ee1a3c8972d Services_Offered_by_VMS/Measurement_and_Stats/MEAS__macros.h --- a/Services_Offered_by_VMS/Measurement_and_Stats/MEAS__macros.h Fri Mar 16 09:39:53 2012 -0700 +++ b/Services_Offered_by_VMS/Measurement_and_Stats/MEAS__macros.h Fri Mar 16 10:43:15 2012 -0700 @@ -292,12 +292,57 @@ #define MEAS__Print_Hists_for_System_Meas #endif + #ifdef HOLISTIC__TURN_ON_PERF_COUNTERS + +#define MEAS__Insert_Counter_Handler \ + typedef void (*CounterHandler) (int,int,int,SlaveVP*,uint64,uint64); + + enum eventType { + DebugEvt = 0, + AppResponderInvocation_start, + AppResponder_start, + AppResponder_end, + AssignerInvocation_start, + NextAssigner_start, + Assigner_start, + Assigner_end, + Work_start, + Work_end, + HwResponderInvocation_start, + Timestamp_start, + Timestamp_end + }; + + + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv \ + int cycles_counter_fd[NUM_CORES]; \ + int instrs_counter_fd[NUM_CORES]; \ + uint64 start_master_lock[NUM_CORES][2]; \ + CounterHandler counterHandler; + + #define HOLISTIC__Setup_Perf_Counters void setup_perf_counters(); + + #define HOLISTIC__Start_Perf_Counters prctl(PR_TASK_PERF_EVENTS_ENABLE); + + #define HOLISTIC__Record_HwResponderInvocation_start \ + uint64 cycles,instrs; \ + saveCyclesAndInstrs(animatingPr->coreAnimatedBy,cycles, instrs); \ + (*(_VMSMasterEnv->counterHandler))(HwResponderInvocation_start,animatingPr->procrID,animatingPr->numTimesScheduled,animatingPr,cycles,instrs); + + + +#else + #define MEAS__Insert_Counter_Handler + #define MEAS__Insert_Counter_Meas_Fields_into_MasterEnv + #define HOLISTIC__Setup_Perf_Counters + #define HOLISTIC__Start_Perf_Counters +#endif //Experiment in two-step macros -- if doesn't work, insert each separately #define MEAS__Insert_Meas_Fields_into_Slave \ MEAS__Insert_Susp_Meas_Fields_into_Slave \ MEAS__Insert_Master_Meas_Fields_into_Slave \ - MEAS__Insert_System_Meas_Fields_into_Slave + MEAS__Insert_System_Meas_Fields_into_Slave //====================== Histogram Macros -- Create ======================== diff -r a0ac58d8201c -r 0ee1a3c8972d VMS.h --- a/VMS.h Fri Mar 16 09:39:53 2012 -0700 +++ b/VMS.h Fri Mar 16 10:43:15 2012 -0700 @@ -43,6 +43,9 @@ typedef void (*TopLevelFnPtr) ( void *, SlaveVP * ); //initData, animSlv typedef void TopLevelFn ( void *, SlaveVP * ); //initData, animSlv typedef void (*ResumeSlvFnPtr) ( SlaveVP *, void * ); + //=========== MEASUREMENT STUFF ========== + MEAS__Insert_Counter_Handler + //======================================== //============================ HW Dependent Fns ================================ @@ -105,6 +108,12 @@ }; //SchedSlot + enum VPtype { + Slave = 1, //default + Master, + Shutdown + }; + /*This structure embodies the state of a slaveVP. It is reused for masterVP * and shutdownVPs. */ @@ -133,7 +142,10 @@ MEAS__Insert_Meas_Fields_into_Slave; //======================================== - float64 createPtInSecs; //have space but don't use on some configs + enum VPtype type; + int numTimesAssigned; + + float64 createPtInSecs; //have space but don't use on some configs }; //SlaveVP @@ -181,6 +193,7 @@ MEAS__Insert_Malloc_Meas_Fields_into_MasterEnv; MEAS__Insert_Plugin_Meas_Fields_into_MasterEnv; MEAS__Insert_System_Meas_Fields_into_MasterEnv; + MEAS__Insert_Counter_Meas_Fields_into_MasterEnv; //========================================== } MasterEnv; @@ -246,6 +259,9 @@ void VMS_SS__start_the_work_then_wait_until_done(); +SlaveVP* +VMS_SS__create_shutdown_slave(); + void VMS_SS__shutdown(); diff -r a0ac58d8201c -r 0ee1a3c8972d VMS__int.c --- a/VMS__int.c Fri Mar 16 09:39:53 2012 -0700 +++ b/VMS__int.c Fri Mar 16 10:43:15 2012 -0700 @@ -175,6 +175,8 @@ newSlv->slaveID = _VMSMasterEnv->numSlavesCreated++; newSlv->requests = NULL; newSlv->schedSlotAssignedTo = NULL; + newSlv->type = Slave; + newSlv->numTimesAssigned = 0; VMS_int__point_slaveVP_to_Fn( newSlv, fnPtr, dataParam ); diff -r a0ac58d8201c -r 0ee1a3c8972d VMS__startup_and_shutdown.c --- a/VMS__startup_and_shutdown.c Fri Mar 16 09:39:53 2012 -0700 +++ b/VMS__startup_and_shutdown.c Fri Mar 16 10:43:15 2012 -0700 @@ -82,6 +82,7 @@ printf( "\n\n Running in SEQUENTIAL mode \n\n" ); #else create_masterEnv(); + printf("Offset of lock in masterEnv:%d\n",offsetof(MasterEnv,masterLock)); create_the_coreCtlr_OS_threads(); #endif } @@ -305,6 +306,7 @@ //Q: should give masterVP core-specific info as its init data? masterVPs[ coreIdx ] = VMS_int__create_slaveVP( (TopLevelFnPtr)&animationMaster, (void*)masterEnv ); masterVPs[ coreIdx ]->coreAnimatedBy = coreIdx; + masterVPs[ coreIdx ]->type = Master; allSchedSlots[ coreIdx ] = create_sched_slots(); //makes for one core } _VMSMasterEnv->masterVPs = masterVPs; @@ -323,6 +325,8 @@ PROBES__Create_Probe_Bookkeeping_Vars; + HOLISTIC__Setup_Perf_Counters; + //======================================================================== } @@ -448,6 +452,15 @@ } +SlaveVP* VMS_SS__create_shutdown_slave(){ + SlaveVP* shutdownVP; + + shutdownVP = VMS_int__create_slaveVP( &endOSThreadFn, NULL ); + shutdownVP->type = Shutdown; + + return shutdownVP; +} + //TODO: look at architecting cleanest separation between request handler // and animation master, for dissipate, create, shutdown, and other non-semantic // requests. Issue is chain: one removes requests from AppSlv, one dispatches @@ -489,7 +502,7 @@ // directly into the Q -- each core will die when gets one for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) { //Note, this is running in the master - shutDownSlv = VMS_int__create_slaveVP( &endOSThreadFn, NULL ); + shutDownSlv = VMS_SS__create_shutdown_slave(); //last slave has dissipated, so no more in slots, so write // shut down slave into first schedulng slot. schedSlots = _VMSMasterEnv->allSchedSlots[ coreIdx ];