# HG changeset patch # User Nina Engelhardt # Date 1326476077 -3600 # Node ID 323418163771a67952068612471c0e1805c78c97 # Parent 5c59bfe62d92372158bf59d41996cbcb3a2ffe0d new counter interface works now diff -r 5c59bfe62d92 -r 323418163771 SSR_Counter_Recording.c --- a/SSR_Counter_Recording.c Fri Jan 13 15:03:20 2012 +0100 +++ b/SSR_Counter_Recording.c Fri Jan 13 18:34:37 2012 +0100 @@ -7,18 +7,29 @@ semanticEnv->counterList = makeListOfArrays(sizeof(CounterEvent), 128); } -void SSR__counter_handler(int evt_type, int coreID, int slotID, VirtProcr* pr, uint64 cycles, uint64 instrs) +void SSR__counter_handler(int evt_type, VirtProcr* pr, uint64 cycles, uint64 instrs) { -/* + SSRSemEnv *semanticEnv = _VMSMasterEnv->semanticEnv; CounterEvent e; e.event_type = evt_type; - e.coreID = coreID; - e.slotID = slotID; + e.coreID = pr->coreAnimatedBy; + e.slotID = pr->schedSlot; e.cycles = cycles; e.instrs = instrs; - + e.vp = pr->procrID; + e.task = pr->numTimesScheduled; addToListOfArrays(CounterEvent,e,semanticEnv->counterList); -*/ + +} + +void set_counter_file(FILE* f){ + counterfile = f; +} + +void print_counter_events_to_file(void* _e){ + CounterEvent* e = (CounterEvent*) _e; + + fprintf(counterfile, "event, %d, %d, %d, %llu, %llu\n",e->event_type,e->vp,e->task,e->cycles,e->instrs); } \ No newline at end of file diff -r 5c59bfe62d92 -r 323418163771 SSR_Counter_Recording.h --- a/SSR_Counter_Recording.h Fri Jan 13 15:03:20 2012 +0100 +++ b/SSR_Counter_Recording.h Fri Jan 13 18:34:37 2012 +0100 @@ -14,13 +14,20 @@ int event_type; int coreID; int slotID; + int vp; + int task; uint64 cycles; uint64 instrs; } CounterEvent; +FILE* counterfile; + void SSR__init_counter_data_structs(); -void SSR__counter_handler(int evt_type, int coreID, int slotID, VirtProcr* pr, uint64 cycles, uint64 instrs); +void SSR__counter_handler(int evt_type, VirtProcr* pr, uint64 cycles, uint64 instrs); +void set_counter_file(FILE* f); + +void print_counter_events_to_file(void* _e); #endif /* SSR_COUNTER_RECORDING_H */ diff -r 5c59bfe62d92 -r 323418163771 SSR_PluginFns.c --- a/SSR_PluginFns.c Fri Jan 13 15:03:20 2012 +0100 +++ b/SSR_PluginFns.c Fri Jan 13 18:34:37 2012 +0100 @@ -260,14 +260,15 @@ newu.vp = procr->procrID; newu.task = procr->numTimesScheduled + 1; addToListOfArrays(Unit,newu,semEnv->unitList); - //addToListOfArraysUnit(newu,semEnv->unitList); - Dependency newd; - newd.from_vp = procr->procrID; - newd.from_task = procr->numTimesScheduled; - newd.to_vp = procr->procrID; - newd.to_task = procr->numTimesScheduled + 1; - //addToListOfArraysDependency(newd,semEnv->ctlDependenciesList); - addToListOfArrays(Dependency, newd ,semEnv->ctlDependenciesList); + + if (procr->numTimesScheduled > 0){ + Dependency newd; + newd.from_vp = procr->procrID; + newd.from_task = procr->numTimesScheduled; + newd.to_vp = procr->procrID; + newd.to_task = procr->numTimesScheduled + 1; + addToListOfArrays(Dependency, newd ,semEnv->ctlDependenciesList); + } #endif writePrivQ( procr, semEnv->readyVPQs[ procr->coreAnimatedBy] ); } diff -r 5c59bfe62d92 -r 323418163771 SSR_lib.c --- a/SSR_lib.c Fri Jan 13 15:03:20 2012 +0100 +++ b/SSR_lib.c Fri Jan 13 18:34:37 2012 +0100 @@ -345,7 +345,33 @@ freeListOfArrays(semanticEnv->dynDependenciesList); #endif - +#ifdef MEAS__PERF_COUNTERS + for(n=0;n<255;n++) + { + sprintf(filename, "./counters/Counters.%d.csv",n); + output = fopen(filename,"r"); + if(output) + { + fclose(output); + }else{ + break; + } + } + if(n<255){ + printf("Saving Counter measurements to File: %s ...\n", filename); + output = fopen(filename,"w+"); + if(output!=NULL){ + set_counter_file(output); + forAllInListOfArraysDo( semanticEnv->counterList, &print_counter_events_to_file ); + fflush(output); + + } else + printf("Opening UCC file failed. Please check that folder \"counters\" exists in run directory and has write permission.\n"); + } else { + printf("Could not open UCC file, please clean \"counters\" folder. (Must contain less than 255 files.)\n"); + } + +#endif /* It's all allocated inside VMS's big chunk -- that's about to be freed, so * nothing to do here