changeset 58:e11ba112a0c7 perf_counters

idle tasks
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Thu, 08 Mar 2012 19:04:08 +0100
parents 6b723b55b9a0
children 471c89d1d545
files SSR.h SSR_Counter_Recording.c SSR_PluginFns.c SSR_lib.c
diffstat 4 files changed, 72 insertions(+), 18 deletions(-) [+]
line diff
     1.1 --- a/SSR.h	Fri Feb 10 18:34:51 2012 +0100
     1.2 +++ b/SSR.h	Thu Mar 08 19:04:08 2012 +0100
     1.3 @@ -119,6 +119,7 @@
     1.4     #ifdef MEAS__PERF_COUNTERS
     1.5     ListOfArrays* counterList[NUM_CORES];
     1.6     #endif
     1.7 +   VirtProcr* idlePr[NUM_CORES][NUM_SCHED_SLOTS];
     1.8   }
     1.9  SSRSemEnv;
    1.10  
     2.1 --- a/SSR_Counter_Recording.c	Fri Feb 10 18:34:51 2012 +0100
     2.2 +++ b/SSR_Counter_Recording.c	Thu Mar 08 19:04:08 2012 +0100
     2.3 @@ -12,12 +12,10 @@
     2.4  
     2.5  void SSR__counter_handler(int evt_type, int vpid, int task, VirtProcr* pr, uint64 cycles, uint64 instrs)
     2.6  {
     2.7 -    if(!pr)
     2.8 +    
     2.9 +    if (pr->isMasterVP || pr->isShutdownVP) { //Save only values for actual work
    2.10          return;
    2.11 -    
    2.12 -    //FIXME: find more reliable way to separate master and slave VPs
    2.13 -    if (pr->isMasterVP || pr->isShutdownVP) //filters master VPs & shutdown
    2.14 -        return;
    2.15 +    }
    2.16  
    2.17      SSRSemEnv *semanticEnv = _VMSMasterEnv->semanticEnv;
    2.18              
    2.19 @@ -32,14 +30,20 @@
    2.20      if(pr){
    2.21          e.coreID = pr->coreAnimatedBy;
    2.22          e.slot = pr->schedSlot;
    2.23 +    } else {
    2.24 +        e.coreID = -1;
    2.25 +        e.slot = NULL;
    2.26      }
    2.27      
    2.28      int corenum;
    2.29      
    2.30      if(pr) corenum = pr->coreAnimatedBy; else return; 
    2.31 -    
    2.32 -    addToListOfArrays(CounterEvent,e,semanticEnv->counterList[corenum]);
    2.33 -
    2.34 +  
    2.35 +    if(evt_type==Work_start || evt_type==Work_end || evt_type==AppResponderInvocation_start){
    2.36 +        addToListOfArrays_ext(CounterEvent,e,semanticEnv->counterList[corenum]);
    2.37 +    } else {
    2.38 +        addToListOfArrays(CounterEvent,e,semanticEnv->counterList[corenum]);
    2.39 +    }
    2.40  }
    2.41  
    2.42  void set_counter_file(FILE* f){
    2.43 @@ -54,28 +58,44 @@
    2.44               fprintf(counterfile, "AppResponderInvocation_start");
    2.45               break;
    2.46           case AppResponder_start:
    2.47 -             fprintf(counterfile, "MasterLoop_beforeReqHdlr");
    2.48 +             fprintf(counterfile, "AppResponder_start");
    2.49               break;
    2.50           case AppResponder_end:
    2.51 -             fprintf(counterfile, "MasterLoop_afterReqHdlr");
    2.52 +             fprintf(counterfile, "AppResponder_end");
    2.53 +             break;
    2.54 +         case AssignerInvocation_start:
    2.55 +             fprintf(counterfile, "AssignerInvocation_start");
    2.56 +             break;
    2.57 +         case NextAssigner_start:
    2.58 +             fprintf(counterfile, "NextAssigner_start");
    2.59               break;
    2.60           case Assigner_start:
    2.61 -             fprintf(counterfile, "MasterLoop_beforeAssign");
    2.62 +             fprintf(counterfile, "Assigner_start");
    2.63               break;
    2.64           case Assigner_end:
    2.65 -             fprintf(counterfile, "MasterLoop_afterAssign");
    2.66 +             fprintf(counterfile, "Assigner_end");
    2.67               break;
    2.68           case Work_end:
    2.69 -             fprintf(counterfile, "CoreLoop_afterWork");
    2.70 +             fprintf(counterfile, "Work_end");
    2.71               break;
    2.72           case Work_start:
    2.73 -             fprintf(counterfile, "CoreLoop_beforeWork");
    2.74 +             fprintf(counterfile, "Work_start");
    2.75               break;
    2.76           case HwResponderInvocation_start:
    2.77 -             fprintf(counterfile, "Procr_suspend");
    2.78 +             fprintf(counterfile, "HwResponderInvocation_start");
    2.79 +             break;
    2.80 +         case Timestamp_start:
    2.81 +             fprintf(counterfile, "Timestamp_start");
    2.82 +             break;
    2.83 +         case Timestamp_end:
    2.84 +             fprintf(counterfile, "Timestamp_end");
    2.85               break;
    2.86           default:
    2.87               fprintf(counterfile, "unknown event");
    2.88       }
    2.89 -     fprintf(counterfile,", %d, %d, %llu, %llu\n",e->vp,e->task,e->cycles,e->instrs);
    2.90 +     fprintf(counterfile,", %d, %d, %llu, %llu",e->vp,e->task,e->cycles,e->instrs);
    2.91 +     if(e->coreID >=0)
    2.92 +         fprintf(counterfile,", %d",e->coreID);
    2.93 +     fprintf(counterfile,"\n");
    2.94 +     fflush(counterfile);
    2.95  }
    2.96 \ No newline at end of file
     3.1 --- a/SSR_PluginFns.c	Fri Feb 10 18:34:51 2012 +0100
     3.2 +++ b/SSR_PluginFns.c	Thu Mar 08 19:04:08 2012 +0100
     3.3 @@ -44,6 +44,26 @@
     3.4  
     3.5     schedPr = readPrivQ( semEnv->readyVPQs[coreNum] );
     3.6        //Note, using a non-blocking queue -- it returns NULL if queue empty
     3.7 +  if(!schedPr){
     3.8 +       schedPr = semEnv->idlePr[coreNum][slotNum];
     3.9 +     //things that would normally happen in resume(), but these VPs never go there
    3.10 +     #ifdef OBSERVE_UCC
    3.11 +        schedPr->numTimesScheduled++; //Somewhere here!
    3.12 +        Unit newu;
    3.13 +        newu.vp = schedPr->procrID;
    3.14 +        newu.task = schedPr->numTimesScheduled;
    3.15 +        addToListOfArrays(Unit,newu,semEnv->unitList);
    3.16 +   
    3.17 +        if (schedPr->numTimesScheduled > 1){
    3.18 +                Dependency newd;
    3.19 +                newd.from_vp = schedPr->procrID;
    3.20 +                newd.from_task = schedPr->numTimesScheduled - 1;
    3.21 +                newd.to_vp = schedPr->procrID;
    3.22 +                newd.to_task = schedPr->numTimesScheduled;
    3.23 +                addToListOfArrays(Dependency, newd ,semEnv->ctlDependenciesList);  
    3.24 +        }
    3.25 +      #endif
    3.26 +   }
    3.27     #ifdef OBSERVE_UCC
    3.28     if (schedPr) {
    3.29          //schedPr->numTimesScheduled++;
     4.1 --- a/SSR_lib.c	Fri Feb 10 18:34:51 2012 +0100
     4.2 +++ b/SSR_lib.c	Thu Mar 08 19:04:08 2012 +0100
     4.3 @@ -194,11 +194,17 @@
     4.4   }
     4.5  #endif
     4.6  
     4.7 +void idle_fn(void* data, VirtProcr *animatingPr){
     4.8 +    while(1){
     4.9 +        VMS__suspend_procr(animatingPr);
    4.10 +    }
    4.11 +}
    4.12 +
    4.13  void
    4.14  SSR__init_Helper()
    4.15   { SSRSemEnv       *semanticEnv;
    4.16     PrivQueueStruc **readyVPQs;
    4.17 -   int              coreIdx, i;
    4.18 +   int              coreIdx, i, j;
    4.19   
    4.20        //Hook up the semantic layer's plug-ins to the Master virt procr
    4.21     _VMSMasterEnv->requestHandler = &SSR__Request_Handler;
    4.22 @@ -215,6 +221,13 @@
    4.23     #ifdef MEAS__PERF_COUNTERS
    4.24     SSR__init_counter_data_structs();
    4.25     #endif
    4.26 +   for(i=0;i<NUM_CORES;++i){
    4.27 +       for(j=0;j<NUM_SCHED_SLOTS;++j){
    4.28 +           semanticEnv->idlePr[i][j] = VMS__create_procr(&idle_fn,NULL);
    4.29 +           semanticEnv->idlePr[i][j]->coreAnimatedBy = i;
    4.30 +       }
    4.31 +   }
    4.32 +
    4.33     #ifdef OBSERVE_UCC
    4.34     semanticEnv->unitList = makeListOfArrays(sizeof(Unit),128);
    4.35     semanticEnv->ctlDependenciesList = makeListOfArrays(sizeof(Dependency),128);
    4.36 @@ -365,8 +378,8 @@
    4.37          int i;
    4.38          for(i=0;i<NUM_CORES;i++){
    4.39              forAllInListOfArraysDo( semanticEnv->counterList[i], &print_counter_events_to_file );
    4.40 +            fflush(output);
    4.41          }
    4.42 -        fflush(output);
    4.43  
    4.44      } else
    4.45          printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n");