diff MasterLoop.c @ 108:3bc3b89630c7

perf counters
author engelhardt@cray1
date Tue, 26 Jul 2011 15:36:24 +0200
parents fe5ec83f1baf
children 659299627e70
line diff
     1.1 --- a/MasterLoop.c	Tue Jul 26 15:35:57 2011 +0200
     1.2 +++ b/MasterLoop.c	Tue Jul 26 15:36:24 2011 +0200
     1.3 @@ -147,6 +147,32 @@
     1.4                 int32 startStamp1, endStamp1;
     1.5                 saveLowTimeStampCountInto( startStamp1 );
     1.6                 #endif
     1.7 +               #ifdef MEAS__PERF_COUNTER
     1.8 +               int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
     1.9 +               CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx];
    1.10 +               lastRecord->req_core = thisCoresIdx;
    1.11 +               int cycles_fd = masterEnv->cycles_counter_fd[thisCoresIdx];
    1.12 +               int instrs_fd = masterEnv->instrs_counter_fd[thisCoresIdx];
    1.13 +               int nread;
    1.14 +               
    1.15 +               nread = read(cycles_fd,&(lastRecord->req_cycles),sizeof(lastRecord->req_cycles));
    1.16 +               if(nread<0){
    1.17 +                   lastRecord->req_cycles = 0;
    1.18 +               }
    1.19 +
    1.20 +               nread = read(instrs_fd,&(lastRecord->req_instrs),sizeof(lastRecord->req_instrs));
    1.21 +               if(nread<0){
    1.22 +                   lastRecord->req_instrs = 0;
    1.23 +               }
    1.24 +               //End of task, start of next task
    1.25 +               //print counters from last run
    1.26 +               print_record(lastRecord);
    1.27 +               //create new entry in record array here
    1.28 +               CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord));
    1.29 +               newRecord->req_core = thisCoresIdx;
    1.30 +               addToDynArray( (void*) newRecord, currSlot->procrAssignedToSlot->counter_history_array_info);
    1.31 +               lastRecord = newRecord;
    1.32 +               #endif
    1.33                 //============================================================
    1.34           (*requestHandler)( currSlot->procrAssignedToSlot, semanticEnv );
    1.35                 //====================== MEASUREMENT STUFF ===================
    1.36 @@ -157,13 +183,59 @@
    1.37                 addIntervalToHist( startStamp1, endStamp1,
    1.38                                          _VMSMasterEnv->reqHdlrHighTimeHist );
    1.39                 #endif
    1.40 +               #ifdef MEAS__PERF_COUNTER
    1.41 +
    1.42 +               nread = read(cycles_fd,&(lastRecord->sc_done_cycles),sizeof(lastRecord->sc_done_cycles));
    1.43 +               if(nread<0){
    1.44 +                   lastRecord->sc_done_cycles = 0;
    1.45 +               }
    1.46 +               nread = read(instrs_fd,&(lastRecord->sc_done_instrs),sizeof(lastRecord->sc_done_instrs));
    1.47 +               if(nread<0){
    1.48 +                   lastRecord->sc_done_instrs = 0;
    1.49 +               }
    1.50 +               #endif
    1.51                 //============================================================
    1.52         }
    1.53        if( currSlot->needsProcrAssigned )
    1.54         {    //give slot a new virt procr
    1.55 +               #ifdef MEAS__PERF_COUNTER
    1.56 +                //start assigner
    1.57 +               int cycles_fd = masterEnv->cycles_counter_fd[thisCoresIdx];
    1.58 +               int instrs_fd = masterEnv->instrs_counter_fd[thisCoresIdx];
    1.59 +               uint64 tmp_cycles;
    1.60 +               uint64 tmp_instrs;
    1.61 +               int nread=0;
    1.62 +               
    1.63 +               nread = read(cycles_fd,&tmp_cycles,sizeof(uint64));
    1.64 +               if(nread<0){
    1.65 +                   tmp_cycles = 0;
    1.66 +               }
    1.67 +
    1.68 +               nread = read(instrs_fd,&tmp_instrs,sizeof(uint64));
    1.69 +               if(nread<0){
    1.70 +                   tmp_instrs = 0;
    1.71 +               }
    1.72 +               #endif
    1.73           schedVirtPr =
    1.74            (*slaveScheduler)( semanticEnv, thisCoresIdx );
    1.75 -         
    1.76 +               #ifdef MEAS__PERF_COUNTER
    1.77 +               //end assigner
    1.78 +               int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
    1.79 +               CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx];
    1.80 +               lastRecord->assigning_core = thisCoresIdx;
    1.81 +               lastRecord->start_assign_cycles = tmp_cycles;
    1.82 +               lastRecord->start_assign_instrs = tmp_instrs;
    1.83 +               
    1.84 +               nread = read(cycles_fd,&(lastRecord->end_assign_cycles),sizeof(lastRecord->end_assign_cycles));
    1.85 +               if(nread<0){
    1.86 +                   lastRecord->end_assign_cycles = 0;
    1.87 +               }
    1.88 +
    1.89 +               nread = read(instrs_fd,&(lastRecord->end_assign_instrs),sizeof(lastRecord->end_assign_instrs));
    1.90 +               if(nread<0){
    1.91 +                   lastRecord->end_assign_instrs = 0;
    1.92 +               }
    1.93 +               #endif
    1.94           if( schedVirtPr != NULL )
    1.95            { currSlot->procrAssignedToSlot = schedVirtPr;
    1.96              schedVirtPr->schedSlot        = currSlot;