Skip to content
This repository has been archived by the owner on Jul 15, 2023. It is now read-only.

Commit

Permalink
Finished variable/function renaming for Benchmark, LatencyBenchmark, …
Browse files Browse the repository at this point in the history
…ThroughputBenchmark, DelayInjectedLoadedLatencyBenchmark classes.
  • Loading branch information
mgottscho committed Apr 5, 2016
1 parent de5dff8 commit babee8e
Show file tree
Hide file tree
Showing 10 changed files with 119 additions and 115 deletions.
2 changes: 1 addition & 1 deletion Doxyfile
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ PROJECT_NAME = X-Mem
# could be handy for archiving the generated documentation or if some version
# control system is used.

PROJECT_NUMBER = 2.4.0
PROJECT_NUMBER = 2.4.1

# Using the PROJECT_BRIEF tag one can provide an optional one line description
# for a project that appears at the top of each page and should give viewer a
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
README
------------------------------------------------------------------------------------------------------------

X-Mem: A Cross-Platform and Extensible Memory Characterization Tool for the Cloud v2.4.0
X-Mem: A Cross-Platform and Extensible Memory Characterization Tool for the Cloud v2.4.1
------------------------------------------------------------------------------------------------------------

X-Mem is a flexible open-source research tool for characterizing memory hierarchy throughput, latency, power, and more. The tool was developed jointly by Microsoft and the UCLA NanoCAD Lab. This project was started by Mark Gottscho (Email: [email protected]) as a Summer 2014 PhD intern at Microsoft Research. X-Mem is released freely and open-source under the MIT License. The project is under active development.

PROJECT REVISION DATE: April 4, 2016
PROJECT REVISION DATE: April 5, 2016

------------------------------------------------------------------------------------------------------------
RESEARCH PAPER & ATTRIBUTION
Expand Down
40 changes: 20 additions & 20 deletions src/Benchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,19 +75,19 @@ Benchmark::Benchmark(
metric_on_iter_(),
mean_metric_(0),
min_metric_(0),
25_percentile_metric_(0),
percentile_25_metric_(0),
median_metric_(0),
75_percentile_metric_(0),
95_percentile_metric_(0),
99_percentile_metric_(0),
percentile_75_metric_(0),
percentile_95_metric_(0),
percentile_99_metric_(0),
max_metric_(0),
mode_metric_(0),
metric_units_(metric_units),
mean_dram_power_socket_(),
peak_dram_power_socket_(),
name_(name),
obj_valid_(false),
hasRun_(false),
has_run_(false),
warning_(false)
{

Expand All @@ -107,7 +107,7 @@ bool Benchmark::run() {

//Write to all of the memory region of interest to make sure
//pages are resident in physical memory and are not shared
forwSequentialWrite_Word32(_mem_array,
forwSequentialWrite_Word32(mem_array_,
reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(mem_array_) + len_));

bool success = runCore();
Expand Down Expand Up @@ -191,7 +191,7 @@ void Benchmark::reportBenchmarkInfo() const {
std::cout << "read";
break;
case WRITE:
if (_pattern_mode == RANDOM) //special case
if (pattern_mode_ == RANDOM) //special case
std::cout << "read+write";
else
std::cout << "write";
Expand All @@ -215,7 +215,7 @@ void Benchmark::reportResults() const {
std::cout << "***" << std::endl;
std::cout << std::endl;

if (hasRun_) {
if (has_run_) {
for (uint32_t i = 0; i < iterations_; i++) {
std::printf("Iter #%4d: %0.3f %s", i, metric_on_iter_[i], metric_units_.c_str());
//std::cout << "Iter #" << i << ": " << metric_on_iter_[i] << " " << metric_units_;
Expand All @@ -237,7 +237,7 @@ void Benchmark::reportResults() const {
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "25th Percentile: " << 25_percentile_metric_ << " " << metric_units_;
std::cout << "25th Percentile: " << percentile_25_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;
Expand All @@ -247,17 +247,17 @@ void Benchmark::reportResults() const {
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "75th Percentile: " << 75_percentile_metric_ << " " << metric_units_;
std::cout << "75th Percentile: " << percentile_75_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "95th Percentile: " << 95_percentile_metric_ << " " << metric_units_;
std::cout << "95th Percentile: " << percentile_95_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "99th Percentile: " << 99_percentile_metric_ << " " << metric_units_;
std::cout << "99th Percentile: " << percentile_99_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;
Expand Down Expand Up @@ -314,7 +314,7 @@ double Benchmark::getMinMetric() const {

double Benchmark::get25PercentileMetric() const {
if (has_run_)
return 25_percentile_metric_;
return percentile_25_metric_;
else //bad call
return -1;
}
Expand All @@ -328,21 +328,21 @@ double Benchmark::getMedianMetric() const {

double Benchmark::get75PercentileMetric() const {
if (has_run_)
return 75_percentile_metric_;
return percentile_75_metric_;
else //bad call
return -1;
}

double Benchmark::get95PercentileMetric() const {
if (has_run_)
return 95_percentile_metric_;
return percentile_95_metric_;
else //bad call
return -1;
}

double Benchmark::get99PercentileMetric() const {
if (has_run_)
return 99_percentile_metric_;
return percentile_99_metric_;
else //bad call
return -1;
}
Expand Down Expand Up @@ -433,11 +433,11 @@ void Benchmark::computeMetrics() {

//Compute percentiles
min_metric_ = sortedMetrics.front();
25_percentile_metric_ = sortedMetrics[sortedMetrics.size()/4];
75_percentile_metric_ = sortedMetrics[sortedMetrics.size()*3/4];
percentile_25_metric_ = sortedMetrics[sortedMetrics.size()/4];
percentile_75_metric_ = sortedMetrics[sortedMetrics.size()*3/4];
median_metric_ = sortedMetrics[sortedMetrics.size()/2];
95_percentile_metric_ = sortedMetrics[sortedMetrics.size()*95/100];
99_percentile_metric_ = sortedMetrics[sortedMetrics.size()*99/100];
percentile_95_metric_ = sortedMetrics[sortedMetrics.size()*95/100];
percentile_99_metric_ = sortedMetrics[sortedMetrics.size()*99/100];
max_metric_ = sortedMetrics.back();

//Compute mode
Expand Down
6 changes: 3 additions & 3 deletions src/BenchmarkManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -192,7 +192,7 @@ bool BenchmarkManager::runThroughputBenchmarks() {

for (uint32_t i = 0; i < __tp_benchmarks.size(); i++) {
__tp_benchmarks[i]->run();
__tp_benchmarks[i]->report_results(); //to console
__tp_benchmarks[i]->reportResults(); //to console

//Write to results file if necessary
if (__config.useOutputFile()) {
Expand Down Expand Up @@ -306,7 +306,7 @@ bool BenchmarkManager::runLatencyBenchmarks() {

for (uint32_t i = 0; i < __lat_benchmarks.size(); i++) {
__lat_benchmarks[i]->run();
__lat_benchmarks[i]->report_results(); //to console
__lat_benchmarks[i]->reportResults(); //to console

//Write to results file if necessary
if (__config.useOutputFile()) {
Expand Down Expand Up @@ -775,7 +775,7 @@ bool BenchmarkManager::runExtDelayInjectedLoadedLatencyBenchmark() {
//Run benchmarks
for (uint32_t i = 0; i < del_lat_benchmarks.size(); i++) {
del_lat_benchmarks[i]->run();
del_lat_benchmarks[i]->report_results(); //to console
del_lat_benchmarks[i]->reportResults(); //to console

//Write to results file if necessary
if (__config.useOutputFile()) {
Expand Down
22 changes: 11 additions & 11 deletions src/LatencyBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ LatencyBenchmark::LatencyBenchmark(
load_metric_on_iter_.push_back(0);
}

void LatencyBenchmark::report_benchmark_info() const {
void LatencyBenchmark::reportBenchmarkInfo() const {
std::cout << "CPU NUMA Node: " << cpu_node_ << std::endl;
std::cout << "Memory NUMA Node: " << mem_node_ << std::endl;
std::cout << "Latency measurement chunk size: ";
Expand Down Expand Up @@ -168,7 +168,7 @@ void LatencyBenchmark::report_benchmark_info() const {
}


void LatencyBenchmark::report_results() const {
void LatencyBenchmark::reportResults() const {
std::cout << std::endl;
std::cout << "*** RESULTS";
std::cout << "***" << std::endl;
Expand Down Expand Up @@ -196,7 +196,7 @@ void LatencyBenchmark::report_results() const {
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "25th Percentile: " << 25_percentile_metric_ << " " << metric_units_;
std::cout << "25th Percentile: " << percentile_25_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;
Expand All @@ -206,17 +206,17 @@ void LatencyBenchmark::report_results() const {
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "75th Percentile: " << 75_percentile_metric_ << " " << metric_units_;
std::cout << "75th Percentile: " << percentile_75_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "95th Percentile: " << 95_percentile_metric_ << " " << metric_units_;
std::cout << "95th Percentile: " << percentile_95_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;

std::cout << "99th Percentile: " << 99_percentile_metric_ << " " << metric_units_;
std::cout << "99th Percentile: " << percentile_99_metric_ << " " << metric_units_;
if (warning_)
std::cout << " (WARNING)";
std::cout << std::endl;
Expand Down Expand Up @@ -260,8 +260,8 @@ double LatencyBenchmark::getMeanLoadMetric() const {
return -1;
}

bool LatencyBenchmark::_run_core() {
size_t len_per_thread = len_ / _num_worker_threads; //Carve up memory space so each worker has its own area to play in
bool LatencyBenchmark::runCore() {
size_t len_per_thread = len_ / num_worker_threads_; //Carve up memory space so each worker has its own area to play in

//Set up latency measurement kernel function pointers
RandomFunction lat_kernel_fptr = &chasePointers;
Expand Down Expand Up @@ -295,7 +295,7 @@ bool LatencyBenchmark::_run_core() {
std::cerr << "ERROR: Failed to find appropriate benchmark kernel." << std::endl;
return false;
}
} else if (_pattern_mode == RANDOM) {
} else if (pattern_mode_ == RANDOM) {
if (!determineRandomKernel(rw_mode_, chunk_size_, &load_kernel_fptr_ran, &load_kernel_dummy_fptr_ran)) {
std::cerr << "ERROR: Failed to find appropriate benchmark kernel." << std::endl;
return false;
Expand Down Expand Up @@ -395,7 +395,7 @@ bool LatencyBenchmark::_run_core() {
tick_t load_total_elapsed_dummy_ticks = 0;
uint32_t load_bytes_per_pass = 0;
double load_avg_adjusted_ticks = 0;
for (uint32_t t = 1; t < _num_worker_threads; t++) {
for (uint32_t t = 1; t < num_worker_threads_; t++) {
load_total_passes += workers[t]->getPasses();
load_total_adjusted_ticks += workers[t]->getAdjustedTicks();
load_total_elapsed_dummy_ticks += workers[t]->getElapsedDummyTicks();
Expand All @@ -405,7 +405,7 @@ bool LatencyBenchmark::_run_core() {

//Compute load metrics for this iteration
load_avg_adjusted_ticks = static_cast<double>(load_total_adjusted_ticks) / (num_worker_threads_-1);
if (_num_worker_threads > 1)
if (num_worker_threads_ > 1)
load_metric_on_iter_[i] = (((static_cast<double>(load_total_passes) * static_cast<double>(load_bytes_per_pass)) / static_cast<double>(MB))) / ((load_avg_adjusted_ticks * g_ns_per_tick) / 1e9);

if (iterwarning)
Expand Down
20 changes: 10 additions & 10 deletions src/ThroughputBenchmark.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,8 @@ bool ThroughputBenchmark::runCore() {

//Build pointer indices. Note that the pointers for each thread must stay within its respective region, otherwise sharing may occur.
for (uint32_t i = 0; i < num_worker_threads_; i++) {
if (!buildRandomPointerPermutation(reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(_mem_array) + i*len_per_thread), //casts to silence compiler warnings
reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(_mem_array) + (i+1)*len_per_thread), //casts to silence compiler warnings
if (!buildRandomPointerPermutation(reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(mem_array_) + i*len_per_thread), //casts to silence compiler warnings
reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(mem_array_) + (i+1)*len_per_thread), //casts to silence compiler warnings
chunk_size_)) {
std::cerr << "ERROR: Failed to build a random pointer permutation for a worker thread!" << std::endl;
return false;
Expand All @@ -115,7 +115,7 @@ bool ThroughputBenchmark::runCore() {
//Start power measurement
if (g_verbose)
std::cout << "Starting power measurement threads...";
if (!_start_power_threads()) {
if (!startPowerThreads()) {
if (g_verbose)
std::cout << "FAIL" << std::endl;
std::cerr << "WARNING: Failed to start power measurement threads." << std::endl;
Expand All @@ -127,21 +127,21 @@ bool ThroughputBenchmark::runCore() {
std::cout << "Running benchmark." << std::endl << std::endl;

//Do a bunch of iterations of the core benchmark routines
for (uint32_t i = 0; i < _iterations; i++) {
for (uint32_t i = 0; i < iterations_; i++) {
//Create workers and worker threads
for (uint32_t t = 0; t < num_worker_threads_; t++) {
void* thread_mem_array = reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(_mem_array) + t * len_per_thread);
int32_t cpu_id = cpu_id_in_numa_node(_cpu_node, t);
void* threadmem_array_ = reinterpret_cast<void*>(reinterpret_cast<uint8_t*>(mem_array_) + t * len_per_thread);
int32_t cpu_id = cpu_id_in_numa_node(cpu_node_, t);
if (cpu_id < 0)
std::cerr << "WARNING: Failed to find logical CPU " << t << " in NUMA node " << _cpu_node << std::endl;
std::cerr << "WARNING: Failed to find logical CPU " << t << " in NUMA node " << cpu_node_ << std::endl;
if (pattern_mode_ == SEQUENTIAL)
workers.push_back(new LoadWorker(thread_mem_array,
workers.push_back(new LoadWorker(threadmem_array_,
len_per_thread,
kernel_fptr_seq,
kernel_dummy_fptr_seq,
cpu_id));
else if (pattern_mode_ == RANDOM)
workers.push_back(new LoadWorker(thread_mem_array,
workers.push_back(new LoadWorker(threadmem_array_,
len_per_thread,
kernel_fptr_ran,
kernel_dummy_fptr_ran,
Expand Down Expand Up @@ -177,7 +177,7 @@ bool ThroughputBenchmark::runCore() {
avg_adjusted_ticks = total_adjusted_ticks / num_worker_threads_;

if (iter_warning)
_warning = true;
warning_ = true;

if (g_verbose ) { //Report duration for this iteration
std::cout << "Iter " << i+1 << " had " << total_passes << " passes in total across " << num_worker_threads_ << " threads, with " << bytes_per_pass << " bytes touched per pass:";
Expand Down
Loading

0 comments on commit babee8e

Please sign in to comment.