Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
changeset 110:724c7a0b687f perf_counters
save counters to file in csv
| author | Nina Engelhardt |
|---|---|
| date | Wed, 03 Aug 2011 17:05:18 +0200 |
| parents | 659299627e70 |
| children | b1817e2451b1 |
| files | Counters/Counters.c Counters/Counters.h MasterLoop.c VMS.c VMS.h |
| diffstat | 5 files changed, 76 insertions(+), 17 deletions(-) [+] |
line diff
1.1 --- a/Counters/Counters.c Tue Aug 02 17:16:12 2011 +0200 1.2 +++ b/Counters/Counters.c Wed Aug 03 17:05:18 2011 +0200 1.3 @@ -1,8 +1,9 @@ 1.4 #include "Counters.h" 1.5 1.6 1.7 -void print_record(CounterRecord* record){ 1.8 - printf("=== Loop Stats (VP %d): ===\n",record->vp_id); 1.9 + 1.10 +void print_record_human_readable(CounterRecord* record){ 1.11 + printf("=== Loop Stats (VP %d suspended at %p): ===\n",record->vp_id,record->addr_of_libcall_for_req); 1.12 printf("Constraints check done:\t%lu cycles, %lu instrs [Core %d]\n",record->sc_done_cycles,record->sc_done_instrs,record->req_core); 1.13 printf("Time in ready queue:\tblocked at %u, unblocked at %u\n",record->blocked_timestamp,record->unblocked_timestamp); 1.14 printf("Assigner started:\t%lu cycles, %lu instrs [Core %d]\n",record->start_assign_cycles,record->start_assign_instrs,record->assigning_core); 1.15 @@ -12,3 +13,26 @@ 1.16 printf("Status request read:\t%lu cycles, %lu instrs [Core %d]\n",record->req_cycles,record->req_instrs,record->req_core); 1.17 } 1.18 1.19 +void print_record_csv(CounterRecord* record) { 1.20 + //Columns are VP,ret_addr, (core,cycles,instrs)* for each savepoint, blocked,unblocked 1.21 + printf("%d,%p,",record->vp_id,record->addr_of_libcall_for_req); 1.22 + printf("%d,%lu,%lu,",record->req_core,record->sc_done_cycles,record->sc_done_instrs); 1.23 + printf("%d,%lu,%lu,",record->assigning_core,record->start_assign_cycles,record->start_assign_instrs); 1.24 + printf("%d,%lu,%lu,",record->assigning_core,record->end_assign_cycles,record->end_assign_instrs); 1.25 + printf("%d,%lu,%lu,",record->work_core,record->start_work_cycles,record->start_work_instrs); 1.26 + printf("%d,%lu,%lu,",record->work_core,record->suspend_cycles,record->suspend_instrs); 1.27 + printf("%d,%lu,%lu,",record->req_core,record->req_cycles,record->req_instrs); 1.28 + printf("%u,%u\n",record->blocked_timestamp,record->unblocked_timestamp); 1.29 +} 1.30 + 1.31 +void print_record_csv_to_file(CounterRecord* record, FILE* file) { 1.32 + //Columns are VP,ret_addr, (core,cycles,instrs)* for each savepoint, blocked,unblocked 1.33 + fprintf(file,"%d,%p,",record->vp_id,record->addr_of_libcall_for_req); 1.34 + fprintf(file,"%d,%lu,%lu,",record->req_core,record->sc_done_cycles,record->sc_done_instrs); 1.35 + fprintf(file,"%d,%lu,%lu,",record->assigning_core,record->start_assign_cycles,record->start_assign_instrs); 1.36 + fprintf(file,"%d,%lu,%lu,",record->assigning_core,record->end_assign_cycles,record->end_assign_instrs); 1.37 + fprintf(file,"%d,%lu,%lu,",record->work_core,record->start_work_cycles,record->start_work_instrs); 1.38 + fprintf(file,"%d,%lu,%lu,",record->work_core,record->suspend_cycles,record->suspend_instrs); 1.39 + fprintf(file,"%d,%lu,%lu,",record->req_core,record->req_cycles,record->req_instrs); 1.40 + fprintf(file,"%u,%u\n",record->blocked_timestamp,record->unblocked_timestamp); 1.41 +} 1.42 \ No newline at end of file
2.1 --- a/Counters/Counters.h Tue Aug 02 17:16:12 2011 +0200 2.2 +++ b/Counters/Counters.h Wed Aug 03 17:05:18 2011 +0200 2.3 @@ -8,6 +8,8 @@ 2.4 #include "../VMS_primitive_data_types.h" 2.5 #include "../DynArray/DynArray.h" 2.6 2.7 +#include <stdio.h> 2.8 + 2.9 #ifndef COUNTERS_H 2.10 #define COUNTERS_H 2.11 2.12 @@ -32,9 +34,14 @@ 2.13 uint64 start_work_instrs; 2.14 uint64 suspend_cycles; 2.15 uint64 suspend_instrs; 2.16 + void* addr_of_libcall_for_req; 2.17 } CounterRecord; 2.18 2.19 -void print_record(CounterRecord* record); 2.20 +void print_record_human_readable(CounterRecord* record); 2.21 + 2.22 +void print_record_csv(CounterRecord* record); 2.23 + 2.24 +void print_record_csv_to_file(CounterRecord* record, FILE* file); 2.25 2.26 #endif /* COUNTERS_H */ 2.27
3.1 --- a/MasterLoop.c Tue Aug 02 17:16:12 2011 +0200 3.2 +++ b/MasterLoop.c Wed Aug 03 17:05:18 2011 +0200 3.3 @@ -154,11 +154,12 @@ 3.4 saveCyclesAndInstrs(thisCoresIdx,lastRecord->req_cycles,lastRecord->req_instrs); 3.5 //End of task, start of next task 3.6 //print counters from last run 3.7 - print_record(lastRecord); 3.8 + print_record_csv_to_file(lastRecord,_VMSMasterEnv->counteroutput); 3.9 //create new entry in record array 3.10 CounterRecord* newRecord = VMS__malloc(sizeof(CounterRecord)); 3.11 newRecord->req_core = thisCoresIdx; 3.12 newRecord->vp_id = currSlot->procrAssignedToSlot->procrID; 3.13 + getReturnAddressBeforeLibraryCall(currSlot->procrAssignedToSlot, &(newRecord->addr_of_libcall_for_req)); 3.14 addToDynArray( (void*) newRecord, currSlot->procrAssignedToSlot->counter_history_array_info); 3.15 lastRecord = newRecord; 3.16 #endif
4.1 --- a/VMS.c Tue Aug 02 17:16:12 2011 +0200 4.2 +++ b/VMS.c Wed Aug 03 17:05:18 2011 +0200 4.3 @@ -187,7 +187,25 @@ 4.4 MakeTheMeasHists(); 4.5 4.6 #ifdef MEAS__PERF_COUNTERS 4.7 - printf("Creating HW counters..."); 4.8 + //printf("Creating HW counters..."); 4.9 + FILE* output; 4.10 + int n; 4.11 + char filename[255]; 4.12 + for(n=0;n<255;n++) 4.13 + { 4.14 + sprintf(filename, "./counters/Counters.%d.dat",n); 4.15 + output = fopen(filename,"r"); 4.16 + if(output) 4.17 + { 4.18 + fclose(output); 4.19 + }else{ 4.20 + break; 4.21 + } 4.22 + } 4.23 + printf("Saving Counter measurements to File: %s ...\n", filename); 4.24 + output = fopen(filename,"w+"); 4.25 + _VMSMasterEnv->counteroutput = output; 4.26 + 4.27 struct perf_event_attr hw_event; 4.28 memset(&hw_event,0,sizeof(hw_event)); 4.29 hw_event.type = PERF_TYPE_HARDWARE; 4.30 @@ -437,8 +455,8 @@ 4.31 * it lets the lang have lang-specific data related to creation transported 4.32 * to the plugin. 4.33 */ 4.34 -void 4.35 -VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ) __attribute__ ((noinline)) 4.36 +__attribute__ ((noinline)) void 4.37 +VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ) 4.38 4.39 { VMSReqst req; 4.40 4.41 @@ -472,8 +490,8 @@ 4.42 * gets suspended in this call and all the virt processor's state disap- 4.43 * pears -- making that suspend the last thing in the virt procr's trace. 4.44 */ 4.45 -void 4.46 -VMS__send_dissipate_req( VirtProcr *procrToDissipate ) __attribute__ ((noinline)) 4.47 +__attribute__ ((noinline)) void 4.48 +VMS__send_dissipate_req( VirtProcr *procrToDissipate ) 4.49 { VMSReqst req; 4.50 4.51 req.reqType = dissipate; 4.52 @@ -532,8 +550,8 @@ 4.53 * to plugin 4.54 *Then it does suspend, to cause request to be sent. 4.55 */ 4.56 -/*inline*/ void 4.57 -VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ) __attribute__ ((noinline)) 4.58 +/*inline*/__attribute__ ((noinline)) void 4.59 +VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ) 4.60 { VMSReqst req; 4.61 4.62 req.reqType = semantic; 4.63 @@ -545,8 +563,8 @@ 4.64 } 4.65 4.66 4.67 -/*inline*/ void 4.68 -VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ) __attribute__ ((noinline)) 4.69 +/*inline*/ __attribute__ ((noinline)) void 4.70 +VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ) 4.71 4.72 { VMSReqst req; 4.73
5.1 --- a/VMS.h Tue Aug 02 17:16:12 2011 +0200 5.2 +++ b/VMS.h Wed Aug 03 17:05:18 2011 +0200 5.3 @@ -33,7 +33,7 @@ 5.4 5.5 //turns on the probe-instrumentation in the application -- when not 5.6 // defined, the calls to the probe functions turn into comments 5.7 -#define STATS__ENABLE_PROBES 5.8 +//#define STATS__ENABLE_PROBES 5.9 //#define TURN_ON_DEBUG_PROBES 5.10 5.11 //These defines turn types of bug messages on and off 5.12 @@ -267,6 +267,7 @@ 5.13 #ifdef MEAS__PERF_COUNTERS 5.14 int cycles_counter_fd[NUM_CORES]; 5.15 int instrs_counter_fd[NUM_CORES]; 5.16 + FILE* counteroutput; 5.17 #endif 5.18 } 5.19 MasterEnv; 5.20 @@ -366,16 +367,16 @@ 5.21 inline void 5.22 VMS__add_sem_request_in_mallocd_VMSReqst( void *semReqData, VirtProcr *callingPr ); 5.23 5.24 -inline void 5.25 +/*inline*/ __attribute__ ((noinline)) void 5.26 VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ); 5.27 5.28 void 5.29 VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ); 5.30 5.31 -void inline 5.32 +void /*inline**/ __attribute__ ((noinline)) 5.33 VMS__send_dissipate_req( VirtProcr *prToDissipate ); 5.34 5.35 -inline void 5.36 +/*inline**/ __attribute__ ((noinline)) void 5.37 VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ); 5.38 5.39 VMSReqst * 5.40 @@ -433,6 +434,14 @@ 5.41 } \ 5.42 } while (0) 5.43 5.44 +#define getReturnAddressBeforeLibraryCall(vp_ptr, res_ptr) do{ \ 5.45 +void* frame_ptr0 = vp_ptr->framePtr; \ 5.46 +void* frame_ptr1 = *((void**)frame_ptr0); \ 5.47 +void* frame_ptr2 = *((void**)frame_ptr1); \ 5.48 +void* frame_ptr3 = *((void**)frame_ptr2); \ 5.49 +void* ret_addr = *((void**)frame_ptr3 + 1); \ 5.50 +*res_ptr = ret_addr; \ 5.51 +} while (0) 5.52 5.53 #define MEAS__SUB_CREATE /*turn on/off subtraction of create from plugin*/ 5.54
