Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff VMS.c @ 109:659299627e70
counters done
| author | Nina Engelhardt |
|---|---|
| date | Tue, 02 Aug 2011 17:16:12 +0200 |
| parents | 3bc3b89630c7 |
| children | 724c7a0b687f |
line diff
1.1 --- a/VMS.c Tue Jul 26 15:36:24 2011 +0200 1.2 +++ b/VMS.c Tue Aug 02 17:16:12 2011 +0200 1.3 @@ -16,9 +16,14 @@ 1.4 #include "Queue_impl/BlockingQueue.h" 1.5 #include "Histogram/Histogram.h" 1.6 1.7 +#include <unistd.h> 1.8 +#include <fcntl.h> 1.9 +#include <linux/types.h> 1.10 #include <linux/perf_event.h> 1.11 -#include <syscall.h> 1.12 -#include <sys/prctl.h> 1.13 +#include <errno.h> 1.14 +#include <sys/syscall.h> 1.15 +#include <linux/prctl.h> 1.16 + 1.17 1.18 #define thdAttrs NULL 1.19 1.20 @@ -181,12 +186,14 @@ 1.21 1.22 MakeTheMeasHists(); 1.23 1.24 - #ifdef MEAS__PERF_COUNTER 1.25 + #ifdef MEAS__PERF_COUNTERS 1.26 printf("Creating HW counters..."); 1.27 struct perf_event_attr hw_event; 1.28 + memset(&hw_event,0,sizeof(hw_event)); 1.29 hw_event.type = PERF_TYPE_HARDWARE; 1.30 - hw_event.size = sizeof(struct perf_event_attr); 1.31 + hw_event.size = sizeof(hw_event); 1.32 hw_event.disabled = 1; 1.33 + hw_event.freq = 0; 1.34 hw_event.inherit = 1; /* children inherit it */ 1.35 hw_event.pinned = 1; /* must always be on PMU */ 1.36 hw_event.exclusive = 0; /* only group on PMU */ 1.37 @@ -197,24 +204,36 @@ 1.38 hw_event.mmap = 0; /* include mmap data */ 1.39 hw_event.comm = 0; /* include comm data */ 1.40 1.41 + 1.42 for( coreIdx = 0; coreIdx < NUM_CORES; coreIdx++ ) 1.43 { 1.44 - hw_event.config = PERF_COUNT_HW_CPU_CYCLES; //cycles 1.45 + hw_event.config = 0x0000000000000000; //cycles 1.46 _VMSMasterEnv->cycles_counter_fd[coreIdx] = syscall(__NR_perf_event_open, &hw_event, 1.47 0,//pid_t pid, 1.48 - coreIdx,//int cpu, 1.49 + -1,//int cpu, 1.50 -1,//int group_fd, 1.51 0//unsigned long flags 1.52 ); 1.53 - hw_event.config = PERF_COUNT_HW_INSTRUCTIONS; //instrs 1.54 + if (_VMSMasterEnv->cycles_counter_fd[coreIdx]<0){ 1.55 + fprintf(stderr,"On core %d: ",coreIdx); 1.56 + perror("Failed to open cycles counter"); 1.57 + } 1.58 + hw_event.config = 0x0000000000000001; //instrs 1.59 _VMSMasterEnv->instrs_counter_fd[coreIdx] = syscall(__NR_perf_event_open, &hw_event, 1.60 0,//pid_t pid, 1.61 - coreIdx,//int cpu, 1.62 + -1,//int cpu, 1.63 -1,//int group_fd, 1.64 0//unsigned long flags 1.65 ); 1.66 + if (_VMSMasterEnv->instrs_counter_fd[coreIdx]<0){ 1.67 + fprintf(stderr,"On core %d: ",coreIdx); 1.68 + perror("Failed to open instrs counter"); 1.69 + } 1.70 } 1.71 prctl(PR_TASK_PERF_EVENTS_ENABLE); 1.72 + uint64 tmpc,tmpi; 1.73 + saveCyclesAndInstrs(0,tmpc,tmpi); 1.74 + printf("Start: cycles = %lu, instrs = %lu\n",tmpc,tmpi); 1.75 #endif 1.76 1.77 //======================================================================== 1.78 @@ -419,7 +438,8 @@ 1.79 * to the plugin. 1.80 */ 1.81 void 1.82 -VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ) 1.83 +VMS__send_create_procr_req( void *semReqData, VirtProcr *reqstingPr ) __attribute__ ((noinline)) 1.84 + 1.85 { VMSReqst req; 1.86 1.87 req.reqType = createReq; 1.88 @@ -453,7 +473,7 @@ 1.89 * pears -- making that suspend the last thing in the virt procr's trace. 1.90 */ 1.91 void 1.92 -VMS__send_dissipate_req( VirtProcr *procrToDissipate ) 1.93 +VMS__send_dissipate_req( VirtProcr *procrToDissipate ) __attribute__ ((noinline)) 1.94 { VMSReqst req; 1.95 1.96 req.reqType = dissipate; 1.97 @@ -512,8 +532,8 @@ 1.98 * to plugin 1.99 *Then it does suspend, to cause request to be sent. 1.100 */ 1.101 -inline void 1.102 -VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ) 1.103 +/*inline*/ void 1.104 +VMS__send_sem_request( void *semReqData, VirtProcr *callingPr ) __attribute__ ((noinline)) 1.105 { VMSReqst req; 1.106 1.107 req.reqType = semantic; 1.108 @@ -525,8 +545,9 @@ 1.109 } 1.110 1.111 1.112 -inline void 1.113 -VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ) 1.114 +/*inline*/ void 1.115 +VMS__send_VMSSem_request( void *semReqData, VirtProcr *callingPr ) __attribute__ ((noinline)) 1.116 + 1.117 { VMSReqst req; 1.118 1.119 req.reqType = VMSSemantic; 1.120 @@ -678,7 +699,18 @@ 1.121 shutDownPr = VMS__create_procr( &endOSThreadFn, NULL ); 1.122 writeVMSQ( shutDownPr, _VMSMasterEnv->readyToAnimateQs[coreIdx] ); 1.123 } 1.124 - 1.125 +#ifdef MEAS__PERF_COUNTERS 1.126 + uint64 tmpc,tmpi; 1.127 + saveCyclesAndInstrs(0,tmpc,tmpi); 1.128 + printf("End: cycles = %lu, instrs = %lu\n",tmpc,tmpi); 1.129 + prctl(PR_TASK_PERF_EVENTS_DISABLE); 1.130 +/* 1.131 + for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ){ 1.132 + close(_VMSMasterEnv->cycles_counter_fd[coreIdx]); 1.133 + close(_VMSMasterEnv->instrs_counter_fd[coreIdx]); 1.134 + } 1.135 +*/ 1.136 +#endif 1.137 } 1.138 1.139 1.140 @@ -718,8 +750,8 @@ 1.141 //SchedSlot ***allSchedSlots; //ptr to array of ptrs 1.142 1.143 //Before getting rid of everything, print out any measurements made 1.144 - forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist ); 1.145 - forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile); 1.146 + //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&printHist ); 1.147 + //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile); 1.148 //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHistExt ); 1.149 #ifdef MEAS__TIME_PLUGIN 1.150 printHist( _VMSMasterEnv->reqHdlrLowTimeHist );
