changeset 177:3bd35fc83c61 perf_counters

move loopgraph recording to plugin (\! changed scheduler fn prototype \!)
author Nina Engelhardt <nengel@mailbox.tu-berlin.de>
date Wed, 04 Jan 2012 16:40:10 +0100
parents 981acd1db6af
children 7523ee70d66c
files Counters/run_graph.py MasterLoop.c VMS.c VMS.h loop.c
diffstat 5 files changed, 13 insertions(+), 137 deletions(-) [+]
line diff
     1.1 --- a/Counters/run_graph.py	Mon Dec 05 18:59:48 2011 +0100
     1.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.3 @@ -1,75 +0,0 @@
     1.4 -#!/usr/bin/python
     1.5 -
     1.6 -import sys
     1.7 -import pygraph
     1.8 -
     1.9 -if len(sys.argv)<3 :
    1.10 -	print "Usage:",sys.argv[0],"dependencyfile.dot counterfile.csv"
    1.11 -	sys.exit()
    1.12 -
    1.13 -try:
    1.14 -	dependencyfile = open(sys.argv[1])
    1.15 -	dependencystring = dependencyfile.read()
    1.16 -except IOError as (errno, strerror):
    1.17 -	print "Error {0}: {1}".format(errno, strerror)
    1.18 -	sys.exit()
    1.19 -	
    1.20 -try:
    1.21 -	counterfile = open(sys.argv[2])
    1.22 -except IOError as (errno, strerror):
    1.23 -	print (("Error {0}: {1}".format)(errno, strerror))
    1.24 -	sys.exit()	
    1.25 -	
    1.26 -from pygraph.readwrite.dot import read,write
    1.27 -
    1.28 -dependencygraph = read(dependencystring)
    1.29 -
    1.30 -import csv
    1.31 -
    1.32 -counterreader = (csv.reader)(counterfile)
    1.33 -
    1.34 -
    1.35 -
    1.36 -for row in counterreader:
    1.37 -	dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('suspend_point',row[2]))
    1.38 -	dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('schedule_check_cycles',int(row[4])-int(row[19])))
    1.39 -	dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('sync_cycles',int(row[25])-int(row[24])))
    1.40 -	dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('assign_cycles',int(row[10])-int(row[7])))
    1.41 -	dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('work_comm_cycles',int(row[16])-int(row[13])))
    1.42 -	dependencygraph.add_node_attribute('VP_{0}_{1}'.format(row[0],row[1]),('status_cycles',int(row[22])-int(row[16])))
    1.43 -
    1.44 -	
    1.45 -def path_length(path):
    1.46 -	length = 0
    1.47 -	for node in path:
    1.48 -		attrd = dict(dependencygraph.node_attributes(node))
    1.49 -		length += attrd['schedule_check_cycles']
    1.50 -		length += attrd['sync_cycles']
    1.51 -		length += attrd['assign_cycles']
    1.52 -		length += attrd['work_comm_cycles']
    1.53 -		length += attrd['status_cycles']
    1.54 -	return length
    1.55 -	
    1.56 -	
    1.57 -def find_critical_path(graph, start, end, path=[]):
    1.58 -	path = path + [end]
    1.59 -	if start == end:
    1.60 -		return path
    1.61 -	if not graph.has_node(end):
    1.62 -		return None
    1.63 -	longest = None
    1.64 -	for node in graph.incidents(end):
    1.65 -		if node not in path:
    1.66 -			newpath = find_critical_path(graph, start, node, path)
    1.67 -			if newpath:
    1.68 -				if not longest or path_length(newpath) > path_length(longest):
    1.69 -					longest = newpath
    1.70 -	return longest
    1.71 -
    1.72 -cr= find_critical_path(dependencygraph, 'VP_2_0', 'VP_2_97')
    1.73 -
    1.74 -for node in cr:
    1.75 -	dependencygraph.add_node_attribute(node,('color','red'))
    1.76 -	dependencygraph.add_node_attribute(node,('style','bold'))
    1.77 -
    1.78 -print write(dependencygraph)
     2.1 --- a/MasterLoop.c	Mon Dec 05 18:59:48 2011 +0100
     2.2 +++ b/MasterLoop.c	Wed Jan 04 16:40:10 2012 +0100
     2.3 @@ -132,12 +132,7 @@
     2.4     semanticEnv      = masterEnv->semanticEnv;
     2.5  
     2.6     #ifdef DETECT_LOOP_GRAPH
     2.7 -   if(numSlotsFilled > 0){
     2.8 -   b = new_bulb();
     2.9 -   addToDynArray((void*)b,masterEnv->loop_graph_array_info);
    2.10 -   set_bulb_core(b,thisCoresIdx);
    2.11 -   set_bulb_id(b,masterEnv->loop_counter[thisCoresIdx]++);
    2.12 -   }
    2.13 +
    2.14     #endif
    2.15  
    2.16        //Poll each slot's Done flag
    2.17 @@ -209,14 +204,14 @@
    2.18                 saveCyclesAndInstrs(thisCoresIdx,tmp_cycles,tmp_instrs);
    2.19                 #endif
    2.20           schedVirtPr =
    2.21 -          (*slaveScheduler)( semanticEnv, thisCoresIdx );
    2.22 +          (*slaveScheduler)( semanticEnv, thisCoresIdx, slotIdx );
    2.23  
    2.24           if( schedVirtPr != NULL )
    2.25            { currSlot->procrAssignedToSlot = schedVirtPr;
    2.26              schedVirtPr->schedSlot        = currSlot;
    2.27              currSlot->needsProcrAssigned  = FALSE;
    2.28              numSlotsFilled               += 1;
    2.29 -            schedVirtPr->numTimesScheduled++;
    2.30 +
    2.31                 #ifdef MEAS__PERF_COUNTERS
    2.32                 //end assigner
    2.33                 int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
    2.34 @@ -226,16 +221,13 @@
    2.35                 lastRecord->start_assign_instrs = tmp_instrs;
    2.36                 saveCyclesAndInstrs(thisCoresIdx,lastRecord->end_assign_cycles,lastRecord->end_assign_instrs);
    2.37                 #endif
    2.38 +               #ifdef DETECT_LOOP_GRAPH
    2.39 +
    2.40 +               #endif
    2.41              writeVMSQ( schedVirtPr, readyToAnimateQ );
    2.42            }
    2.43         }
    2.44 -               #ifdef DETECT_LOOP_GRAPH
    2.45 -               if(!currSlot->needsProcrAssigned) {
    2.46 -                   int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1;
    2.47 -                   CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx];
    2.48 -                   set_bulb_member(b,slotIdx,currSlot->procrAssignedToSlot->procrID,lastRecord->task_position);
    2.49 -               }
    2.50 -               #endif
    2.51 +
    2.52      }
    2.53  
    2.54     
     3.1 --- a/VMS.c	Mon Dec 05 18:59:48 2011 +0100
     3.2 +++ b/VMS.c	Wed Jan 04 16:40:10 2012 +0100
     3.3 @@ -188,13 +188,7 @@
     3.4     
     3.5  
     3.6     #ifdef DETECT_LOOP_GRAPH
     3.7 -   _VMSMasterEnv->loop_graph = VMS__malloc(10*sizeof(void*));
     3.8 -   _VMSMasterEnv->loop_graph_array_info = makePrivDynArrayInfoFrom((void***)&(_VMSMasterEnv->loop_graph),10);
     3.9 -   int loop_i;
    3.10 -   for(loop_i=0;loop_i<NUM_CORES;loop_i++){
    3.11 -       _VMSMasterEnv->loop_counter[loop_i]=0;
    3.12 -   }
    3.13 -   
    3.14 +
    3.15     #endif
    3.16  
    3.17     #ifdef MEAS__PERF_COUNTERS
    3.18 @@ -785,41 +779,7 @@
    3.19     //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile);
    3.20     //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHistExt );
    3.21  
    3.22 -   #ifdef DETECT_LOOP_GRAPH
    3.23 -   FILE* loop_output;
    3.24 -   int loop_n;
    3.25 -   char loop_filename[255];    
    3.26 -    for(loop_n=0;loop_n<255;loop_n++)
    3.27 -    {
    3.28 -        sprintf(loop_filename, "./counters/LoopGraph.%d.dot",loop_n);
    3.29 -        loop_output = fopen(loop_filename,"r");
    3.30 -        if(loop_output)
    3.31 -        {
    3.32 -            fclose(loop_output);
    3.33 -        }else{
    3.34 -            break;
    3.35 -        }
    3.36 -    }
    3.37 -   if(loop_n<255){
    3.38 -    printf("Saving Loop Graph to File: %s ...\n", loop_filename);
    3.39 -    loop_output = fopen(loop_filename,"w+");
    3.40 -    if(loop_output!=NULL){
    3.41 -        set_dependency_file(loop_output);
    3.42 -        fprintf(loop_output,"digraph Loop {\n");
    3.43 -        set_loop_file(loop_output);
    3.44 -        forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info );
    3.45 -        forAllInDynArrayDo( _VMSMasterEnv->loop_graph_array_info, &print_per_slot_to_file );
    3.46 -        //int coreIdx;
    3.47 -        //for(coreIdx=0;coreIdx<NUM_CORES;coreIdx++){
    3.48 -        //    fprintf(loop_output,"sync%d_%d [shape=rect,label=\"Sync\"];\n",coreIdx,_VMSMasterEnv->loop_counter[coreIdx]);
    3.49 -        //}
    3.50 -        fprintf(loop_output,"}\n");
    3.51 -    } else
    3.52 -        printf("Opening Loop Graph file failed. Please check that folder \"counters\" exists in run directory.\n");
    3.53 -   } else {
    3.54 -       printf("Could not open Loop Graph file, please clean \"counters\" folder. (Must contain less than 255 files.)\n");
    3.55 -   }
    3.56 -#endif
    3.57 +
    3.58     #ifdef MEAS__TIME_PLUGIN
    3.59     printHist( _VMSMasterEnv->reqHdlrLowTimeHist );
    3.60     saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist );
     4.1 --- a/VMS.h	Mon Dec 05 18:59:48 2011 +0100
     4.2 +++ b/VMS.h	Wed Jan 04 16:40:10 2012 +0100
     4.3 @@ -18,6 +18,7 @@
     4.4  #include "vmalloc.h"
     4.5  #include "Counters/Counters.h"
     4.6  #include "loop.h"
     4.7 +#include "ListOfArrays/ListOfArrays.h"
     4.8  
     4.9  #include <pthread.h>
    4.10  #include <sys/time.h>
    4.11 @@ -124,7 +125,7 @@
    4.12  typedef struct _GateStruc     GateStruc;
    4.13  
    4.14  
    4.15 -typedef VirtProcr * (*SlaveScheduler)  ( void *, int );   //semEnv, coreIdx
    4.16 +typedef VirtProcr * (*SlaveScheduler)  ( void *, int, int );   //semEnv, coreIdx
    4.17  typedef void  (*RequestHandler)  ( VirtProcr *, void * ); //prWReqst, semEnv
    4.18  typedef void  (*VirtProcrFnPtr)  ( void *, VirtProcr * ); //initData, animPr
    4.19  typedef void    VirtProcrFn      ( void *, VirtProcr * ); //initData, animPr
    4.20 @@ -279,9 +280,7 @@
    4.21     PrivDynArrayInfo* counter_history_array_info;
    4.22     #endif
    4.23     #ifdef DETECT_LOOP_GRAPH
    4.24 -   bulb* loop_graph;
    4.25 -   PrivDynArrayInfo* loop_graph_array_info;
    4.26 -   int loop_counter[NUM_CORES];
    4.27 +
    4.28     #endif
    4.29   }
    4.30  MasterEnv;
     5.1 --- a/loop.c	Mon Dec 05 18:59:48 2011 +0100
     5.2 +++ b/loop.c	Wed Jan 04 16:40:10 2012 +0100
     5.3 @@ -46,7 +46,7 @@
     5.4      for(i=0;i<NUM_SCHED_SLOTS;++i){
     5.5          if(b[2*i] != 0){
     5.6              if(prev_slots[b[2*NUM_SCHED_SLOTS]][2*i] != 0){
     5.7 -               fprintf(loop_file, "VP_%d_%d -> VP_%d_%d;\n",prev_slots[b[2*NUM_SCHED_SLOTS]][2*i],prev_slots[b[2*NUM_SCHED_SLOTS]][2*i+1],b[2*i],b[2*i+1]); 
     5.8 +               fprintf(loop_file, "loopDep, %d, %d, %d, %d;\n",prev_slots[b[2*NUM_SCHED_SLOTS]][2*i],prev_slots[b[2*NUM_SCHED_SLOTS]][2*i+1],b[2*i],b[2*i+1]); 
     5.9              }
    5.10              prev_slots[b[2*NUM_SCHED_SLOTS]][2*i] = b[2*i];
    5.11              prev_slots[b[2*NUM_SCHED_SLOTS]][2*i+1] = b[2*i+1];