Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 185:28cc465f7eb7 perf_counters
new counter interface works now
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Fri, 13 Jan 2012 18:34:31 +0100 |
| parents | 50b29548d4f0 |
| children | 69eb54ce9c4b |
| files | CoreLoop.c MasterLoop.c VMS.h |
| diffstat | 3 files changed, 28 insertions(+), 64 deletions(-) [+] |
line diff
1.1 --- a/CoreLoop.c Fri Jan 13 15:03:32 2012 +0100 1.2 +++ b/CoreLoop.c Fri Jan 13 18:34:31 2012 +0100 1.3 @@ -77,7 +77,9 @@ 1.4 pthread_setaffinity_np( selfThd, sizeof(coreMask), &coreMask); 1.5 1.6 if(errorCode){ printf("\nset affinity failure\n"); exit(0); } 1.7 - 1.8 +#ifdef MEAS__PERF_COUNTERS 1.9 + CounterHandler counterHandler = _VMSMasterEnv->counterHandler; 1.10 +#endif 1.11 1.12 //Save the return address in the SwitchVP function 1.13 saveCoreLoopReturnAddr((void**)&(_VMSMasterEnv->coreLoopReturnPt)); 1.14 @@ -85,15 +87,12 @@ 1.15 1.16 while(1){ 1.17 #ifdef MEAS__PERF_COUNTERS 1.18 - //end work 1.19 - /* 1.20 - if(currPr!=NULL){ 1.21 - int lastRecordIdx = currPr->counter_history_array_info->numInArray -1; 1.22 - CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx]; 1.23 - //lastRecord->work_core = thisCoresIdx; 1.24 - saveCyclesAndInstrs(thisCoresIdx,lastRecord->suspend_cycles,lastRecord->suspend_instrs); 1.25 + //end work 1.26 + if(currPr){ 1.27 + uint64 cycles,instrs; 1.28 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); 1.29 + (*counterHandler)(CoreLoop_afterWork,currPr,cycles,instrs); 1.30 } 1.31 - */ 1.32 #endif 1.33 //Get virtual processor from queue 1.34 //The Q must be a global, static volatile var, so not kept in reg, 1.35 @@ -163,12 +162,11 @@ 1.36 1.37 #ifdef MEAS__PERF_COUNTERS 1.38 //start work 1.39 -/* 1.40 - int lastRecordIdx = currPr->counter_history_array_info->numInArray -1; 1.41 - CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx]; 1.42 - lastRecord->work_core = thisCoresIdx; 1.43 - saveCyclesAndInstrs(thisCoresIdx,lastRecord->start_work_cycles,lastRecord->start_work_instrs); 1.44 -*/ 1.45 + if(currPr){ 1.46 + uint64 cycles,instrs; 1.47 + saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); 1.48 + (*counterHandler)(CoreLoop_beforeWork,currPr,cycles,instrs); 1.49 + } 1.50 #endif 1.51 switchToVP(currPr); //The VPs return in here 1.52
2.1 --- a/MasterLoop.c Fri Jan 13 15:03:32 2012 +0100 2.2 +++ b/MasterLoop.c Fri Jan 13 18:34:31 2012 +0100 2.3 @@ -130,7 +130,7 @@ 2.4 semanticEnv = masterEnv->semanticEnv; 2.5 2.6 #ifdef MEAS__PERF_COUNTERS 2.7 - //CounterHandler counterHandler = masterEnv->counterHandler; 2.8 + CounterHandler counterHandler = masterEnv->counterHandler; 2.9 #endif 2.10 2.11 //Poll each slot's Done flag 2.12 @@ -151,32 +151,9 @@ 2.13 saveLowTimeStampCountInto( startStamp1 ); 2.14 #endif 2.15 #ifdef MEAS__PERF_COUNTERS 2.16 - int cycles, instrs; 2.17 + uint64 cycles, instrs; 2.18 saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); 2.19 - //(*counterHandler)(MasterLoop_beforeReqHdlr,thisCoresIdx,slotIdx,currSlot->procrAssignedToSlot,cycles,instrs); 2.20 - 2.21 - /* 2.22 - int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1; 2.23 - CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx]; 2.24 - lastRecord->req_core = thisCoresIdx; 2.25 - saveCyclesAndInstrs(thisCoresIdx,lastRecord->next_task_req_cycles,lastRecord->next_task_req_instrs); 2.26 - //End of task, start of next task 2.27 - //print counters from last run 2.28 - addToDynArray((void*)lastRecord,masterEnv->counter_history_array_info); 2.29 - print_record_csv_to_file(lastRecord,_VMSMasterEnv->counteroutput); 2.30 - 2.31 - //print_record_human_readable(lastRecord); 2.32 - //create new entry in record array 2.33 - CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord)); 2.34 - newRecord->req_core = thisCoresIdx; 2.35 - newRecord->vp_id = currSlot->procrAssignedToSlot->procrID; 2.36 - newRecord->task_position = lastRecord->task_position + 1; 2.37 - newRecord->req_cycles = lastRecord->next_task_req_cycles; 2.38 - newRecord->req_instrs = lastRecord->next_task_req_instrs; 2.39 - getReturnAddressBeforeLibraryCall(currSlot->procrAssignedToSlot, &(newRecord->addr_of_libcall_for_req)); 2.40 - addToDynArray( (void*) newRecord, currSlot->procrAssignedToSlot->counter_history_array_info); 2.41 - lastRecord = newRecord; 2.42 - */ 2.43 + (*counterHandler)(MasterLoop_beforeReqHdlr,currSlot->procrAssignedToSlot,cycles,instrs); 2.44 #endif 2.45 //============================================================ 2.46 (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv ); 2.47 @@ -190,12 +167,9 @@ 2.48 #endif 2.49 #ifdef MEAS__PERF_COUNTERS 2.50 //done with constraints check 2.51 - saveCyclesAndInstrs(thisCoresIdx,cycles, instrs); 2.52 - //(*counterHandler)(MasterLoop_afterReqHdlr,thisCoresIdx,slotIdx,currSlot->procrAssignedToSlot,cycles,instrs); 2.53 - /* 2.54 - saveCyclesAndInstrs(thisCoresIdx,lastRecord->sc_done_cycles,lastRecord->sc_done_instrs); 2.55 - saveLowTimeStampCountInto(lastRecord->blocked_timestamp); 2.56 - */ 2.57 + uint64 cycles2,instrs2; 2.58 + saveCyclesAndInstrs(thisCoresIdx,cycles2, instrs2); 2.59 + (*counterHandler)(MasterLoop_afterReqHdlr,currSlot->procrAssignedToSlot,cycles2,instrs2); 2.60 #endif 2.61 //============================================================ 2.62 } 2.63 @@ -216,22 +190,15 @@ 2.64 currSlot->needsProcrAssigned = FALSE; 2.65 numSlotsFilled += 1; 2.66 2.67 + writeVMSQ( schedVirtPr, readyToAnimateQ ); 2.68 + 2.69 #ifdef MEAS__PERF_COUNTERS 2.70 uint64 cycles; 2.71 uint64 instrs; 2.72 saveCyclesAndInstrs(thisCoresIdx,cycles,instrs); 2.73 - //(*counterHandler)(MasterLoop_beforeAssign,thisCoresIdx,slotIdx,schedVirtPr,tmp_cycles,tmp_instrs); 2.74 - //(*counterHandler)(MasterLoop_afterAssign,thisCoresIdx,slotIdx,schedVirtPr,cycles,instrs); 2.75 - //end assigner 2.76 - //int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1; 2.77 - //CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx]; 2.78 - //lastRecord->assigning_core = thisCoresIdx; 2.79 - //lastRecord->start_assign_cycles = tmp_cycles; 2.80 - //lastRecord->start_assign_instrs = tmp_instrs; 2.81 - //saveCyclesAndInstrs(thisCoresIdx,lastRecord->end_assign_cycles,lastRecord->end_assign_instrs); 2.82 + (*counterHandler)(MasterLoop_beforeAssign,schedVirtPr,tmp_cycles,tmp_instrs); 2.83 + (*counterHandler)(MasterLoop_afterAssign,schedVirtPr,cycles,instrs); 2.84 #endif 2.85 - 2.86 - writeVMSQ( schedVirtPr, readyToAnimateQ ); 2.87 } 2.88 } 2.89
3.1 --- a/VMS.h Fri Jan 13 15:03:32 2012 +0100 3.2 +++ b/VMS.h Fri Jan 13 18:34:31 2012 +0100 3.3 @@ -16,7 +16,6 @@ 3.4 #include "DynArray/DynArray.h" 3.5 #include "Hash_impl/PrivateHash.h" 3.6 #include "vmalloc.h" 3.7 -#include "Counters/Counters.h" 3.8 #include "loop.h" 3.9 #include "ListOfArrays/ListOfArrays.h" 3.10 3.11 @@ -130,7 +129,7 @@ 3.12 typedef void (*VirtProcrFnPtr) ( void *, VirtProcr * ); //initData, animPr 3.13 typedef void VirtProcrFn ( void *, VirtProcr * ); //initData, animPr 3.14 typedef void (*ResumePrFnPtr) ( VirtProcr *, void * ); 3.15 -typedef void (*CounterHandler) (int,int,int,VirtProcr*,uint64,uint64); 3.16 +typedef void (*CounterHandler) (int,VirtProcr*,uint64,uint64); 3.17 3.18 //============= Requests =========== 3.19 // 3.20 @@ -273,9 +272,7 @@ 3.21 #ifdef MEAS__PERF_COUNTERS 3.22 int cycles_counter_fd[NUM_CORES]; 3.23 int instrs_counter_fd[NUM_CORES]; 3.24 - FILE* counteroutput; 3.25 - #endif 3.26 - #ifdef MEAS__PERF_COUNTERS // 3.27 + //FILE* counteroutput; 3.28 //CounterRecord** counter_history; 3.29 //PrivDynArrayInfo* counter_history_array_info; 3.30 CounterHandler counterHandler; 3.31 @@ -449,7 +446,9 @@ 3.32 MasterLoop_beforeReqHdlr = 1, 3.33 MasterLoop_afterReqHdlr, 3.34 MasterLoop_beforeAssign, 3.35 - MasterLoop_afterAssign 3.36 + MasterLoop_afterAssign, 3.37 + CoreLoop_afterWork, 3.38 + CoreLoop_beforeWork 3.39 }; 3.40 3.41 #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \
