diff --git a/app/benchmark_fft/main.cpp b/app/benchmark_fft/main.cpp index 3ba38ea..a78a0ce 100644 --- a/app/benchmark_fft/main.cpp +++ b/app/benchmark_fft/main.cpp @@ -38,6 +38,7 @@ int main(int argc, char **argv) { string test_name = to_string(num_threads) + ".csv"; string full_directory = directory + "/PLS_v3/"; benchmark_runner runner{full_directory, test_name}; + runner.enable_memory_stats(); fft::complex_vector data(fft::SIZE); fft::complex_vector swap_array(fft::SIZE); diff --git a/app/benchmark_fib/main.cpp b/app/benchmark_fib/main.cpp index a76b1a0..3df5218 100644 --- a/app/benchmark_fib/main.cpp +++ b/app/benchmark_fib/main.cpp @@ -36,6 +36,7 @@ int main(int argc, char **argv) { string test_name = to_string(num_threads) + ".csv"; string full_directory = directory + "/PLS_v3/"; benchmark_runner runner{full_directory, test_name}; + runner.enable_memory_stats(); pls::scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE}; diff --git a/app/benchmark_matrix/main.cpp b/app/benchmark_matrix/main.cpp index 903f7b2..4ce92a8 100644 --- a/app/benchmark_matrix/main.cpp +++ b/app/benchmark_matrix/main.cpp @@ -31,6 +31,7 @@ int main(int argc, char **argv) { string test_name = to_string(num_threads) + ".csv"; string full_directory = directory + "/PLS_v3/"; benchmark_runner runner{full_directory, test_name}; + runner.enable_memory_stats(); pls_matrix a; pls_matrix b; diff --git a/app/benchmark_matrix_div_conquer/main.cpp b/app/benchmark_matrix_div_conquer/main.cpp index 9ba2cc7..8532657 100644 --- a/app/benchmark_matrix_div_conquer/main.cpp +++ b/app/benchmark_matrix_div_conquer/main.cpp @@ -112,6 +112,7 @@ int main(int argc, char **argv) { string test_name = to_string(num_threads) + ".csv"; string full_directory = directory + "/PLS_v3/"; benchmark_runner runner{full_directory, test_name}; + runner.enable_memory_stats(); // Only run on one version to avoid copy std::unique_ptr result_data{new double[size * size]}; diff --git a/app/benchmark_unbalanced/main.cpp b/app/benchmark_unbalanced/main.cpp index 1b81da7..7e151f9 100644 --- a/app/benchmark_unbalanced/main.cpp +++ b/app/benchmark_unbalanced/main.cpp @@ -42,6 +42,7 @@ int main(int argc, char **argv) { string test_name = to_string(num_threads) + ".csv"; string full_directory = directory + "/PLS_v3/"; benchmark_runner runner{full_directory, test_name}; + runner.enable_memory_stats(); scheduler scheduler{(unsigned) num_threads, MAX_NUM_TASKS, MAX_STACK_SIZE}; diff --git a/extern/benchmark_runner/benchmark_runner.h b/extern/benchmark_runner/benchmark_runner.h index 2a399b3..fc61b6a 100644 --- a/extern/benchmark_runner/benchmark_runner.h +++ b/extern/benchmark_runner/benchmark_runner.h @@ -29,6 +29,12 @@ class benchmark_runner { chrono::steady_clock::time_point last_start_time_; vector times_; + bool memory_stats_enabled_{false}; + const string MEMORY_PRE_RUN = "memory_pages_pre_run"; + const string MEMORY_POST_RUN = "memory_pages_post_run"; + unsigned long memory_pre_run_; + unsigned long memory_post_run_; + map> custom_stats_; void print_statistics() { @@ -96,6 +102,12 @@ class benchmark_runner { custom_stats_.insert({name, {}}); } + void enable_memory_stats() { + memory_stats_enabled_ = true; + add_custom_stats_field(MEMORY_PRE_RUN); + add_custom_stats_field(MEMORY_POST_RUN); + } + static void read_args(int argc, char **argv, int &num_threads, string &path) { if (argc < 3) { cout << "Must Specifiy concurrency and output directory! (usage: `benchmark `)" @@ -109,17 +121,31 @@ class benchmark_runner { } void start_iteration() { + if (memory_stats_enabled_) { + auto memory_stats = query_process_memory_pages(); + memory_pre_run_ = memory_stats.first; + } + last_start_time_ = chrono::steady_clock::now(); } void end_iteration() { + size_t iteration_index = times_.size(); + auto end_time = chrono::steady_clock::now(); long time = chrono::duration_cast(end_time - last_start_time_).count(); - times_.emplace_back(time); + times_.emplace_back(time); for (auto &iter : custom_stats_) { iter.second.emplace_back(0); } + if (memory_stats_enabled_) { + auto memory_stats = query_process_memory_pages(); + memory_post_run_ = memory_stats.first; + + custom_stats_[MEMORY_PRE_RUN][iteration_index] = memory_pre_run_; + custom_stats_[MEMORY_POST_RUN][iteration_index] = memory_post_run_; + } } void store_custom_stat(const string &name, long value) {