changeset 184:50b29548d4f0 perf_counters

handler interface for counters... not working
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Fri, 13 Jan 2012 15:03:32 +0100
parents 7523ee70d66c
children 28cc465f7eb7
files CoreLoop.c MasterLoop.c ProcrContext.c VMS.c VMS.h
diffstat 5 files changed, 53 insertions(+), 23 deletions(-) [+]
line diff
     1.1 --- a/CoreLoop.c	Fri Jan 06 18:55:05 2012 +0100
     1.2 +++ b/CoreLoop.c	Fri Jan 13 15:03:32 2012 +0100
     1.3 @@ -86,14 +86,14 @@
     1.4     while(1){
     1.5     #ifdef MEAS__PERF_COUNTERS
     1.6          //end work
     1.7 -
     1.8 +       /*
     1.9         if(currPr!=NULL){
    1.10 -   int lastRecordIdx = currPr->counter_history_array_info->numInArray -1;
    1.11 -   CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx];
    1.12 -   //lastRecord->work_core = thisCoresIdx;
    1.13 -   saveCyclesAndInstrs(thisCoresIdx,lastRecord->suspend_cycles,lastRecord->suspend_instrs);
    1.14 +        int lastRecordIdx = currPr->counter_history_array_info->numInArray -1;
    1.15 +        CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx];
    1.16 +        //lastRecord->work_core = thisCoresIdx;
    1.17 +        saveCyclesAndInstrs(thisCoresIdx,lastRecord->suspend_cycles,lastRecord->suspend_instrs);
    1.18         }
    1.19 -
    1.20 +        */
    1.21     #endif
    1.22        //Get virtual processor from queue
    1.23        //The Q must be a global, static volatile var, so not kept in reg,
    1.24 @@ -163,10 +163,12 @@
    1.25  
    1.26     #ifdef MEAS__PERF_COUNTERS
    1.27          //start work
    1.28 +/*
    1.29     int lastRecordIdx = currPr->counter_history_array_info->numInArray -1;
    1.30     CounterRecord* lastRecord = currPr->counter_history[lastRecordIdx];
    1.31     lastRecord->work_core = thisCoresIdx;   
    1.32     saveCyclesAndInstrs(thisCoresIdx,lastRecord->start_work_cycles,lastRecord->start_work_instrs);
    1.33 +*/
    1.34     #endif
    1.35     switchToVP(currPr); //The VPs return in here
    1.36  
     2.1 --- a/MasterLoop.c	Fri Jan 06 18:55:05 2012 +0100
     2.2 +++ b/MasterLoop.c	Fri Jan 13 15:03:32 2012 +0100
     2.3 @@ -128,7 +128,10 @@
     2.4     requestHandler   = masterEnv->requestHandler;
     2.5     slaveScheduler   = masterEnv->slaveScheduler;
     2.6     semanticEnv      = masterEnv->semanticEnv;
     2.7 -
     2.8 +   
     2.9 +#ifdef MEAS__PERF_COUNTERS
    2.10 +   //CounterHandler counterHandler = masterEnv->counterHandler;
    2.11 +#endif
    2.12  
    2.13        //Poll each slot's Done flag
    2.14     numSlotsFilled = 0;
    2.15 @@ -148,6 +151,11 @@
    2.16                 saveLowTimeStampCountInto( startStamp1 );
    2.17                 #endif
    2.18                 #ifdef MEAS__PERF_COUNTERS
    2.19 +               int cycles, instrs;
    2.20 +               saveCyclesAndInstrs(thisCoresIdx,cycles, instrs);
    2.21 +               //(*counterHandler)(MasterLoop_beforeReqHdlr,thisCoresIdx,slotIdx,currSlot->procrAssignedToSlot,cycles,instrs);
    2.22 +               
    2.23 +               /*
    2.24                 int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
    2.25                 CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx];
    2.26                 lastRecord->req_core = thisCoresIdx;
    2.27 @@ -156,11 +164,7 @@
    2.28                 //print counters from last run
    2.29                 addToDynArray((void*)lastRecord,masterEnv->counter_history_array_info);
    2.30                 print_record_csv_to_file(lastRecord,_VMSMasterEnv->counteroutput);
    2.31 -               
    2.32 -  
    2.33                
    2.34 -
    2.35 -               
    2.36                 //print_record_human_readable(lastRecord);
    2.37                 //create new entry in record array
    2.38                 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
    2.39 @@ -171,7 +175,8 @@
    2.40                 newRecord->req_instrs = lastRecord->next_task_req_instrs;
    2.41                 getReturnAddressBeforeLibraryCall(currSlot->procrAssignedToSlot, &(newRecord->addr_of_libcall_for_req));
    2.42                 addToDynArray( (void*) newRecord, currSlot->procrAssignedToSlot->counter_history_array_info);
    2.43 -               lastRecord = newRecord;
    2.44 +               lastRecord = newRecord; 
    2.45 +                */
    2.46                 #endif
    2.47                 //============================================================
    2.48           (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv );
    2.49 @@ -185,8 +190,12 @@
    2.50                 #endif
    2.51                 #ifdef MEAS__PERF_COUNTERS
    2.52                 //done with constraints check
    2.53 +               saveCyclesAndInstrs(thisCoresIdx,cycles, instrs);
    2.54 +               //(*counterHandler)(MasterLoop_afterReqHdlr,thisCoresIdx,slotIdx,currSlot->procrAssignedToSlot,cycles,instrs);
    2.55 +               /*
    2.56                 saveCyclesAndInstrs(thisCoresIdx,lastRecord->sc_done_cycles,lastRecord->sc_done_instrs);
    2.57                 saveLowTimeStampCountInto(lastRecord->blocked_timestamp);
    2.58 +                */
    2.59                 #endif
    2.60                 //============================================================
    2.61         }
    2.62 @@ -208,13 +217,18 @@
    2.63              numSlotsFilled               += 1;
    2.64  
    2.65                 #ifdef MEAS__PERF_COUNTERS
    2.66 +               uint64 cycles;
    2.67 +               uint64 instrs;
    2.68 +               saveCyclesAndInstrs(thisCoresIdx,cycles,instrs);
    2.69 +               //(*counterHandler)(MasterLoop_beforeAssign,thisCoresIdx,slotIdx,schedVirtPr,tmp_cycles,tmp_instrs);
    2.70 +               //(*counterHandler)(MasterLoop_afterAssign,thisCoresIdx,slotIdx,schedVirtPr,cycles,instrs);
    2.71                 //end assigner
    2.72 -               int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
    2.73 -               CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx];
    2.74 -               lastRecord->assigning_core = thisCoresIdx;
    2.75 -               lastRecord->start_assign_cycles = tmp_cycles;
    2.76 -               lastRecord->start_assign_instrs = tmp_instrs;
    2.77 -               saveCyclesAndInstrs(thisCoresIdx,lastRecord->end_assign_cycles,lastRecord->end_assign_instrs);
    2.78 +               //int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
    2.79 +               //CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx];
    2.80 +               //lastRecord->assigning_core = thisCoresIdx;
    2.81 +               //lastRecord->start_assign_cycles = tmp_cycles;
    2.82 +               //lastRecord->start_assign_instrs = tmp_instrs;
    2.83 +               //saveCyclesAndInstrs(thisCoresIdx,lastRecord->end_assign_cycles,lastRecord->end_assign_instrs);
    2.84                 #endif
    2.85  
    2.86              writeVMSQ( schedVirtPr, readyToAnimateQ );
     3.1 --- a/ProcrContext.c	Fri Jan 06 18:55:05 2012 +0100
     3.2 +++ b/ProcrContext.c	Fri Jan 13 15:03:32 2012 +0100
     3.3 @@ -61,6 +61,7 @@
     3.4     //                                            _VMSMasterEnv->createPtInSecs;
     3.5     #endif
     3.6     #ifdef MEAS__PERF_COUNTERS
     3.7 +/*
     3.8     newPr->counter_history = VMS__malloc(10*sizeof(void*));
     3.9     newPr->counter_history_array_info = makePrivDynArrayInfoFrom((void*)&(newPr->counter_history),10);
    3.10     CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
    3.11 @@ -72,6 +73,7 @@
    3.12     newRecord->req_cycles = 0;
    3.13     newRecord->req_instrs = 0;
    3.14     addToDynArray( (void*) newRecord, newPr->counter_history_array_info);
    3.15 +*/
    3.16     #endif
    3.17     //========================================================================
    3.18  
     4.1 --- a/VMS.c	Fri Jan 06 18:55:05 2012 +0100
     4.2 +++ b/VMS.c	Fri Jan 13 15:03:32 2012 +0100
     4.3 @@ -192,9 +192,12 @@
     4.4     #endif
     4.5  
     4.6     #ifdef MEAS__PERF_COUNTERS
     4.7 +/*
     4.8     _VMSMasterEnv->counter_history = VMS__malloc(10*sizeof(void*));
     4.9     _VMSMasterEnv->counter_history_array_info = makePrivDynArrayInfoFrom((void***)&(_VMSMasterEnv->counter_history),10);
    4.10 +*/
    4.11     //printf("Creating HW counters...");
    4.12 +/*
    4.13     FILE* output;
    4.14     int n;
    4.15     char filename[255];    
    4.16 @@ -212,6 +215,7 @@
    4.17      printf("Saving Counter measurements to File: %s ...\n", filename);
    4.18      output = fopen(filename,"w+");
    4.19     _VMSMasterEnv->counteroutput = output;
    4.20 +*/
    4.21      
    4.22     struct perf_event_attr hw_event;
    4.23     memset(&hw_event,0,sizeof(hw_event));
     5.1 --- a/VMS.h	Fri Jan 06 18:55:05 2012 +0100
     5.2 +++ b/VMS.h	Fri Jan 13 15:03:32 2012 +0100
     5.3 @@ -130,7 +130,7 @@
     5.4  typedef void  (*VirtProcrFnPtr)  ( void *, VirtProcr * ); //initData, animPr
     5.5  typedef void    VirtProcrFn      ( void *, VirtProcr * ); //initData, animPr
     5.6  typedef void  (*ResumePrFnPtr)   ( VirtProcr *, void * );
     5.7 -
     5.8 +typedef void (*CounterHandler) (int,int,int,VirtProcr*,uint64,uint64);
     5.9  
    5.10  //============= Requests ===========
    5.11  //
    5.12 @@ -210,8 +210,8 @@
    5.13     unsigned int endMasterTSCLow;
    5.14     #endif
    5.15     #ifdef MEAS__PERF_COUNTERS //
    5.16 -   CounterRecord** counter_history;
    5.17 -   PrivDynArrayInfo* counter_history_array_info;
    5.18 +   //CounterRecord** counter_history;
    5.19 +   //PrivDynArrayInfo* counter_history_array_info;
    5.20     #endif
    5.21        //========================================
    5.22     
    5.23 @@ -276,8 +276,9 @@
    5.24     FILE* counteroutput;
    5.25     #endif
    5.26     #ifdef MEAS__PERF_COUNTERS //
    5.27 -   CounterRecord** counter_history;
    5.28 -   PrivDynArrayInfo* counter_history_array_info;
    5.29 +   //CounterRecord** counter_history;
    5.30 +   //PrivDynArrayInfo* counter_history_array_info;
    5.31 +   CounterHandler counterHandler;
    5.32     #endif
    5.33   }
    5.34  MasterEnv;
    5.35 @@ -444,6 +445,13 @@
    5.36     }                                                    \
    5.37  } while (0) 
    5.38  
    5.39 +enum eventType {
    5.40 +    MasterLoop_beforeReqHdlr = 1,
    5.41 +    MasterLoop_afterReqHdlr,
    5.42 +    MasterLoop_beforeAssign,
    5.43 +    MasterLoop_afterAssign
    5.44 +};
    5.45 +
    5.46  #define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{     \
    5.47  void* frame_ptr0 = vp_ptr->framePtr;                               \
    5.48  void* frame_ptr1 = *((void**)frame_ptr0);                          \