Mercurial > cgi-bin > hgwebdir.cgi > VMS > VMS_Implementations > VMS_impls > VMS__MC_shared_impl
diff VMS.c @ 211:5b419522dc7f
time stamp checks added
| author | Nina Engelhardt <nengel@mailbox.tu-berlin.de> |
|---|---|
| date | Thu, 08 Mar 2012 19:02:16 +0100 |
| parents | f6d81915512c |
| children |
line diff
1.1 --- a/VMS.c Fri Feb 10 18:35:00 2012 +0100 1.2 +++ b/VMS.c Thu Mar 08 19:02:16 2012 +0100 1.3 @@ -193,31 +193,6 @@ 1.4 #endif 1.5 1.6 #ifdef MEAS__PERF_COUNTERS 1.7 -/* 1.8 - _VMSMasterEnv->counter_history = VMS__malloc(10*sizeof(void*)); 1.9 - _VMSMasterEnv->counter_history_array_info = makePrivDynArrayInfoFrom((void***)&(_VMSMasterEnv->counter_history),10); 1.10 -*/ 1.11 - //printf("Creating HW counters..."); 1.12 -/* 1.13 - FILE* output; 1.14 - int n; 1.15 - char filename[255]; 1.16 - for(n=0;n<255;n++) 1.17 - { 1.18 - sprintf(filename, "./counters/Counters.%d.csv",n); 1.19 - output = fopen(filename,"r"); 1.20 - if(output) 1.21 - { 1.22 - fclose(output); 1.23 - }else{ 1.24 - break; 1.25 - } 1.26 - } 1.27 - printf("Saving Counter measurements to File: %s ...\n", filename); 1.28 - output = fopen(filename,"w+"); 1.29 - _VMSMasterEnv->counteroutput = output; 1.30 -*/ 1.31 - 1.32 struct perf_event_attr hw_event; 1.33 memset(&hw_event,0,sizeof(hw_event)); 1.34 hw_event.type = PERF_TYPE_HARDWARE; 1.35 @@ -228,8 +203,8 @@ 1.36 hw_event.pinned = 1; /* must always be on PMU */ 1.37 hw_event.exclusive = 0; /* only group on PMU */ 1.38 hw_event.exclude_user = 0; /* don't count user */ 1.39 - hw_event.exclude_kernel = 1; /* ditto kernel */ 1.40 - hw_event.exclude_hv = 1; /* ditto hypervisor */ 1.41 + hw_event.exclude_kernel = 0; /* ditto kernel */ 1.42 + hw_event.exclude_hv = 0; /* ditto hypervisor */ 1.43 hw_event.exclude_idle = 0; /* don't count when idle */ 1.44 hw_event.mmap = 0; /* include mmap data */ 1.45 hw_event.comm = 0; /* include comm data */ 1.46 @@ -260,10 +235,9 @@ 1.47 perror("Failed to open instrs counter"); 1.48 } 1.49 } 1.50 - prctl(PR_TASK_PERF_EVENTS_ENABLE); 1.51 - uint64 tmpc,tmpi; 1.52 - saveCyclesAndInstrs(0,tmpc,tmpi); 1.53 - printf("Start: cycles = %llu, instrs = %llu\n",tmpc,tmpi); 1.54 + //uint64 tmpc,tmpi; 1.55 + //saveCyclesAndInstrs(0,tmpc,tmpi); 1.56 + //printf("Start: cycles = %llu, instrs = %llu\n",tmpc,tmpi); 1.57 #endif 1.58 1.59 //======================================================================== 1.60 @@ -314,8 +288,10 @@ 1.61 1.62 //Make the threads that animate the core loops 1.63 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ) 1.64 - { coreLoopThdParams[coreIdx] = VMS__malloc( sizeof(ThdParams) ); 1.65 + { coreLoopThdParams[coreIdx] = VMS__malloc( sizeof(ThdParams) + CACHE_LINE ); //make sure there is no false sharing 1.66 coreLoopThdParams[coreIdx]->coreNum = coreIdx; 1.67 + coreLoopThdParams[coreIdx]->sent_ctr = 0; 1.68 + coreLoopThdParams[coreIdx]->ret_tsc = 0; 1.69 1.70 retCode = 1.71 pthread_create( &(coreLoopThdHandles[coreIdx]), 1.72 @@ -324,6 +300,7 @@ 1.73 (void *)(coreLoopThdParams[coreIdx]) ); 1.74 if(retCode){printf("ERROR creating thread: %d\n", retCode); exit(1);} 1.75 } 1.76 + prctl(PR_TASK_PERF_EVENTS_ENABLE); 1.77 } 1.78 1.79 /*Semantic layer calls this when it want the system to start running.. 1.80 @@ -737,8 +714,7 @@ 1.81 #ifdef MEAS__PERF_COUNTERS 1.82 uint64 tmpc,tmpi; 1.83 saveCyclesAndInstrs(0,tmpc,tmpi); 1.84 - printf("End: cycles = %llu, instrs = %llu\n",tmpc,tmpi); 1.85 - prctl(PR_TASK_PERF_EVENTS_DISABLE); 1.86 + //printf("End: cycles = %llu, instrs = %llu\n",tmpc,tmpi); 1.87 /* 1.88 for( coreIdx=0; coreIdx < NUM_CORES; coreIdx++ ){ 1.89 close(_VMSMasterEnv->cycles_counter_fd[coreIdx]); 1.90 @@ -789,7 +765,7 @@ 1.91 //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, (DynArrayFnPtr)&saveHistToFile); 1.92 //forAllInDynArrayDo( _VMSMasterEnv->measHistsInfo, &freeHist ); 1.93 1.94 - 1.95 + prctl(PR_TASK_PERF_EVENTS_DISABLE); 1.96 #ifdef MEAS__TIME_PLUGIN 1.97 printHist( _VMSMasterEnv->reqHdlrLowTimeHist ); 1.98 saveHistToFile( _VMSMasterEnv->reqHdlrLowTimeHist ); 1.99 @@ -879,3 +855,74 @@ 1.100 exit(1); 1.101 } 1.102 1.103 + __inline__ uint64_t rdtsc(void){ 1.104 + uint32_t lo, hi; 1.105 + __asm__ __volatile__ ( // serialize 1.106 + "xorl %%eax,%%eax \n cpuid" 1.107 + ::: "%rax", "%rbx", "%rcx", "%rdx"); 1.108 + __asm__ __volatile__ ("rdtsc" : "=a" (lo), "=d" (hi)); 1.109 + /* asm volatile("RDTSC;" 1.110 + "movl %%eax, %0;" 1.111 + "movl %%edx, %1;" 1.112 + : "=m" (lo), "=m" (hi) 1.113 + : 1.114 + : "%eax", "%edx" 1.115 + ); */ 1.116 + return (uint64_t)hi << 32 | lo; 1.117 + } 1.118 + 1.119 + uint64 tsc_offset_send(ThdParams* thisCoresThdParams, uint64 initval){ 1.120 + uint64 ret_tsc_curr; //local copy of coreLoopThdParams->ret_tsc 1.121 + uint64 ret_tsc_prev; 1.122 + uint64 local_before; 1.123 + uint64 local_after; 1.124 + 1.125 + ret_tsc_prev = initval; 1.126 + ret_tsc_curr = initval; 1.127 + local_before = rdtsc(); 1.128 + thisCoresThdParams->sent_ctr++; 1.129 + while(ret_tsc_curr == ret_tsc_prev) 1.130 + ret_tsc_curr = thisCoresThdParams->ret_tsc; 1.131 + local_after = rdtsc(); 1.132 + ret_tsc_prev = ret_tsc_curr; 1.133 + 1.134 + int i; 1.135 + for(i=0;i<3;++i){ 1.136 + local_before = rdtsc(); 1.137 + thisCoresThdParams->sent_ctr++; 1.138 + while(ret_tsc_curr == ret_tsc_prev) 1.139 + ret_tsc_curr = thisCoresThdParams->ret_tsc; 1.140 + local_after = rdtsc(); 1.141 + int64 midpoint = local_before + (local_after-local_before)/2; 1.142 + int64 difference; 1.143 + if (midpoint > ret_tsc_curr) 1.144 + difference = midpoint - (int64)ret_tsc_curr; 1.145 + else 1.146 + difference = (int64)ret_tsc_curr - midpoint; 1.147 + //printf("TSC: %llu (Core %d) = %llu (Core %d) // difference=%llu\n",midpoint,thisCoresThdParams->coreNum,ret_tsc_curr,thisCoresThdParams->coreNum + 1,difference); 1.148 + ret_tsc_prev = ret_tsc_curr; 1.149 + } 1.150 + 1.151 + return ret_tsc_curr; 1.152 + } 1.153 + 1.154 + int tsc_offset_resp(ThdParams* sendCoresThdParams, int initialctrval){ 1.155 + 1.156 + int send_ctr_curr = initialctrval; 1.157 + int send_ctr_prev = initialctrval; 1.158 + 1.159 + 1.160 + while(send_ctr_curr == send_ctr_prev) 1.161 + send_ctr_curr = sendCoresThdParams->sent_ctr; 1.162 + sendCoresThdParams->ret_tsc = rdtsc(); 1.163 + send_ctr_prev = send_ctr_curr; 1.164 + 1.165 + int i; 1.166 + for(i=0;i<3;++i){ 1.167 + while(send_ctr_curr == send_ctr_prev) 1.168 + send_ctr_curr = sendCoresThdParams->sent_ctr; 1.169 + sendCoresThdParams->ret_tsc = rdtsc(); 1.170 + send_ctr_prev = send_ctr_curr; 1.171 + } 1.172 + return send_ctr_curr; 1.173 + } 1.174 \ No newline at end of file
