# HG changeset patch # User Nina Engelhardt # Date 1318945984 -7200 # Node ID aefd87f9d12fb59c11b7498ce37352f51d7f6c25 # Parent fe3ff53b55a67c36cf9d24c323936abafc183052 loop graph diff -r fe3ff53b55a6 -r aefd87f9d12f MasterLoop.c --- a/MasterLoop.c Wed Sep 28 14:58:41 2011 +0200 +++ b/MasterLoop.c Tue Oct 18 15:53:04 2011 +0200 @@ -90,6 +90,8 @@ volatileMasterPr = animatingPr; masterPr = (VirtProcr*)volatileMasterPr; //used to force re-define after jmp + bulb b = new_bulb(); + numSlotsFilled=1; //First animation of each MasterVP will in turn animate this part // of setup code.. (VP creator sets up the stack as if this function // was called normally, but actually get here by jmp) @@ -129,6 +131,14 @@ slaveScheduler = masterEnv->slaveScheduler; semanticEnv = masterEnv->semanticEnv; + #ifdef DETECT_LOOP_GRAPH + if(numSlotsFilled > 0){ + b = new_bulb(); + addToDynArray((void*)b,masterEnv->loop_graph_array_info); + set_bulb_core(b,thisCoresIdx); + set_bulb_id(b,masterEnv->loop_counter[thisCoresIdx]++); + } + #endif //Poll each slot's Done flag numSlotsFilled = 0; @@ -160,6 +170,8 @@ Dependency* newd = new_dependency(currSlot->procrAssignedToSlot->procrID,lastRecord->task_position,currSlot->procrAssignedToSlot->procrID,lastRecord->task_position + 1); addToDynArray((void*) newd ,masterEnv->dependenciesInfo); + + //print_record_human_readable(lastRecord); //create new entry in record array CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord)); @@ -217,6 +229,13 @@ writeVMSQ( schedVirtPr, readyToAnimateQ ); } } + #ifdef DETECT_LOOP_GRAPH + if(!currSlot->needsProcrAssigned) { + int lastRecordIdx = currSlot->procrAssignedToSlot->counter_history_array_info->numInArray -1; + CounterRecord* lastRecord = currSlot->procrAssignedToSlot->counter_history[lastRecordIdx]; + set_bulb_member(b,slotIdx,currSlot->procrAssignedToSlot->procrID,lastRecord->task_position); + } + #endif } diff -r fe3ff53b55a6 -r aefd87f9d12f VMS.c --- a/VMS.c Wed Sep 28 14:58:41 2011 +0200 +++ b/VMS.c Tue Oct 18 15:53:04 2011 +0200 @@ -190,7 +190,17 @@ _VMSMasterEnv->dependencies = VMS__malloc(10*sizeof(void*)); _VMSMasterEnv->dependenciesInfo = makePrivDynArrayInfoFrom((void***)&(_VMSMasterEnv->dependencies),10); #endif + + #ifdef DETECT_LOOP_GRAPH + _VMSMasterEnv->loop_graph = VMS__malloc(10*sizeof(void*)); + _VMSMasterEnv->loop_graph_array_info = makePrivDynArrayInfoFrom((void***)&(_VMSMasterEnv->loop_graph),10); + int loop_i; + for(loop_i=0;loop_iloop_counter[loop_i]=0; + } + #endif + #ifdef MEAS__PERF_COUNTERS _VMSMasterEnv->counter_history = VMS__malloc(10*sizeof(void*)); _VMSMasterEnv->counter_history_array_info = makePrivDynArrayInfoFrom((void***)&(_VMSMasterEnv->counter_history),10); @@ -809,6 +819,41 @@ printf("Could not open Dependencies file, please clean \"counters\" folder. (Must contain less than 255 files.)\n"); } #endif + #ifdef DETECT_LOOP_GRAPH + FILE* loop_output; + int loop_n; + char loop_filename[255]; + for(loop_n=0;loop_n<255;loop_n++) + { + sprintf(loop_filename, "./counters/LoopGraph.%d.dot",loop_n); + loop_output = fopen(loop_filename,"r"); + if(loop_output) + { + fclose(loop_output); + }else{ + break; + } + } + if(loop_n<255){ + printf("Saving Loop Graph to File: %s ...\n", loop_filename); + loop_output = fopen(loop_filename,"w+"); + if(loop_output!=NULL){ + set_dependency_file(loop_output); + fprintf(loop_output,"digraph Loop {\n"); + set_loop_file(loop_output); + forAllInDynArrayDo(_VMSMasterEnv->counter_history_array_info, &print_dot_node_info ); + forAllInDynArrayDo( _VMSMasterEnv->loop_graph_array_info, &print_per_slot_to_file ); + //int coreIdx; + //for(coreIdx=0;coreIdxloop_counter[coreIdx]); + //} + fprintf(loop_output,"}\n"); + } else + printf("Opening Loop Graph file failed. Please check that folder \"counters\" exists in run directory.\n"); + } else { + printf("Could not open Loop Graph file, please clean \"counters\" folder. (Must contain less than 255 files.)\n"); + } +#endif #ifdef MEAS__TIME_PLUGIN printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); diff -r fe3ff53b55a6 -r aefd87f9d12f VMS.h --- a/VMS.h Wed Sep 28 14:58:41 2011 +0200 +++ b/VMS.h Tue Oct 18 15:53:04 2011 +0200 @@ -18,6 +18,7 @@ #include "vmalloc.h" #include "Counters/Counters.h" #include "dependency.h" +#include "loop.h" #include #include @@ -77,6 +78,7 @@ #define MEAS__PERF_COUNTERS #define DETECT_DEPENDENCIES +#define DETECT_LOOP_GRAPH //========================= Hardware related Constants ===================== //This value is the number of hardware threads in the shared memory @@ -280,6 +282,11 @@ CounterRecord** counter_history; PrivDynArrayInfo* counter_history_array_info; #endif + #ifdef DETECT_LOOP_GRAPH + bulb* loop_graph; + PrivDynArrayInfo* loop_graph_array_info; + int loop_counter[NUM_CORES]; + #endif } MasterEnv; diff -r fe3ff53b55a6 -r aefd87f9d12f loop.c --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loop.c Tue Oct 18 15:53:04 2011 +0200 @@ -0,0 +1,55 @@ +#include "VMS.h" +#include "vmalloc.h" +#include "loop.h" + +bulb new_bulb() { + bulb b = VMS__malloc((2*NUM_SCHED_SLOTS + 2)*sizeof(int)); + memset(b,0,(2*NUM_SCHED_SLOTS + 2)*sizeof(int)); + return b; +} + +void set_bulb_member(bulb b, int i, int vp, int task){ + b[2*i]=vp; + b[2*i+1]=task; +} + +void set_bulb_core(bulb b, int core){ + b[2*NUM_SCHED_SLOTS] = core; +} + +void set_bulb_id(bulb b, int id){ + b[2*NUM_SCHED_SLOTS + 1] = id; +} + +void set_loop_file(FILE* file){ + loop_file=file; +} + +void print_bulb_to_file(void* _b){ + bulb b = (bulb) _b; + if(b[2*NUM_SCHED_SLOTS]!=0 || b[2*NUM_SCHED_SLOTS + 1]!=0) + fprintf(loop_file,"sync%d_%d [shape=rect];\n",b[2*NUM_SCHED_SLOTS],b[2*NUM_SCHED_SLOTS + 1]); + int i; + for(i=0;i VP_%d_%d;\n",b[2*NUM_SCHED_SLOTS],b[2*NUM_SCHED_SLOTS + 1],b[2*i],b[2*i+1]); + fprintf(loop_file, "VP_%d_%d -> sync%d_%d;\n",b[2*i],b[2*i+1],b[2*NUM_SCHED_SLOTS],b[2*NUM_SCHED_SLOTS + 1] + 1); + } + } +} + +int prev_slots[NUM_CORES][2*NUM_SCHED_SLOTS]; + +void print_per_slot_to_file(void* _b){ + bulb b = (bulb) _b; + int i; + for(i=0;i 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]); + } + prev_slots[b[2*NUM_SCHED_SLOTS]][2*i] = b[2*i]; + prev_slots[b[2*NUM_SCHED_SLOTS]][2*i+1] = b[2*i+1]; + } + } +} \ No newline at end of file diff -r fe3ff53b55a6 -r aefd87f9d12f loop.h --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/loop.h Tue Oct 18 15:53:04 2011 +0200 @@ -0,0 +1,31 @@ +/* + * File: loop.h + * Author: engelhardt + * + * Created on 4. Oktober 2011, 15:54 + */ + +#ifndef LOOP_H +#define LOOP_H + +#include + +typedef int* bulb; + +FILE* loop_file; + +bulb new_bulb(); + +void set_bulb_member(bulb b, int i, int vp, int task); + +void set_bulb_core(bulb b, int core); + +void set_bulb_id(bulb b, int id); + +void set_loop_file(FILE* file); + +void print_bulb_to_file(void* b); + +void print_per_slot_to_file(void* _b); +#endif /* LOOP_H */ +