src/worker.cc
// Worked thread to test the cache coherency of the CPUs
// Return false on fatal sw error.
Worked thread to test the cache coherency of the CPUs
Return false on fatal sw error.
Worked thread to test the cache coherency of the CPUs Return false on fatal sw error .
bool CpuCacheCoherencyThread::Work() {
  logprintf(9, "Log: Starting the Cache Coherency thread %d\n",
            cc_thread_num_);
  uint64 time_start, time_end;
  struct timeval tv;
  unsigned int seed = static_cast<unsigned int>(gettid());
  gettimeofday(&tv, NULL);  
  time_start = tv.tv_sec * 1000000ULL + tv.tv_usec;
  uint64 total_inc = 0;  
  while (IsReadyToRun()) {
    for (int i = 0; i < cc_inc_count_; i++) {
#ifdef HAVE_RAND_R
      int r = rand_r(&seed);
#else
      int r = rand();
#endif
      r = cc_cacheline_count_ * (r / (RAND_MAX + 1.0));
      (cc_cacheline_data_[r].num[cc_thread_num_])++;
    }
    total_inc += cc_inc_count_;
    int cc_global_num = 0;
    for (int cline_num = 0; cline_num < cc_cacheline_count_; cline_num++) {
      cc_global_num += cc_cacheline_data_[cline_num].num[cc_thread_num_];
      cc_cacheline_data_[cline_num].num[cc_thread_num_] = 0;
    }
    if (sat_->error_injection())
      cc_global_num = -1;
    if (cc_global_num != cc_inc_count_) {
      errorcount_++;
      logprintf(0, "Hardware Error: global(%d) and local(%d) do not match\n",
                cc_global_num, cc_inc_count_);
    }
  }
  gettimeofday(&tv, NULL);  
  time_end = tv.tv_sec * 1000000ULL + tv.tv_usec;
  uint64 us_elapsed = time_end - time_start;
  double inc_rate = total_inc * 1e6 / us_elapsed;
  logprintf(4, "Stats: CC Thread(%d): Time=%llu us,"
            " Increments=%llu, Increments/sec = %.6lf\n",
            cc_thread_num_, us_elapsed, total_inc, inc_rate);
  logprintf(9, "Log: Finished CPU Cache Coherency thread %d:\n",
            cc_thread_num_);
  status_ = true;
  return true;
}
bool CpuCacheCoherencyThread :: Work ( ) { logprintf ( 9 , " \n " , cc_thread_num_ ) ; uint64 time_start , time_end ; struct timeval tv ; unsigned int seed = static_cast < unsigned int > ( gettid ( ) ) ; gettimeofday ( & tv , NULL ) ; time_start = tv . tv_sec * 1000000ULL + tv . tv_usec ; uint64 total_inc = 0 ; while ( IsReadyToRun ( ) ) { for ( int i = 0 ; i < cc_inc_count_ ; i ++ ) { #ifdef HAVE_RAND_R int r = rand_r ( & seed ) ; #else int r = rand ( ) ; #endif r = cc_cacheline_count_ * ( r / ( RAND_MAX + 1.0 ) ) ; ( cc_cacheline_data_ [ r ] . num [ cc_thread_num_ ] ) ++ ; } total_inc += cc_inc_count_ ; int cc_global_num = 0 ; for ( int cline_num = 0 ; cline_num < cc_cacheline_count_ ; cline_num ++ ) { cc_global_num += cc_cacheline_data_ [ cline_num ] . num [ cc_thread_num_ ] ; cc_cacheline_data_ [ cline_num ] . num [ cc_thread_num_ ] = 0 ; } if ( sat_ -> error_injection ( ) ) cc_global_num = -1 ; if ( cc_global_num != cc_inc_count_ ) { errorcount_ ++ ; logprintf ( 0 , " \n " , cc_global_num , cc_inc_count_ ) ; } } gettimeofday ( & tv , NULL ) ; time_end = tv . tv_sec * 1000000ULL + tv . tv_usec ; uint64 us_elapsed = time_end - time_start ; double inc_rate = total_inc * 1e6 / us_elapsed ; logprintf ( 4 , " " " \n " , cc_thread_num_ , us_elapsed , total_inc , inc_rate ) ; logprintf ( 9 , " \n " , cc_thread_num_ ) ; status_ = true ; return true ; }
Worked thread to test the cache coherency of the CPUs
Return false on fatal sw error.
Worked thread to test the cache coherency of the CPUs Return false on fatal sw error .
// Get the timestamp before increments. // Total increments done by the thread. // Choose a datastructure in random and increment the appropriate // member in that according to the offset (which is the same as the // thread number. // Increment the member of the randomely selected structure. // Calculate if the local counter matches with the global value // in all the cache line structures for this particular thread. // Reset the cachline member's value for the next run. // Get the timestamp at the end. // inc_rate is the no. of increments per second.