Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff VMS.c @ 108:3bc3b89630c7
perf counters
| author | engelhardt@cray1 |
|---|---|
| date | Tue, 26 Jul 2011 15:36:24 +0200 |
| parents | 97e26095c01f |
| children | 659299627e70 |
line diff
1.1 --- a/VMS.c Tue Jul 26 15:35:57 2011 +0200 1.2 +++ b/VMS.c Tue Jul 26 15:36:24 2011 +0200 1.3 @@ -16,6 +16,9 @@ 1.4 #include "Queue_impl/BlockingQueue.h" 1.5 #include "Histogram/Histogram.h" 1.6 1.7 +#include <linux/perf_event.h> 1.8 +#include <syscall.h> 1.9 +#include <sys/prctl.h> 1.10 1.11 #define thdAttrs NULL 1.12 1.13 @@ -177,6 +180,43 @@ 1.14 #endif 1.15 1.16 MakeTheMeasHists(); 1.17 + 1.18 + #ifdef MEAS__PERF_COUNTER 1.19 + printf("Creating HW counters..."); 1.20 + struct perf_event_attr hw_event; 1.21 + hw_event.type = PERF_TYPE_HARDWARE; 1.22 + hw_event.size = sizeof(struct perf_event_attr); 1.23 + hw_event.disabled = 1; 1.24 + hw_event.inherit = 1; /* children inherit it */ 1.25 + hw_event.pinned = 1; /* must always be on PMU */ 1.26 + hw_event.exclusive = 0; /* only group on PMU */ 1.27 + hw_event.exclude_user = 0; /* don't count user */ 1.28 + hw_event.exclude_kernel = 1; /* ditto kernel */ 1.29 + hw_event.exclude_hv = 1; /* ditto hypervisor */ 1.30 + hw_event.exclude_idle = 0; /* don't count when idle */ 1.31 + hw_event.mmap = 0; /* include mmap data */ 1.32 + hw_event.comm = 0; /* include comm data */ 1.33 + 1.34 + for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 1.35 + { 1.36 + hw_event.config = PERF_COUNT_HW_CPU_CYCLES; //cycles 1.37 + _VMSMasterEnv->cycles_counter_fd[coreIdx] = syscall(__NR_perf_event_open, &hw_event, 1.38 + 0,//pid_t pid, 1.39 + coreIdx,//int cpu, 1.40 + -1,//int group_fd, 1.41 + 0//unsigned long flags 1.42 + ); 1.43 + hw_event.config = PERF_COUNT_HW_INSTRUCTIONS; //instrs 1.44 + _VMSMasterEnv->instrs_counter_fd[coreIdx] = syscall(__NR_perf_event_open, &hw_event, 1.45 + 0,//pid_t pid, 1.46 + coreIdx,//int cpu, 1.47 + -1,//int group_fd, 1.48 + 0//unsigned long flags 1.49 + ); 1.50 + } 1.51 + prctl(PR_TASK_PERF_EVENTS_ENABLE); 1.52 + #endif 1.53 + 1.54 //======================================================================== 1.55 1.56 }
