From 58eec4f39108a4fc9e328a79cef4128ab38a67e2 Mon Sep 17 00:00:00 2001 From: Tobias Fuchs Date: Mon, 13 Apr 2015 13:57:41 +0200 Subject: [PATCH] performance test: improved macros for test setup, fixes for gcc --- algorithms_cpp/perf/for_each_perf-inl.h | 16 ++++++++-------- base_cpp/perf/include/embb/base/perf/perf.h | 13 ++++++------- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/algorithms_cpp/perf/for_each_perf-inl.h b/algorithms_cpp/perf/for_each_perf-inl.h index 614d0b1..8a16758 100644 --- a/algorithms_cpp/perf/for_each_perf-inl.h +++ b/algorithms_cpp/perf/for_each_perf-inl.h @@ -41,7 +41,7 @@ namespace perf { template SerialForEach::SerialForEach(const embb::base::perf::CallArgs & args) : cargs(args), op(args), vector_size(args.VectorSize()) { - if (cargs.StressMode() == CallArgs::RAM_STRESS) { + if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) { v = static_cast(embb::base::Allocation::AllocateCacheAligned( vector_size * sizeof(T))); for (size_t i = 0; i < vector_size; i++) { @@ -54,19 +54,19 @@ SerialForEach::SerialForEach(const embb::base::perf::CallArgs & args) template SerialForEach::~SerialForEach() { - if (cargs.StressMode() == CallArgs::RAM_STRESS) { + if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) { embb::base::Allocation::FreeAligned(v); } } template void SerialForEach::Run() { - if (cargs.StressMode() == CallArgs::CPU_STRESS) { + if (cargs.StressMode() == embb::base::perf::CallArgs::CPU_STRESS) { for (size_t i = 0; i < vector_size; i++) { T v = static_cast(i); op(v); } - } else if (cargs.StressMode() == CallArgs::RAM_STRESS) { + } else if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) { for (size_t i = 0; i < vector_size; i++) { op(v[i]); } @@ -76,7 +76,7 @@ void SerialForEach::Run() { template ParallelForEach::ParallelForEach(const embb::base::perf::CallArgs & args) : cargs(args), vector_size(args.VectorSize()) { - if (cargs.StressMode() == CallArgs::RAM_STRESS) { + if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) { v = static_cast(embb::base::Allocation::AllocateCacheAligned( vector_size * sizeof(T))); } else { @@ -93,7 +93,7 @@ ParallelForEach::~ParallelForEach() { template void ParallelForEach::Pre() { - if (cargs.StressMode() == CallArgs::RAM_STRESS) { + if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) { // Initialize input vector with incrementing values: for (size_t i = 0; i < vector_size; i++) { v[i] = static_cast(i); @@ -103,7 +103,7 @@ void ParallelForEach::Pre() { template void ParallelForEach::Run(unsigned int numThreads) { - if (cargs.StressMode() == CallArgs::CPU_STRESS) { + if (cargs.StressMode() == embb::base::perf::CallArgs::CPU_STRESS) { // Computing input values, no memory access ForEachFunctor op(cargs); embb::algorithms::ForEach( @@ -114,7 +114,7 @@ void ParallelForEach::Run(unsigned int numThreads) { op, embb::tasks::ExecutionPolicy(), vector_size / numThreads); - } else if (cargs.StressMode() == CallArgs::RAM_STRESS) { + } else if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) { // Reading input values from memory ForEachFunctor op(cargs); embb::algorithms::ForEach( diff --git a/base_cpp/perf/include/embb/base/perf/perf.h b/base_cpp/perf/include/embb/base/perf/perf.h index 23aeacb..6644558 100644 --- a/base_cpp/perf/include/embb/base/perf/perf.h +++ b/base_cpp/perf/include/embb/base/perf/perf.h @@ -34,11 +34,6 @@ #include #define PT_PERF_MAIN(component) \ -template \ -void PartestRunPerformanceTest(Test & test) { \ - test.Run(); \ - test.PrintReport(std::cout); \ -} \ void PartestRunPerformanceTests( \ embb::base::perf::CallArgs & perf_test_params); \ int main(int argc, char** argv) { \ @@ -59,8 +54,12 @@ void PartestRunPerformanceTests( \ #define PT_PERF_RUN(PT_PERF_TEST) \ ( \ (std::cout << "Running " << #PT_PERF_TEST << " ..." << std::endl), \ - PartestRunPerformanceTest(PT_PERF_TEST(perf_test_params)), \ + ({ \ + PT_PERF_TEST perf_test(perf_test_params); \ + perf_test.Run(); \ + perf_test.PrintReport(std::cout); \ + }), \ (std::cout << "Running " << #PT_PERF_TEST << " ..." << " done" << std::endl) \ ) -#endif // EMBB_BASE_CPP_PERF_PERF_H_ \ No newline at end of file +#endif // EMBB_BASE_CPP_PERF_PERF_H_ -- libgit2 0.26.0