Commit 58eec4f3 by Tobias Fuchs

performance test: improved macros for test setup, fixes for gcc

parent 077e21b4
...@@ -41,7 +41,7 @@ namespace perf { ...@@ -41,7 +41,7 @@ namespace perf {
template<typename T> template<typename T>
SerialForEach<T>::SerialForEach(const embb::base::perf::CallArgs & args) SerialForEach<T>::SerialForEach(const embb::base::perf::CallArgs & args)
: cargs(args), op(args), vector_size(args.VectorSize()) { : 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<T *>(embb::base::Allocation::AllocateCacheAligned( v = static_cast<T *>(embb::base::Allocation::AllocateCacheAligned(
vector_size * sizeof(T))); vector_size * sizeof(T)));
for (size_t i = 0; i < vector_size; i++) { for (size_t i = 0; i < vector_size; i++) {
...@@ -54,19 +54,19 @@ SerialForEach<T>::SerialForEach(const embb::base::perf::CallArgs & args) ...@@ -54,19 +54,19 @@ SerialForEach<T>::SerialForEach(const embb::base::perf::CallArgs & args)
template<typename T> template<typename T>
SerialForEach<T>::~SerialForEach() { SerialForEach<T>::~SerialForEach() {
if (cargs.StressMode() == CallArgs::RAM_STRESS) { if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) {
embb::base::Allocation::FreeAligned(v); embb::base::Allocation::FreeAligned(v);
} }
} }
template<typename T> template<typename T>
void SerialForEach<T>::Run() { void SerialForEach<T>::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++) { for (size_t i = 0; i < vector_size; i++) {
T v = static_cast<T>(i); T v = static_cast<T>(i);
op(v); 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++) { for (size_t i = 0; i < vector_size; i++) {
op(v[i]); op(v[i]);
} }
...@@ -76,7 +76,7 @@ void SerialForEach<T>::Run() { ...@@ -76,7 +76,7 @@ void SerialForEach<T>::Run() {
template<typename T> template<typename T>
ParallelForEach<T>::ParallelForEach(const embb::base::perf::CallArgs & args) ParallelForEach<T>::ParallelForEach(const embb::base::perf::CallArgs & args)
: cargs(args), vector_size(args.VectorSize()) { : cargs(args), vector_size(args.VectorSize()) {
if (cargs.StressMode() == CallArgs::RAM_STRESS) { if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) {
v = static_cast<T *>(embb::base::Allocation::AllocateCacheAligned( v = static_cast<T *>(embb::base::Allocation::AllocateCacheAligned(
vector_size * sizeof(T))); vector_size * sizeof(T)));
} else { } else {
...@@ -93,7 +93,7 @@ ParallelForEach<T>::~ParallelForEach() { ...@@ -93,7 +93,7 @@ ParallelForEach<T>::~ParallelForEach() {
template<typename T> template<typename T>
void ParallelForEach<T>::Pre() { void ParallelForEach<T>::Pre() {
if (cargs.StressMode() == CallArgs::RAM_STRESS) { if (cargs.StressMode() == embb::base::perf::CallArgs::RAM_STRESS) {
// Initialize input vector with incrementing values: // Initialize input vector with incrementing values:
for (size_t i = 0; i < vector_size; i++) { for (size_t i = 0; i < vector_size; i++) {
v[i] = static_cast<T>(i); v[i] = static_cast<T>(i);
...@@ -103,7 +103,7 @@ void ParallelForEach<T>::Pre() { ...@@ -103,7 +103,7 @@ void ParallelForEach<T>::Pre() {
template<typename T> template<typename T>
void ParallelForEach<T>::Run(unsigned int numThreads) { void ParallelForEach<T>::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 // Computing input values, no memory access
ForEachFunctor<T> op(cargs); ForEachFunctor<T> op(cargs);
embb::algorithms::ForEach( embb::algorithms::ForEach(
...@@ -114,7 +114,7 @@ void ParallelForEach<T>::Run(unsigned int numThreads) { ...@@ -114,7 +114,7 @@ void ParallelForEach<T>::Run(unsigned int numThreads) {
op, op,
embb::tasks::ExecutionPolicy(), embb::tasks::ExecutionPolicy(),
vector_size / numThreads); 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 // Reading input values from memory
ForEachFunctor<T> op(cargs); ForEachFunctor<T> op(cargs);
embb::algorithms::ForEach( embb::algorithms::ForEach(
......
...@@ -34,11 +34,6 @@ ...@@ -34,11 +34,6 @@
#include <iomanip> #include <iomanip>
#define PT_PERF_MAIN(component) \ #define PT_PERF_MAIN(component) \
template <class Test> \
void PartestRunPerformanceTest(Test & test) { \
test.Run(); \
test.PrintReport(std::cout); \
} \
void PartestRunPerformanceTests( \ void PartestRunPerformanceTests( \
embb::base::perf::CallArgs & perf_test_params); \ embb::base::perf::CallArgs & perf_test_params); \
int main(int argc, char** argv) { \ int main(int argc, char** argv) { \
...@@ -59,8 +54,12 @@ void PartestRunPerformanceTests( \ ...@@ -59,8 +54,12 @@ void PartestRunPerformanceTests( \
#define PT_PERF_RUN(PT_PERF_TEST) \ #define PT_PERF_RUN(PT_PERF_TEST) \
( \ ( \
(std::cout << "Running " << #PT_PERF_TEST << " ..." << std::endl), \ (std::cout << "Running " << #PT_PERF_TEST << " ..." << std::endl), \
PartestRunPerformanceTest<PT_PERF_TEST>(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) \ (std::cout << "Running " << #PT_PERF_TEST << " ..." << " done" << std::endl) \
) )
#endif // EMBB_BASE_CPP_PERF_PERF_H_ #endif // EMBB_BASE_CPP_PERF_PERF_H_
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment