From 0b1648bfcbe6bfbeb340996a915d27fcbd1ce2b9 Mon Sep 17 00:00:00 2001 From: Joel Falcou Date: Fri, 29 Mar 2019 19:45:03 +0100 Subject: [PATCH] Basic support for benchmarks (#67) --- .circleci/run.sh | 2 +- CMakeLists.txt | 6 +- benchmark/CMakeLists.txt | 10 ++ benchmark/bench.hpp | 138 ++++++++++++++++++ benchmark/module/core/CMakeLists.txt | 16 ++ .../module/core/scalar/bitwise_and/double.cpp | 17 +++ .../module/core/scalar/bitwise_and/float.cpp | 17 +++ .../module/core/scalar/bitwise_and/int16.cpp | 18 +++ .../module/core/scalar/bitwise_and/int32.cpp | 18 +++ .../module/core/scalar/bitwise_and/int64.cpp | 18 +++ .../module/core/scalar/bitwise_and/int8.cpp | 18 +++ .../module/core/scalar/bitwise_and/uint16.cpp | 18 +++ .../module/core/scalar/bitwise_and/uint32.cpp | 18 +++ .../module/core/scalar/bitwise_and/uint64.cpp | 18 +++ .../module/core/scalar/bitwise_and/uint8.cpp | 18 +++ .../module/core/simd/bitwise_and/double.cpp | 19 +++ .../module/core/simd/bitwise_and/float.cpp | 19 +++ .../module/core/simd/bitwise_and/int16.cpp | 19 +++ .../module/core/simd/bitwise_and/int32.cpp | 19 +++ .../module/core/simd/bitwise_and/int64.cpp | 19 +++ .../module/core/simd/bitwise_and/int8.cpp | 19 +++ .../module/core/simd/bitwise_and/uint16.cpp | 19 +++ .../module/core/simd/bitwise_and/uint32.cpp | 19 +++ .../module/core/simd/bitwise_and/uint64.cpp | 19 +++ .../module/core/simd/bitwise_and/uint8.cpp | 19 +++ cmake/benchmark.cmake | 74 +++++++++- 26 files changed, 606 insertions(+), 8 deletions(-) create mode 100644 benchmark/CMakeLists.txt create mode 100644 benchmark/bench.hpp create mode 100644 benchmark/module/core/CMakeLists.txt create mode 100644 benchmark/module/core/scalar/bitwise_and/double.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/float.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/int16.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/int32.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/int64.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/int8.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/uint16.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/uint32.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/uint64.cpp create mode 100644 benchmark/module/core/scalar/bitwise_and/uint8.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/double.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/float.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/int16.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/int32.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/int64.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/int8.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/uint16.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/uint32.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/uint64.cpp create mode 100644 benchmark/module/core/simd/bitwise_and/uint8.cpp diff --git a/.circleci/run.sh b/.circleci/run.sh index fcdb12036e..2168ecbf7f 100644 --- a/.circleci/run.sh +++ b/.circleci/run.sh @@ -13,4 +13,4 @@ cd build $1 --version cmake .. -DCMAKE_BUILD_TYPE=$VARIANT -G Ninja -DCMAKE_CXX_COMPILER=$1 -DCMAKE_CXX_FLAGS=$OPTIONS ninja unit -j 8 -ctest -D Experimental -j 8 +ctest -D Experimental -j 8 -R ^*.unit diff --git a/CMakeLists.txt b/CMakeLists.txt index 4f1049790a..1856ea4a64 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -29,9 +29,9 @@ include(parse_revision) ## ================================================================================================= ## Options ## ================================================================================================= -option( EVE_BUILD_TEST "Build tests for eve" ON ) -option( EVE_BUILD_BENCHMARKS "Build benchmarks for eve" OFF ) -option( EVE_BUILD_DOC "Build documentation for eve" ON ) +option( EVE_BUILD_TEST "Build tests for eve" ON ) +option( EVE_BUILD_BENCHMARKS "Build benchmarks for eve" ON ) +option( EVE_BUILD_DOC "Build documentation for eve" ON ) message( STATUS "[eve] Building ${CMAKE_BUILD_TYPE} mode with: ${CMAKE_CXX_FLAGS}") diff --git a/benchmark/CMakeLists.txt b/benchmark/CMakeLists.txt new file mode 100644 index 0000000000..dc81812c16 --- /dev/null +++ b/benchmark/CMakeLists.txt @@ -0,0 +1,10 @@ +##================================================================================================== +## EVE - Expressive Vector Engine +## Copyright 2019 Joel FALCOU +## Copyright 2019 Jean-Thierry LAPRESTE +## +## Licensed under the MIT License . +## SPDX-License-Identifier: MIT +##================================================================================================== + +add_subdirectory(module/core) diff --git a/benchmark/bench.hpp b/benchmark/bench.hpp new file mode 100644 index 0000000000..042a09a279 --- /dev/null +++ b/benchmark/bench.hpp @@ -0,0 +1,138 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#ifndef BENCHMARK_BENCH_HPP +#define BENCHMARK_BENCH_HPP + +#include +#include +#include "tts/detail/pp_helpers.hpp" +#include "cycleclock.h" +#include +#include +#include + +namespace eve::bench +{ + // ------------------------------------------------------------------------------------------------- + struct metrics + { + std::size_t size; + void operator()(benchmark::State& state, double cycles, std::size_t byte_size, std::size_t card) const + { + auto iter = state.iterations(); + state.SetItemsProcessed( iter * size * card); + state.SetBytesProcessed( iter * size * byte_size); + state.counters["cycle_per_value"] = (cycles / iter) / (size*card); + } + }; + + // ------------------------------------------------------------------------------------------------- + // Generators + template auto value(std::size_t sz, T const& val) + { + std::vector data(sz, val); + return data; + } + + template auto iota(std::size_t sz, T first = {}) + { + std::vector data(sz); + std::iota(data.begin(),data.end(),first); + return data; + } + + template auto arithmetic(std::size_t sz, T first = {}, T step = 1) + { + std::vector data(sz); + + data[0] = first; + for(std::size_t i=1;i auto geomtric(std::size_t sz, T first = 1, T step = 2) + { + std::vector data(sz); + + data[0] = first; + for(std::size_t i=1;i auto random(std::size_t sz, U mn, U mx) + { + std::vector data(sz); + std::generate ( data.begin(), data.end() + , [=]() + { + return static_cast( mn + std::rand() / (double)RAND_MAX * (mx - mn)); + } + ); + return data; + } + + template + struct experiment + { + using out_type = decltype( std::declval()(std::declval()...) ); + + experiment(std::string const& root, Fun fun, std::size_t size, Args const&... args) : output(size) + { + auto card = std::max({eve::cardinal_v...}); + std::cout << "[EVE] - Target: "<< TTS_STRING(EVE_CURRENT_API) << " - Build type: "; + #ifdef NDEBUG + std::cout << "Release - "; + #else + std::cout << "Debug - "; + #endif + std::cout << "Cardinal: " << card << "\n"; + + benchmark::RegisterBenchmark( root.c_str() + , [=,out = output.data()](benchmark::State& st) + { + auto c0 = benchmark::cycleclock::Now(); + while (st.KeepRunning()) + { + for(std::size_t i=0;i output; + }; +} + +int main(int argc, char** argv) +{ + using namespace eve::bench; + using T = TYPE(); + + auto size = benchmark::CPUInfo::Get().caches[1].size / sizeof(T); + auto name = std::string(TTS_STRING(FUNCTION())) + " - " + std::string(TTS_STRING(TYPE())); + + experiment _(name, FUNCTION(), size, SAMPLES(size)); + + benchmark::Initialize(&argc, argv); + benchmark::RunSpecifiedBenchmarks(); +} + +#endif diff --git a/benchmark/module/core/CMakeLists.txt b/benchmark/module/core/CMakeLists.txt new file mode 100644 index 0000000000..0fb49ed633 --- /dev/null +++ b/benchmark/module/core/CMakeLists.txt @@ -0,0 +1,16 @@ +##================================================================================================== +## EVE - Expressive Vector Engine +## Copyright 2019 Joel FALCOU +## Copyright 2019 Jean-Thierry LAPRESTE +## +## Licensed under the MIT License . +## SPDX-License-Identifier: MIT +##================================================================================================== + +##================================================================================================== +## scalar benchmarks +list_benchs("scalar/bitwise_and" "core" ${all_types}) + +##================================================================================================== +## SIMD< benchmarks +list_benchs("simd/bitwise_and" "core" ${all_types}) diff --git a/benchmark/module/core/scalar/bitwise_and/double.cpp b/benchmark/module/core/scalar/bitwise_and/double.cpp new file mode 100644 index 0000000000..2ba4c7a991 --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/double.cpp @@ -0,0 +1,17 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include + +#define TYPE() double +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100.,100.),random(N,-100.,100.) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/float.cpp b/benchmark/module/core/scalar/bitwise_and/float.cpp new file mode 100644 index 0000000000..9f7761165b --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/float.cpp @@ -0,0 +1,17 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include + +#define TYPE() float +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100.f,100.f),random(N,-100.f,100.f) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/int16.cpp b/benchmark/module/core/scalar/bitwise_and/int16.cpp new file mode 100644 index 0000000000..437d334854 --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/int16.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::int16_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/int32.cpp b/benchmark/module/core/scalar/bitwise_and/int32.cpp new file mode 100644 index 0000000000..e31adda1ee --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/int32.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::int32_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/int64.cpp b/benchmark/module/core/scalar/bitwise_and/int64.cpp new file mode 100644 index 0000000000..750ceee7c0 --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/int64.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::int64_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/int8.cpp b/benchmark/module/core/scalar/bitwise_and/int8.cpp new file mode 100644 index 0000000000..6a15e0e9a4 --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/int8.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::int8_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/uint16.cpp b/benchmark/module/core/scalar/bitwise_and/uint16.cpp new file mode 100644 index 0000000000..545c09e545 --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/uint16.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::uint16_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,10000),random(N,0,10000) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/uint32.cpp b/benchmark/module/core/scalar/bitwise_and/uint32.cpp new file mode 100644 index 0000000000..be4d45341d --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/uint32.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::uint32_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,10000),random(N,0,10000) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/uint64.cpp b/benchmark/module/core/scalar/bitwise_and/uint64.cpp new file mode 100644 index 0000000000..f35e7a2b3a --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/uint64.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::uint64_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,10000),random(N,0,10000) + +#include "bench.hpp" diff --git a/benchmark/module/core/scalar/bitwise_and/uint8.cpp b/benchmark/module/core/scalar/bitwise_and/uint8.cpp new file mode 100644 index 0000000000..2d5dc561ce --- /dev/null +++ b/benchmark/module/core/scalar/bitwise_and/uint8.cpp @@ -0,0 +1,18 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() std::uint8_t +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,200),random(N,0,200) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/double.cpp b/benchmark/module/core/simd/bitwise_and/double.cpp new file mode 100644 index 0000000000..43650246dc --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/double.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100.,100.),random(N,-100.,100.) + +#include "bench.hpp" + diff --git a/benchmark/module/core/simd/bitwise_and/float.cpp b/benchmark/module/core/simd/bitwise_and/float.cpp new file mode 100644 index 0000000000..e68daf102c --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/float.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100.f,100.f),random(N,-100.f,100.f) + +#include "bench.hpp" + diff --git a/benchmark/module/core/simd/bitwise_and/int16.cpp b/benchmark/module/core/simd/bitwise_and/int16.cpp new file mode 100644 index 0000000000..9ca547f672 --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/int16.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/int32.cpp b/benchmark/module/core/simd/bitwise_and/int32.cpp new file mode 100644 index 0000000000..36c9bdcac4 --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/int32.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/int64.cpp b/benchmark/module/core/simd/bitwise_and/int64.cpp new file mode 100644 index 0000000000..c7ea85781f --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/int64.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/int8.cpp b/benchmark/module/core/simd/bitwise_and/int8.cpp new file mode 100644 index 0000000000..5f1a145bee --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/int8.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,-100,100),random(N,-100,100) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/uint16.cpp b/benchmark/module/core/simd/bitwise_and/uint16.cpp new file mode 100644 index 0000000000..651d14f066 --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/uint16.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,10000),random(N,0,10000) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/uint32.cpp b/benchmark/module/core/simd/bitwise_and/uint32.cpp new file mode 100644 index 0000000000..ab98a428e4 --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/uint32.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,10000),random(N,0,10000) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/uint64.cpp b/benchmark/module/core/simd/bitwise_and/uint64.cpp new file mode 100644 index 0000000000..30b9afbf7f --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/uint64.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,10000),random(N,0,10000) + +#include "bench.hpp" diff --git a/benchmark/module/core/simd/bitwise_and/uint8.cpp b/benchmark/module/core/simd/bitwise_and/uint8.cpp new file mode 100644 index 0000000000..6d0d1a48f5 --- /dev/null +++ b/benchmark/module/core/simd/bitwise_and/uint8.cpp @@ -0,0 +1,19 @@ +//================================================================================================== +/** + EVE - Expressive Vector Engine + Copyright 2019 Joel FALCOU + Copyright 2019 Jean-Thierry LAPRESTE + + Licensed under the MIT License . + SPDX-License-Identifier: MIT +**/ +//================================================================================================== +#include +#include +#include + +#define TYPE() eve::wide +#define FUNCTION() eve::bitwise_and +#define SAMPLES(N) random(N,0,200),random(N,0,200) + +#include "bench.hpp" diff --git a/cmake/benchmark.cmake b/cmake/benchmark.cmake index 8b42cb16fc..b7fac93741 100644 --- a/cmake/benchmark.cmake +++ b/cmake/benchmark.cmake @@ -5,9 +5,75 @@ ## Licensed under the MIT License . ## SPDX-License-Identifier: MIT ##================================================================================================== + include(download) +include(add_parent_target) + +##================================================================================================== +## Centralize all required setup for unit benchs +##================================================================================================== +function(add_bench root) + if( MSVC ) + set( options /std:c++latest -W3 -EHsc) + else() + set( options -std=c++17 -Wall -Wno-missing-braces ) + endif() + + foreach(file ${ARGN}) + string(REPLACE ".cpp" ".bench" base ${file}) + string(REPLACE "/" "." base ${base}) + string(REPLACE "\\" "." base ${base}) + set(bench "${root}.${base}") + + add_executable( ${bench} ${file}) + target_compile_options ( ${bench} PUBLIC ${options} ) + + set_property( TARGET ${bench} + PROPERTY RUNTIME_OUTPUT_DIRECTORY "${PROJECT_BINARY_DIR}/bench" + ) + + add_test( NAME ${bench} + WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/bench" + COMMAND $ --benchmark_counters_tabular=true --benchmark_repetitions=3 --benchmark_report_aggregates_only=true + ) + + set_target_properties ( ${bench} PROPERTIES + EXCLUDE_FROM_DEFAULT_BUILD TRUE + EXCLUDE_FROM_ALL TRUE + ${MAKE_UNIT_TARGET_PROPERTIES} + ) -## Disable testing GBench + target_include_directories( ${bench} + PRIVATE + ${tts_SOURCE_DIR}/include + ${googlebenchmark_SOURCE_DIR}/include + ${googlebenchmark_SOURCE_DIR}/src + ${PROJECT_SOURCE_DIR}/benchmark + ${PROJECT_SOURCE_DIR}/include + ) + + target_link_libraries(${bench} benchmark) + add_dependencies(bench ${bench}) + + add_parent_target(${bench}) + endforeach() +endfunction() + +##================================================================================================== +## Generate a list of benchs from a type list +##================================================================================================== +function (list_benchs root bench) + set(sources ) + + foreach(e ${ARGN}) + list(APPEND sources "${root}/${e}.cpp") + endforeach(e) + + add_bench( ${bench} "${sources}" ) +endfunction() + +##================================================================================================== +## Disable benching/doc for Google Bench set(BENCHMARK_ENABLE_TESTING OFF CACHE INTERNAL "") download_project( PROJ googlebenchmark @@ -18,8 +84,8 @@ download_project( PROJ googlebenchmark ) add_subdirectory(${googlebenchmark_SOURCE_DIR} ${googlebenchmark_BINARY_DIR}) -include_directories("${googlebenchmark_SOURCE_DIR}/include") -## Setup our benchmarks +## Setup our benchs add_custom_target(bench) -#add_subdirectory(${PROJECT_SOURCE_DIR}/benchmark/) + +add_subdirectory(${PROJECT_SOURCE_DIR}/benchmark/)