# HG changeset patch # User Nina Engelhardt # Date 1326476071 -3600 # Node ID 28cc465f7eb7e25df7229fb236ab9177a34197df # Parent 50b29548d4f0627361ad3522cc717d5935bc83da new counter interface works now diff -r 50b29548d4f0 -r 28cc465f7eb7 CoreLoop.c --- a/CoreLoop.c Fri Jan 13 15:03:32 2012 +0100 +++ b/CoreLoop.c Fri Jan 13 18:34:31 2012 +0100 @@ -77,7 +77,9 @@ pthread_setaffinity_np( selfThd, sizeof(coreMask), &coreMask); if(errorCode){ printf("\nset affinity failure\n"); exit(0); } - +#ifdef MEAS__PERF_COUNTERS + CounterHandler counterHandler = _VMSMasterEnv->counterHandler; +#endif //Save the return address in the SwitchVP function saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); @@ -85,15 +87,12 @@ while(1){ #ifdef MEAS__PERF_COUNTERS - //end work - /* - if(currPr!=NULL){ - int lastRecordIdx = currPr->counter_history_array_info->numInArray -1; - CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx]; - //lastRecord->work_core = thisCoresIdx; - saveCyclesAndInstrs(thisCoresIdx,lastRecord->suspend_cycles,lastRecord->suspend_instrs); + //end work + if(currPr){ + uint64 cycles,instrs; + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); + (*counterHandler)(CoreLoop_afterWork,currPr,cycles,instrs); } - */ #endif //Get virtual processor from queue //The Q must be a global, static volatile var, so not kept in reg, @@ -163,12 +162,11 @@ #ifdef MEAS__PERF_COUNTERS //start work -/* - int lastRecordIdx = currPr->counter_history_array_info->numInArray -1; - CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx]; - lastRecord->work_core = thisCoresIdx; - saveCyclesAndInstrs(thisCoresIdx,lastRecord->start_work_cycles,lastRecord->start_work_instrs); -*/ + if(currPr){ + uint64 cycles,instrs; + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); + (*counterHandler)(CoreLoop_beforeWork,currPr,cycles,instrs); + } #endif switchToVP(currPr); //The VPs return in here diff -r 50b29548d4f0 -r 28cc465f7eb7 MasterLoop.c --- a/MasterLoop.c Fri Jan 13 15:03:32 2012 +0100 +++ b/MasterLoop.c Fri Jan 13 18:34:31 2012 +0100 @@ -130,7 +130,7 @@ semanticEnv = masterEnv->semanticEnv; #ifdef MEAS__PERF_COUNTERS - //CounterHandler counterHandler = masterEnv->counterHandler; + CounterHandler counterHandler = masterEnv->counterHandler; #endif //Poll each slot's Done flag @@ -151,32 +151,9 @@ saveLowTimeStampCountInto( startStamp1 ); #endif #ifdef MEAS__PERF_COUNTERS - int cycles, instrs; + uint64 cycles, instrs; saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); - //(*counterHandler)(MasterLoop_beforeReqHdlr,thisCoresIdx,slotIdx,currSlot->procrAssignedToSlot,cycles,instrs); - - /* - int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1; - CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx]; - lastRecord->req_core = thisCoresIdx; - saveCyclesAndInstrs(thisCoresIdx,lastRecord->next_task_req_cycles,lastRecord->next_task_req_instrs); - //End of task, start of next task - //print counters from last run - addToDynArray((void*)lastRecord,masterEnv->counter_history_array_info); - print_record_csv_to_file(lastRecord,_VMSMasterEnv->counteroutput); - - //print_record_human_readable(lastRecord); - //create new entry in record array - CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord)); - newRecord->req_core = thisCoresIdx; - newRecord->vp_id = currSlot->procrAssignedToSlot->procrID; - newRecord->task_position = lastRecord->task_position + 1; - newRecord->req_cycles = lastRecord->next_task_req_cycles; - newRecord->req_instrs = lastRecord->next_task_req_instrs; - getReturnAddressBeforeLibraryCall(currSlot->procrAssignedToSlot, &(newRecord->addr_of_libcall_for_req)); - addToDynArray( (void*) newRecord, currSlot->procrAssignedToSlot->counter_history_array_info); - lastRecord = newRecord; - */ + (*counterHandler)(MasterLoop_beforeReqHdlr,currSlot->procrAssignedToSlot,cycles,instrs); #endif //============================================================ (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv ); @@ -190,12 +167,9 @@ #endif #ifdef MEAS__PERF_COUNTERS //done with constraints check - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); - //(*counterHandler)(MasterLoop_afterReqHdlr,thisCoresIdx,slotIdx,currSlot->procrAssignedToSlot,cycles,instrs); - /* - saveCyclesAndInstrs(thisCoresIdx,lastRecord->sc_done_cycles,lastRecord->sc_done_instrs); - saveLowTimeStampCountInto(lastRecord->blocked_timestamp); - */ + uint64 cycles2,instrs2; + saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2); + (*counterHandler)(MasterLoop_afterReqHdlr,currSlot->procrAssignedToSlot,cycles2,instrs2); #endif //============================================================ } @@ -216,22 +190,15 @@ currSlot->needsProcrAssigned = FALSE; numSlotsFilled += 1; + writeVMSQ( schedVirtPr, readyToAnimateQ ); + #ifdef MEAS__PERF_COUNTERS uint64 cycles; uint64 instrs; saveCyclesAndInstrs(thisCoresIdx,cycles,instrs); - //(*counterHandler)(MasterLoop_beforeAssign,thisCoresIdx,slotIdx,schedVirtPr,tmp_cycles,tmp_instrs); - //(*counterHandler)(MasterLoop_afterAssign,thisCoresIdx,slotIdx,schedVirtPr,cycles,instrs); - //end assigner - //int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1; - //CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx]; - //lastRecord->assigning_core = thisCoresIdx; - //lastRecord->start_assign_cycles = tmp_cycles; - //lastRecord->start_assign_instrs = tmp_instrs; - //saveCyclesAndInstrs(thisCoresIdx,lastRecord->end_assign_cycles,lastRecord->end_assign_instrs); + (*counterHandler)(MasterLoop_beforeAssign,schedVirtPr,tmp_cycles,tmp_instrs); + (*counterHandler)(MasterLoop_afterAssign,schedVirtPr,cycles,instrs); #endif - - writeVMSQ( schedVirtPr, readyToAnimateQ ); } } diff -r 50b29548d4f0 -r 28cc465f7eb7 VMS.h --- a/VMS.h Fri Jan 13 15:03:32 2012 +0100 +++ b/VMS.h Fri Jan 13 18:34:31 2012 +0100 @@ -16,7 +16,6 @@ #include "DynArray/DynArray.h" #include "Hash_impl/PrivateHash.h" #include "vmalloc.h" -#include "Counters/Counters.h" #include "loop.h" #include "ListOfArrays/ListOfArrays.h" @@ -130,7 +129,7 @@ typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); -typedef void (*CounterHandler) (int,int,int,VirtProcr*,uint64,uint64); +typedef void (*CounterHandler) (int,VirtProcr*,uint64,uint64); //============= Requests =========== // @@ -273,9 +272,7 @@ #ifdef MEAS__PERF_COUNTERS int cycles_counter_fd[NUM_CORES]; int instrs_counter_fd[NUM_CORES]; - FILE* counteroutput; - #endif - #ifdef MEAS__PERF_COUNTERS // + //FILE* counteroutput; //CounterRecord** counter_history; //PrivDynArrayInfo* counter_history_array_info; CounterHandler counterHandler; @@ -449,7 +446,9 @@ MasterLoop_beforeReqHdlr = 1, MasterLoop_afterReqHdlr, MasterLoop_beforeAssign, - MasterLoop_afterAssign + MasterLoop_afterAssign, + CoreLoop_afterWork, + CoreLoop_beforeWork }; #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \