diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..c820a2cb --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,18 @@ +cmake_minimum_required(VERSION 3.17) + +project(zoo VERSION 1.0) + +set(CMAKE_CXX_STANDARD 17) + +option (ENABLE_TESTS "Build tests" ON) +# todo jamie the benchmarks don't build from the root CMakeLists.txt +option (ENABLE_BENCHMARKS "Build benchmarks" OFF) + +if (ENABLE_TESTS) + enable_testing() + add_subdirectory(test) +endif() + +if (ENABLE_BENCHMARKS) + add_subdirectory(benchmark) +endif() diff --git a/src/CMakeLists.txt b/demo/CMakeLists.txt similarity index 97% rename from src/CMakeLists.txt rename to demo/CMakeLists.txt index 2872a150..c0f5ebbe 100644 --- a/src/CMakeLists.txt +++ b/demo/CMakeLists.txt @@ -29,7 +29,6 @@ add_compile_definitions(TESTS) add_executable( zooDemonstrations${CMAKE_BUILD_TYPE} - demoTightPolicy.cpp ../test/catch_main.cpp ${ADDITIONAL_SOURCES} ) diff --git a/src/statistics.cpp b/src/statistics.cpp index 0ee3b9b0..dc6d405b 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -2,6 +2,7 @@ #include #include #include +#include "TightPolicy.h" std::vector constructionTrace; diff --git a/test/CMakeLists.txt b/test/CMakeLists.txt index 411d9ce1..2d185bd1 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -1,8 +1,5 @@ cmake_minimum_required (VERSION 3.8) -set(CMAKE_BUILD_TYPE Debug) - - project(ZooTest VERSION 1.0 LANGUAGES CXX) configure_file ( @@ -33,6 +30,7 @@ if(MSVC) set( ZOO_TEST_SOURCES catch_main.cpp + demoTightPolicy.cpp any.cpp AlignedStorage.cpp AnyCallable.cpp AnyCallSignature.cpp AnyExtended.cpp GenericPolicy.cpp FunctionPolicy.cpp swar/BasicOperations.cpp @@ -122,7 +120,7 @@ else() set( ZOO_TEST_SOURCES ${CATCH2_MAIN_SOURCE} ${TYPE_ERASURE_SOURCES} ${ALGORITHM_SOURCES} - ${SWAR_SOURCES} + ${SWAR_SOURCES} ${MISCELLANEA_SOURCES} ) diff --git a/src/demoTightPolicy.cpp b/test/demoTightPolicy.cpp similarity index 100% rename from src/demoTightPolicy.cpp rename to test/demoTightPolicy.cpp diff --git a/test/swar/BasicOperations.cpp b/test/swar/BasicOperations.cpp index 1628e222..6682f710 100644 --- a/test/swar/BasicOperations.cpp +++ b/test/swar/BasicOperations.cpp @@ -357,7 +357,7 @@ TEST_CASE( const auto left = S2_16{0}.blitElement(1, i); const auto right = S2_16{S2_16::AllOnes}.blitElement(1, i-1); const auto test = S2_16{0}.blitElement(1, 2); - CHECK(test.value() == greaterEqual<2, u16>(left, right).value()); + CHECK(test.value() == greaterEqual<2, u16>(left, right).value()); } } SECTION("single") { @@ -365,7 +365,7 @@ TEST_CASE( const auto large = S4_32{0}.blitElement(1, i+1); const auto small = S4_32{S4_32::AllOnes}.blitElement(1, i-1); const auto test = S4_32{0}.blitElement(1, 8); - CHECK(test.value() == greaterEqual<4, u32>(large, small).value()); + CHECK(test.value() == greaterEqual<4, u32>(large, small).value()); } } SECTION("allLanes") { @@ -373,7 +373,7 @@ TEST_CASE( const auto small = S4_32(S4_32::LeastSignificantBit * (i-1)); const auto large = S4_32(S4_32::LeastSignificantBit * (i+1)); const auto test = S4_32(S4_32::LeastSignificantBit * 8); - CHECK(test.value() == greaterEqual<4, u32>(large, small).value()); + CHECK(test.value() == greaterEqual<4, u32>(large, small).value()); } } } @@ -425,7 +425,7 @@ TEST_CASE( "BooleanSWAR MSBtoLaneMask", "[swar]" ) { - // BooleanSWAR as a mask: + // BooleanSWAR as a mask: auto bswar =BooleanSWAR<4, u32>(0x0808'0000); auto mask = S4_32(0x0F0F'0000); CHECK(bswar.MSBtoLaneMask().value() == mask.value()); @@ -452,6 +452,6 @@ TEST_CASE( CHECK(SWAR<4, u16>(0x0400).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0100), SWAR<4, u16>(0x0300)).value()); CHECK(SWAR<4, u16>(0x0B00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0300)).value()); CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0700)).value()); - CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value()); - CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value()); + CHECK(SWAR<4, u16>(0x0F00).value() == saturatingUnsignedAddition(SWAR<4, u16>(0x0800), SWAR<4, u16>(0x0800)).value()); + CHECK(S4_32(0x0F0C'F000).value() == saturatingUnsignedAddition(S4_32(0x0804'F000), S4_32(0x0808'F000)).value()); }