# HG changeset patch # User Nina Engelhardt # Date 1312383918 -7200 # Node ID 724c7a0b687f6c8bf4fbeb8e1dc877def8e6f529 # Parent 659299627e70087ef065f6c0728dcd6f9cb8d645 save counters to file in csv diff -r 659299627e70 -r 724c7a0b687f Counters/Counters.c --- a/Counters/Counters.c Tue Aug 02 17:16:12 2011 +0200 +++ b/Counters/Counters.c Wed Aug 03 17:05:18 2011 +0200 @@ -1,8 +1,9 @@ #include "Counters.h" -void print_record(CounterRecord* record){ - printf("=== Loop Stats (VP %d): ===\n",record->vp_id); + +void print_record_human_readable(CounterRecord* record){ + printf("=== Loop Stats (VP %d suspended at %p): ===\n",record->vp_id,record->addr_of_libcall_for_req); printf("Constraints check done:\t%lu cycles, %lu instrs [Core %d]\n",record->sc_done_cycles,record->sc_done_instrs,record->req_core); printf("Time in ready queue:\tblocked at %u, unblocked at %u\n",record->blocked_timestamp,record->unblocked_timestamp); printf("Assigner started:\t%lu cycles, %lu instrs [Core %d]\n",record->start_assign_cycles,record->start_assign_instrs,record->assigning_core); @@ -12,3 +13,26 @@ printf("Status request read:\t%lu cycles, %lu instrs [Core %d]\n",record->req_cycles,record->req_instrs,record->req_core); } +void print_record_csv(CounterRecord* record) { + //Columns are VP,ret_addr, (core,cycles,instrs)* for each savepoint, blocked,unblocked + printf("%d,%p,",record->vp_id,record->addr_of_libcall_for_req); + printf("%d,%lu,%lu,",record->req_core,record->sc_done_cycles,record->sc_done_instrs); + printf("%d,%lu,%lu,",record->assigning_core,record->start_assign_cycles,record->start_assign_instrs); + printf("%d,%lu,%lu,",record->assigning_core,record->end_assign_cycles,record->end_assign_instrs); + printf("%d,%lu,%lu,",record->work_core,record->start_work_cycles,record->start_work_instrs); + printf("%d,%lu,%lu,",record->work_core,record->suspend_cycles,record->suspend_instrs); + printf("%d,%lu,%lu,",record->req_core,record->req_cycles,record->req_instrs); + printf("%u,%u\n",record->blocked_timestamp,record->unblocked_timestamp); +} + +void print_record_csv_to_file(CounterRecord* record, FILE* file) { + //Columns are VP,ret_addr, (core,cycles,instrs)* for each savepoint, blocked,unblocked + fprintf(file,"%d,%p,",record->vp_id,record->addr_of_libcall_for_req); + fprintf(file,"%d,%lu,%lu,",record->req_core,record->sc_done_cycles,record->sc_done_instrs); + fprintf(file,"%d,%lu,%lu,",record->assigning_core,record->start_assign_cycles,record->start_assign_instrs); + fprintf(file,"%d,%lu,%lu,",record->assigning_core,record->end_assign_cycles,record->end_assign_instrs); + fprintf(file,"%d,%lu,%lu,",record->work_core,record->start_work_cycles,record->start_work_instrs); + fprintf(file,"%d,%lu,%lu,",record->work_core,record->suspend_cycles,record->suspend_instrs); + fprintf(file,"%d,%lu,%lu,",record->req_core,record->req_cycles,record->req_instrs); + fprintf(file,"%u,%u\n",record->blocked_timestamp,record->unblocked_timestamp); +} \ No newline at end of file diff -r 659299627e70 -r 724c7a0b687f Counters/Counters.h --- a/Counters/Counters.h Tue Aug 02 17:16:12 2011 +0200 +++ b/Counters/Counters.h Wed Aug 03 17:05:18 2011 +0200 @@ -8,6 +8,8 @@ #include "../VMS_primitive_data_types.h" #include "../DynArray/DynArray.h" +#include + #ifndef COUNTERS_H #define COUNTERS_H @@ -32,9 +34,14 @@ uint64 start_work_instrs; uint64 suspend_cycles; uint64 suspend_instrs; + void* addr_of_libcall_for_req; } CounterRecord; -void print_record(CounterRecord* record); +void print_record_human_readable(CounterRecord* record); + +void print_record_csv(CounterRecord* record); + +void print_record_csv_to_file(CounterRecord* record, FILE* file); #endif /* COUNTERS_H */ diff -r 659299627e70 -r 724c7a0b687f MasterLoop.c --- a/MasterLoop.c Tue Aug 02 17:16:12 2011 +0200 +++ b/MasterLoop.c Wed Aug 03 17:05:18 2011 +0200 @@ -154,11 +154,12 @@ saveCyclesAndInstrs(thisCoresIdx,lastRecord->req_cycles,lastRecord->req_instrs); //End of task, start of next task //print counters from last run - print_record(lastRecord); + print_record_csv_to_file(lastRecord,_VMSMasterEnv->counteroutput); //create new entry in record array CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord)); newRecord->req_core = thisCoresIdx; newRecord->vp_id = currSlot->procrAssignedToSlot->procrID; + getReturnAddressBeforeLibraryCall(currSlot->procrAssignedToSlot, &(newRecord->addr_of_libcall_for_req)); addToDynArray( (void*) newRecord, currSlot->procrAssignedToSlot->counter_history_array_info); lastRecord = newRecord; #endif diff -r 659299627e70 -r 724c7a0b687f VMS.c --- a/VMS.c Tue Aug 02 17:16:12 2011 +0200 +++ b/VMS.c Wed Aug 03 17:05:18 2011 +0200 @@ -187,7 +187,25 @@ MakeTheMeasHists(); #ifdef MEAS__PERF_COUNTERS - printf("Creating HW counters..."); + //printf("Creating HW counters..."); + FILE* output; + int n; + char filename[255]; + for(n=0;n<255;n++) + { + sprintf(filename, "./counters/Counters.%d.dat",n); + output = fopen(filename,"r"); + if(output) + { + fclose(output); + }else{ + break; + } + } + printf("Saving Counter measurements to File: %s ...\n", filename); + output = fopen(filename,"w+"); + _VMSMasterEnv->counteroutput = output; + struct perf_event_attr hw_event; memset(&hw_event,0,sizeof(hw_event)); hw_event.type = PERF_TYPE_HARDWARE; @@ -437,8 +455,8 @@ * it lets the lang have lang-specific data related to creation transported * to the plugin. */ -void -VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ) __attribute__ ((noinline)) +__attribute__ ((noinline)) void +VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ) { VMSReqst req; @@ -472,8 +490,8 @@ * gets suspended in this call and all the virt processor's state disap- * pears -- making that suspend the last thing in the virt procr's trace. */ -void -VMS__send_dissipate_req( VirtProcr *procrToDissipate ) __attribute__ ((noinline)) +__attribute__ ((noinline)) void +VMS__send_dissipate_req( VirtProcr *procrToDissipate ) { VMSReqst req; req.reqType = dissipate; @@ -532,8 +550,8 @@ * to plugin *Then it does suspend, to cause request to be sent. */ -/*inline*/ void -VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ) __attribute__ ((noinline)) +/*inline*/__attribute__ ((noinline)) void +VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ) { VMSReqst req; req.reqType = semantic; @@ -545,8 +563,8 @@ } -/*inline*/ void -VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ) __attribute__ ((noinline)) +/*inline*/ __attribute__ ((noinline)) void +VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ) { VMSReqst req; diff -r 659299627e70 -r 724c7a0b687f VMS.h --- a/VMS.h Tue Aug 02 17:16:12 2011 +0200 +++ b/VMS.h Wed Aug 03 17:05:18 2011 +0200 @@ -33,7 +33,7 @@ //turns on the probe-instrumentation in the application -- when not // defined, the calls to the probe functions turn into comments -#define STATS__ENABLE_PROBES +//#define STATS__ENABLE_PROBES //#define TURN_ON_DEBUG_PROBES //These defines turn types of bug messages on and off @@ -267,6 +267,7 @@ #ifdef MEAS__PERF_COUNTERS int cycles_counter_fd[NUM_CORES]; int instrs_counter_fd[NUM_CORES]; + FILE* counteroutput; #endif } MasterEnv; @@ -366,16 +367,16 @@ inline void VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr ); -inline void +/*inline*/ __attribute__ ((noinline)) void VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ); void VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); -void inline +void /*inline**/ __attribute__ ((noinline)) VMS__send_dissipate_req( VirtProcr *prToDissipate ); -inline void +/*inline**/ __attribute__ ((noinline)) void VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); VMSReqst * @@ -433,6 +434,14 @@ } \ } while (0) +#define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ +void* frame_ptr0 = vp_ptr->framePtr; \ +void* frame_ptr1 = *((void**)frame_ptr0); \ +void* frame_ptr2 = *((void**)frame_ptr1); \ +void* frame_ptr3 = *((void**)frame_ptr2); \ +void* ret_addr = *((void**)frame_ptr3 + 1); \ +*res_ptr = ret_addr; \ +} while (0) #define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/