From 96e3065c96e67f4aaf96e69aaa3be2bc66726c43 Mon Sep 17 00:00:00 2001 From: Jamie Pond <73431532+jamierpond@users.noreply.github.com> Date: Tue, 21 May 2024 18:35:52 -0700 Subject: [PATCH 1/6] init --- CMakeLists.txt | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 CMakeLists.txt diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 00000000..ad4b689a --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,9 @@ +cmake_minimum_required(VERSION 3.17) + +project(zoo) + +set(CMAKE_CXX_STANDARD 17) + +add_subdirectory(src) + + From 8476cfa232b9129547ced681a0a037bd3007f8d7 Mon Sep 17 00:00:00 2001 From: Jamie Pond <73431532+jamierpond@users.noreply.github.com> Date: Tue, 21 May 2024 18:43:37 -0700 Subject: [PATCH 2/6] wip --- CMakeLists.txt | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index ad4b689a..7e37027a 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,7 +3,25 @@ cmake_minimum_required(VERSION 3.17) project(zoo) set(CMAKE_CXX_STANDARD 17) +set(CMAKE_CXX_STANDARD_REQUIRED True) + +# add header files +include_directories(inc) + +# add source files +file(GLOB SOURCES "src/*.cpp") + + +# Add the include directory +include_directories("include") + +# Create a library target +add_library(zoo ${SOURCES}) + +# Install the library and headers +install(TARGETS zoo DESTINATION zoo/lib) +install(DIRECTORY include/ DESTINATION include) + -add_subdirectory(src) From ae0bf331f856c9acb8c24054568f75eed576ba49 Mon Sep 17 00:00:00 2001 From: Jamie Pond <73431532+jamierpond@users.noreply.github.com> Date: Tue, 21 May 2024 18:45:56 -0700 Subject: [PATCH 3/6] debug --- CMakeLists.txt | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 7e37027a..cf3d1406 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -18,6 +18,8 @@ include_directories("include") # Create a library target add_library(zoo ${SOURCES}) +message(STATUS "Hello from zoo") + # Install the library and headers install(TARGETS zoo DESTINATION zoo/lib) install(DIRECTORY include/ DESTINATION include) From 7d90e09a579407b6dc02fc8c46fde9b82b38caec Mon Sep 17 00:00:00 2001 From: Jamie Pond <73431532+jamierpond@users.noreply.github.com> Date: Tue, 21 May 2024 18:57:18 -0700 Subject: [PATCH 4/6] wip --- CMakeLists.txt | 5 +++++ src/CMakeLists.txt | 1 - test/CMakeLists.txt | 3 ++- {src => test}/demoTightPolicy.cpp | 0 4 files changed, 7 insertions(+), 2 deletions(-) rename {src => test}/demoTightPolicy.cpp (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index cf3d1406..bce81693 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -5,6 +5,9 @@ project(zoo) set(CMAKE_CXX_STANDARD 17) set(CMAKE_CXX_STANDARD_REQUIRED True) +message(STATUS "Updating submodules") +execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) + # add header files include_directories(inc) @@ -24,6 +27,8 @@ message(STATUS "Hello from zoo") install(TARGETS zoo DESTINATION zoo/lib) install(DIRECTORY include/ DESTINATION include) +# git submodule update --init --recursive +# do the submodule update diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 2872a150..c0f5ebbe 100644 --- a/src/CMakeLists.txt +++ b/src/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/test/CMakeLists.txt b/test/CMakeLists.txt index 411d9ce1..d0a61456 100644 --- a/test/CMakeLists.txt +++ b/test/CMakeLists.txt @@ -33,6 +33,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 +123,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 From ca5f7186d83d07297b169836c9640db469d04909 Mon Sep 17 00:00:00 2001 From: Jamie Pond <73431532+jamierpond@users.noreply.github.com> Date: Tue, 21 May 2024 22:05:23 -0700 Subject: [PATCH 5/6] wip --- CMakeLists.txt | 61 ++++++++++++++++++++++-------------- {src => demo}/CMakeLists.txt | 0 src/statistics.cpp | 1 + test/CMakeLists.txt | 3 -- 4 files changed, 38 insertions(+), 27 deletions(-) rename {src => demo}/CMakeLists.txt (100%) diff --git a/CMakeLists.txt b/CMakeLists.txt index bce81693..32cd6f14 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,34 +1,47 @@ cmake_minimum_required(VERSION 3.17) -project(zoo) +project(zoo VERSION 1.0) set(CMAKE_CXX_STANDARD 17) -set(CMAKE_CXX_STANDARD_REQUIRED True) +option(ENABLE_TESTING "Enable testing" OFF) -message(STATUS "Updating submodules") -execute_process(COMMAND git submodule update --init --recursive WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) - -# add header files +# Include directories include_directories(inc) -# add source files -file(GLOB SOURCES "src/*.cpp") - +# Get all header files in the 'inc' directory +file(GLOB HEADERS "inc/*.h" "inc/*.hpp") -# Add the include directory -include_directories("include") +# Get all source files in the 'src' directory +file(GLOB SOURCES "src/*.cpp") # Create a library target -add_library(zoo ${SOURCES}) - -message(STATUS "Hello from zoo") - -# Install the library and headers -install(TARGETS zoo DESTINATION zoo/lib) -install(DIRECTORY include/ DESTINATION include) - -# git submodule update --init --recursive -# do the submodule update - - - +add_library(zoo ${SOURCES} ${HEADERS}) + +# Set include directories for the library +target_include_directories(zoo PUBLIC + $ + $ +) + +# Installation +install(TARGETS zoo EXPORT zoo-targets + LIBRARY DESTINATION lib + ARCHIVE DESTINATION lib + RUNTIME DESTINATION bin + INCLUDES DESTINATION include +) + +install(FILES ${HEADERS} DESTINATION include) + +install(EXPORT zoo-targets + FILE zoo-config.cmake + NAMESPACE zoo:: + DESTINATION lib/cmake/zoo +) + +export(TARGETS zoo FILE zoo-config.cmake) + +if (ENABLE_TESTING) + enable_testing() + add_subdirectory(test) +endif() diff --git a/src/CMakeLists.txt b/demo/CMakeLists.txt similarity index 100% rename from src/CMakeLists.txt rename to demo/CMakeLists.txt 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 d0a61456..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 ( From 8f66c066906c8212fda9a8da3e760fef08016ef1 Mon Sep 17 00:00:00 2001 From: Jamie Pond <73431532+jamierpond@users.noreply.github.com> Date: Tue, 21 May 2024 22:18:35 -0700 Subject: [PATCH 6/6] camke --- CMakeLists.txt | 45 +++++++---------------------------- test/swar/BasicOperations.cpp | 12 +++++----- 2 files changed, 14 insertions(+), 43 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 32cd6f14..c820a2cb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,45 +3,16 @@ cmake_minimum_required(VERSION 3.17) project(zoo VERSION 1.0) set(CMAKE_CXX_STANDARD 17) -option(ENABLE_TESTING "Enable testing" OFF) -# Include directories -include_directories(inc) +option (ENABLE_TESTS "Build tests" ON) +# todo jamie the benchmarks don't build from the root CMakeLists.txt +option (ENABLE_BENCHMARKS "Build benchmarks" OFF) -# Get all header files in the 'inc' directory -file(GLOB HEADERS "inc/*.h" "inc/*.hpp") - -# Get all source files in the 'src' directory -file(GLOB SOURCES "src/*.cpp") - -# Create a library target -add_library(zoo ${SOURCES} ${HEADERS}) - -# Set include directories for the library -target_include_directories(zoo PUBLIC - $ - $ -) - -# Installation -install(TARGETS zoo EXPORT zoo-targets - LIBRARY DESTINATION lib - ARCHIVE DESTINATION lib - RUNTIME DESTINATION bin - INCLUDES DESTINATION include -) - -install(FILES ${HEADERS} DESTINATION include) - -install(EXPORT zoo-targets - FILE zoo-config.cmake - NAMESPACE zoo:: - DESTINATION lib/cmake/zoo -) - -export(TARGETS zoo FILE zoo-config.cmake) - -if (ENABLE_TESTING) +if (ENABLE_TESTS) enable_testing() add_subdirectory(test) endif() + +if (ENABLE_BENCHMARKS) + add_subdirectory(benchmark) +endif() 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()); }