From 61ab82b725946e1d2df77c854cdedc428d1ef94d Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 12:17:44 -0500 Subject: [PATCH 1/9] Testing amalgamation files --- CMakeLists.txt | 32 ++++++++++++++++++++++++++++++++ amalgamation.sh | 20 ++++++++++++++++++++ 2 files changed, 52 insertions(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index ce31c0294..8b4dacea7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -110,6 +110,38 @@ if(ENABLE_ROARING_TESTS) endif() add_subdirectory(tests) endif() +find_program(BASH bash) + +if(ENABLE_ROARING_TESTS AND BASH) + set(CROARING_SINGLEHEADER_FILES + ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.c + ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/roaring.c + ${CMAKE_CURRENT_SOURCE_DIR}/roaring.h + ${CMAKE_CURRENT_SOURCE_DIR}/roaring.hh + ) + set_source_files_properties(${CROARING_SINGLEHEADER_FILES} PROPERTIES GENERATED TRUE) + + add_custom_command( + OUTPUT ${CROARING_SINGLEHEADER_FILES} + COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh + ) + add_custom_target(croaring-singleheader-files DEPENDS ${CROARING_SINGLEHEADER_FILES}) + + add_library(croaring-singleheader-include-source INTERFACE) + target_include_directories(croaring-singleheader-include-source INTERFACE $) + add_dependencies(croaring-singleheader-include-source croaring-singleheader-files) + + add_executable(amalgamate_demo $) + target_link_libraries(amalgamate_demo croaring-singleheader-include-source) + add_test(amalgamate_demo amalgamate_demo) + + add_executable(amalgamate_demo_cpp $) + target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source) + add_test(amalgamate_demo_cpp amalgamate_demo_cpp) + + endif() option(ENABLE_ROARING_MICROBENCHMARKS "Enable microbenchmarks" OFF) if(ENABLE_ROARING_MICROBENCHMARKS) add_subdirectory(microbenchmarks) diff --git a/amalgamation.sh b/amalgamation.sh index ca12b6102..34da73b00 100755 --- a/amalgamation.sh +++ b/amalgamation.sh @@ -174,6 +174,25 @@ echo "Creating ${DEMOC}..." #include #include #include "roaring.c" + + +void or_many(void) { + roaring_bitmap_t *r1 = roaring_bitmap_of(2, 500, 1000); + roaring_bitmap_t *r2 = roaring_bitmap_of(2, 1000, 2000); + + const roaring_bitmap_t *bitmap_arr[2] = {r1, r2}; + fprintf(stderr, "Going to or many\n"); + for (int i = 0; i < 10000; i++) { + roaring_bitmap_t *r = roaring_bitmap_or_many(2, bitmap_arr); + roaring_bitmap_free(r); + } + + fprintf(stderr, "Got done\n"); + + roaring_bitmap_free(r2); + roaring_bitmap_free(r1); +} + int main() { roaring_bitmap_t *r1 = roaring_bitmap_create(); for (uint32_t i = 100; i < 1000; i++) roaring_bitmap_add(r1, i); @@ -191,6 +210,7 @@ int main() { } printf("%zu \n", bitset_count(b)); bitset_free(b); + or_many(); return EXIT_SUCCESS; } ' From ec200e5c29ff37544ebe1f0d1a924b0c6830b857 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 12:20:08 -0500 Subject: [PATCH 2/9] specifying working directory --- CMakeLists.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8b4dacea7..40167f328 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -125,6 +125,7 @@ if(ENABLE_ROARING_TESTS AND BASH) add_custom_command( OUTPUT ${CROARING_SINGLEHEADER_FILES} COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh + WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh ) add_custom_target(croaring-singleheader-files DEPENDS ${CROARING_SINGLEHEADER_FILES}) From 8d085ca6e2c97ba5a99a78e36dd024646f15922d Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 17:08:04 -0500 Subject: [PATCH 3/9] minor tweak --- CMakeLists.txt | 12 +++++++++++- amalgamation.sh | 4 ++-- tools/cmake/FindOptions.cmake | 11 +++++------ 3 files changed, 18 insertions(+), 9 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 40167f328..bcb5592c6 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -3,6 +3,9 @@ project(RoaringBitmap DESCRIPTION "Roaring bitmaps in C (and C++)" LANGUAGES CXX C ) +set (CMAKE_C_STANDARD 11) +set (CMAKE_CXX_STANDARD 11) + include(GNUInstallDirs) if (NOT CMAKE_BUILD_TYPE) @@ -128,6 +131,8 @@ if(ENABLE_ROARING_TESTS AND BASH) WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh ) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.c PROPERTIES LANGUAGE C CMAKE_C_STANDARD 11) + set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.cpp PROPERTIES LANGUAGE CXX CXX_STANDARD 11) add_custom_target(croaring-singleheader-files DEPENDS ${CROARING_SINGLEHEADER_FILES}) add_library(croaring-singleheader-include-source INTERFACE) @@ -140,9 +145,14 @@ if(ENABLE_ROARING_TESTS AND BASH) add_executable(amalgamate_demo_cpp $) target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source) + if(ROARING_EXCEPTIONS) + target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=1) + else() + target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=0) + endif() add_test(amalgamate_demo_cpp amalgamate_demo_cpp) - endif() +endif() option(ENABLE_ROARING_MICROBENCHMARKS "Enable microbenchmarks" OFF) if(ENABLE_ROARING_MICROBENCHMARKS) add_subdirectory(microbenchmarks) diff --git a/amalgamation.sh b/amalgamation.sh index 34da73b00..bb63917d4 100755 --- a/amalgamation.sh +++ b/amalgamation.sh @@ -177,8 +177,8 @@ echo "Creating ${DEMOC}..." void or_many(void) { - roaring_bitmap_t *r1 = roaring_bitmap_of(2, 500, 1000); - roaring_bitmap_t *r2 = roaring_bitmap_of(2, 1000, 2000); + roaring_bitmap_t *r1 = roaring_bitmap_from(500, 1000); + roaring_bitmap_t *r2 = roaring_bitmap_from(1000, 2000); const roaring_bitmap_t *bitmap_arr[2] = {r1, r2}; fprintf(stderr, "Going to or many\n"); diff --git a/tools/cmake/FindOptions.cmake b/tools/cmake/FindOptions.cmake index f7b8f9675..1a9dab7eb 100644 --- a/tools/cmake/FindOptions.cmake +++ b/tools/cmake/FindOptions.cmake @@ -34,13 +34,12 @@ endif() endif() if(NOT MSVC) -set(STD_FLAGS "-std=c11 -fPIC") -set(CXXSTD_FLAGS "-std=c++11 -fPIC") -endif() - set(WARNING_FLAGS "-Wall") -if(NOT MSVC) -set(WARNING_FLAGS "${WARNING_FLAGS} -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self") +if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") +set(WARNING_FLAGS "${WARNING_FLAGS} -Wmissing-braces -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self") +elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") +set(WARNING_FLAGS "${WARNING_FLAGS} -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wcast-align -Wmissing-prototypes") +endif() endif() set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} ${STD_FLAGS} ${OPT_FLAGS} ${INCLUDE_FLAGS} ${WARNING_FLAGS} ${ROARING_SANITIZE_FLAGS} ") From f77808ee70696bb155419003db2327873c7938b5 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 17:22:30 -0500 Subject: [PATCH 4/9] tweaks --- amalgamation.sh | 2 +- benchmarks/adversarialunions_benchmark.c | 4 ++-- benchmarks/equals_benchmark.c | 6 +++--- benchmarks/run_container_benchmark.c | 16 ++++++++-------- tests/format_portability_unit.c | 8 ++++---- tools/cmake/FindOptions.cmake | 2 +- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/amalgamation.sh b/amalgamation.sh index bb63917d4..e78bcad8b 100755 --- a/amalgamation.sh +++ b/amalgamation.sh @@ -176,7 +176,7 @@ echo "Creating ${DEMOC}..." #include "roaring.c" -void or_many(void) { +static inline void or_many(void) { roaring_bitmap_t *r1 = roaring_bitmap_from(500, 1000); roaring_bitmap_t *r2 = roaring_bitmap_from(1000, 2000); diff --git a/benchmarks/adversarialunions_benchmark.c b/benchmarks/adversarialunions_benchmark.c index 5c0d620d2..b06a1ea55 100644 --- a/benchmarks/adversarialunions_benchmark.c +++ b/benchmarks/adversarialunions_benchmark.c @@ -2,7 +2,7 @@ #include #include #include "benchmark.h" -int quickfull() { +inline int quickfull() { printf("The naive approach works well when the bitmaps quickly become full\n"); uint64_t cycles_start, cycles_final; size_t bitmapcount = 100; @@ -47,7 +47,7 @@ int quickfull() { return 0; } -int notsofull() { +inline int notsofull() { printf("The naive approach works less well when the bitmaps do not quickly become full\n"); uint64_t cycles_start, cycles_final; size_t bitmapcount = 100; diff --git a/benchmarks/equals_benchmark.c b/benchmarks/equals_benchmark.c index 6aebce08c..b665c3343 100644 --- a/benchmarks/equals_benchmark.c +++ b/benchmarks/equals_benchmark.c @@ -8,9 +8,9 @@ #include "benchmark.h" #include "random.h" -int32_t array_container_get_nruns(const array_container_t *c) { (void) c; return -1; } -int32_t bitset_container_get_nruns(const bitset_container_t *c) { (void) c; return -1; } -int32_t run_container_get_nruns(const run_container_t *c) { return c->n_runs; } +inline int32_t array_container_get_nruns(const array_container_t *c) { (void) c; return -1; } +inline int32_t bitset_container_get_nruns(const bitset_container_t *c) { (void) c; return -1; } +inline int32_t run_container_get_nruns(const run_container_t *c) { return c->n_runs; } #define BENCHMARK_CONTAINER(cname1, cname2, fname, n) \ { \ diff --git a/benchmarks/run_container_benchmark.c b/benchmarks/run_container_benchmark.c index e2fdc495a..7401027e4 100644 --- a/benchmarks/run_container_benchmark.c +++ b/benchmarks/run_container_benchmark.c @@ -8,7 +8,7 @@ enum { TESTSIZE = 2048 }; #if defined(CROARING_IS_X64) && !(defined(_MSC_VER) && !defined(__clang__)) // flushes the array from cache -void run_cache_flush(run_container_t* B) { +static inline void run_cache_flush(run_container_t* B) { const int32_t CACHELINESIZE = computecacheline(); // 64 bytes per cache line for (int32_t k = 0; k < B->n_runs * 2; @@ -17,11 +17,11 @@ void run_cache_flush(run_container_t* B) { } } #else -void run_cache_flush(run_container_t* B) { (void)B; } +static inline void run_cache_flush(run_container_t* B) { (void)B; } #endif // tries to put array in cache -void run_cache_prefetch(run_container_t* B) { +static inline void run_cache_prefetch(run_container_t* B) { #if !CROARING_REGULAR_VISUAL_STUDIO #if CROARING_IS_X64 const int32_t CACHELINESIZE = @@ -36,7 +36,7 @@ void run_cache_prefetch(run_container_t* B) { #endif // !CROARING_REGULAR_VISUAL_STUDIO } -int add_test(run_container_t* B) { +static inline int add_test(run_container_t* B) { int x; for (x = 0; x < (1 << 16); x += 3) { run_container_add(B, (uint16_t)x); @@ -44,7 +44,7 @@ int add_test(run_container_t* B) { return 0; } -int remove_test(run_container_t* B) { +static inline int remove_test(run_container_t* B) { int x; for (x = 0; x < (1 << 16); x += 3) { run_container_remove(B, (uint16_t)x); @@ -52,7 +52,7 @@ int remove_test(run_container_t* B) { return 0; } -int contains_test(run_container_t* B) { +static inline int contains_test(run_container_t* B) { int card = 0; int x; for (x = 0; x < (1 << 16); x++) { @@ -61,12 +61,12 @@ int contains_test(run_container_t* B) { return card; } -int union_test(run_container_t* B1, run_container_t* B2, run_container_t* BO) { +static inline int union_test(run_container_t* B1, run_container_t* B2, run_container_t* BO) { run_container_union(B1, B2, BO); return run_container_cardinality(BO); } -int intersection_test(run_container_t* B1, run_container_t* B2, +static inline int intersection_test(run_container_t* B1, run_container_t* B2, run_container_t* BO) { run_container_intersection(B1, B2, BO); return run_container_cardinality(BO); diff --git a/tests/format_portability_unit.c b/tests/format_portability_unit.c index a823a9b64..fba9c65c9 100644 --- a/tests/format_portability_unit.c +++ b/tests/format_portability_unit.c @@ -16,7 +16,7 @@ #include "test.h" -long filesize(char const* path) { +inline long filesize(char const* path) { FILE* fp = fopen(path, "rb"); assert_non_null(fp); @@ -25,7 +25,7 @@ long filesize(char const* path) { return ftell(fp); } -char* readfile(char const* path) { +inline char* readfile(char const* path) { FILE* fp = fopen(path, "rb"); assert_non_null(fp); @@ -42,7 +42,7 @@ char* readfile(char const* path) { return buf; } -int compare(char* x, char* y, size_t size) { +inline int compare(char* x, char* y, size_t size) { for (size_t i = 0; i < size; ++i) { if (x[i] != y[i]) { return i + 1; @@ -51,7 +51,7 @@ int compare(char* x, char* y, size_t size) { return 0; } -void test_deserialize(char* filename) { +inline void test_deserialize(char* filename) { char* input_buffer = readfile(filename); assert_non_null(input_buffer); diff --git a/tools/cmake/FindOptions.cmake b/tools/cmake/FindOptions.cmake index 1a9dab7eb..095031986 100644 --- a/tools/cmake/FindOptions.cmake +++ b/tools/cmake/FindOptions.cmake @@ -38,7 +38,7 @@ set(WARNING_FLAGS "-Wall") if (CMAKE_CXX_COMPILER_ID STREQUAL "Clang") set(WARNING_FLAGS "${WARNING_FLAGS} -Wmissing-braces -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self") elseif (CMAKE_CXX_COMPILER_ID STREQUAL "GNU") -set(WARNING_FLAGS "${WARNING_FLAGS} -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wcast-align -Wmissing-prototypes") +set(WARNING_FLAGS "${WARNING_FLAGS} -Wextra -Wsign-compare -Wshadow -Wwrite-strings -Wpointer-arith -Winit-self -Wcast-align") endif() endif() From d6ddb4d5fc6f5847fe85c79b6aa2befd1f8225ac Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 20:25:42 -0500 Subject: [PATCH 5/9] fix. --- CMakeLists.txt | 17 +++++++++-------- benchmarks/adversarialunions_benchmark.c | 4 ++-- 2 files changed, 11 insertions(+), 10 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index bcb5592c6..cd437f953 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -142,15 +142,16 @@ if(ENABLE_ROARING_TESTS AND BASH) add_executable(amalgamate_demo $) target_link_libraries(amalgamate_demo croaring-singleheader-include-source) add_test(amalgamate_demo amalgamate_demo) - - add_executable(amalgamate_demo_cpp $) - target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source) - if(ROARING_EXCEPTIONS) - target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=1) - else() - target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=0) + if(NOT MSVC) + add_executable(amalgamate_demo_cpp $) + target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source) + if(ROARING_EXCEPTIONS) + target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=1) + else() + target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=0) + endif() + add_test(amalgamate_demo_cpp amalgamate_demo_cpp) endif() - add_test(amalgamate_demo_cpp amalgamate_demo_cpp) endif() option(ENABLE_ROARING_MICROBENCHMARKS "Enable microbenchmarks" OFF) diff --git a/benchmarks/adversarialunions_benchmark.c b/benchmarks/adversarialunions_benchmark.c index b06a1ea55..3a2e27b84 100644 --- a/benchmarks/adversarialunions_benchmark.c +++ b/benchmarks/adversarialunions_benchmark.c @@ -2,7 +2,7 @@ #include #include #include "benchmark.h" -inline int quickfull() { +static inline int quickfull() { printf("The naive approach works well when the bitmaps quickly become full\n"); uint64_t cycles_start, cycles_final; size_t bitmapcount = 100; @@ -47,7 +47,7 @@ inline int quickfull() { return 0; } -inline int notsofull() { +static inline int notsofull() { printf("The naive approach works less well when the bitmaps do not quickly become full\n"); uint64_t cycles_start, cycles_final; size_t bitmapcount = 100; From 9ac97e8903f6d788cdcc1de915a82135e8cf9089 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 20:47:15 -0500 Subject: [PATCH 6/9] Removing old vs --- .github/workflows/vs16-arm-ci.yml | 28 ------------------------ .github/workflows/vs16-ci.yml | 36 ------------------------------- tests/format_portability_unit.c | 8 +++---- 3 files changed, 4 insertions(+), 68 deletions(-) delete mode 100644 .github/workflows/vs16-arm-ci.yml delete mode 100644 .github/workflows/vs16-ci.yml diff --git a/.github/workflows/vs16-arm-ci.yml b/.github/workflows/vs16-arm-ci.yml deleted file mode 100644 index f03caae40..000000000 --- a/.github/workflows/vs16-arm-ci.yml +++ /dev/null @@ -1,28 +0,0 @@ -name: VS16-ARM-CI - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - ci: - name: windows-vs16 - runs-on: windows-2019 - strategy: - fail-fast: false - matrix: - include: - - {gen: Visual Studio 16 2019, arch: ARM} - - {gen: Visual Studio 16 2019, arch: ARM64} - steps: - - name: checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Configure - run: | - mkdir build - cd build && cmake -G "${{matrix.gen}}" -A ${{matrix.arch}} .. - - name: Build - run: cmake --build build --config Release - - name: Build Debug - run: cmake --build build --config Debug \ No newline at end of file diff --git a/.github/workflows/vs16-ci.yml b/.github/workflows/vs16-ci.yml deleted file mode 100644 index 33b1cdfc8..000000000 --- a/.github/workflows/vs16-ci.yml +++ /dev/null @@ -1,36 +0,0 @@ -name: VS16-CI - -on: [push, pull_request] - -permissions: - contents: read - -jobs: - ci: - name: windows-vs16 - runs-on: windows-2019 - strategy: - fail-fast: false - matrix: - include: - - {gen: Visual Studio 16 2019, arch: Win32} - - {gen: Visual Studio 16 2019, arch: x64} - steps: - - name: checkout - uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # v4.1.1 - - name: Configure - run: | - mkdir build - cd build && cmake -DENABLE_ROARING_TESTS=ON -G "${{matrix.gen}}" -A ${{matrix.arch}} .. - - name: Build - run: cmake --build build --config Release - - name: Run basic tests - run: | - cd build - ctest -C Release --output-on-failure - - name: Build Debug - run: cmake --build build --config Debug - - name: Run basic tests in Debug - run: | - cd build - ctest -C Debug --output-on-failure \ No newline at end of file diff --git a/tests/format_portability_unit.c b/tests/format_portability_unit.c index fba9c65c9..22d4fc004 100644 --- a/tests/format_portability_unit.c +++ b/tests/format_portability_unit.c @@ -16,7 +16,7 @@ #include "test.h" -inline long filesize(char const* path) { +static inline long filesize(char const* path) { FILE* fp = fopen(path, "rb"); assert_non_null(fp); @@ -25,7 +25,7 @@ inline long filesize(char const* path) { return ftell(fp); } -inline char* readfile(char const* path) { +static inline char* readfile(char const* path) { FILE* fp = fopen(path, "rb"); assert_non_null(fp); @@ -42,7 +42,7 @@ inline char* readfile(char const* path) { return buf; } -inline int compare(char* x, char* y, size_t size) { +static inline int compare(char* x, char* y, size_t size) { for (size_t i = 0; i < size; ++i) { if (x[i] != y[i]) { return i + 1; @@ -51,7 +51,7 @@ inline int compare(char* x, char* y, size_t size) { return 0; } -inline void test_deserialize(char* filename) { +static inline void test_deserialize(char* filename) { char* input_buffer = readfile(filename); assert_non_null(input_buffer); From 6e992c47403e0c2ff8bb725f44d75281c25b0890 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 21:01:30 -0500 Subject: [PATCH 7/9] removing useless check --- tools/cmake/FindCTargets.cmake | 3 --- 1 file changed, 3 deletions(-) diff --git a/tools/cmake/FindCTargets.cmake b/tools/cmake/FindCTargets.cmake index 243cc848a..3218aab10 100644 --- a/tools/cmake/FindCTargets.cmake +++ b/tools/cmake/FindCTargets.cmake @@ -1,6 +1,3 @@ -if (CMAKE_VERSION VERSION_GREATER 3.0.0) - cmake_policy(VERSION 3.0.0) -endif () include(${PROJECT_SOURCE_DIR}/tools/cmake/Import.cmake) set(BUILD_STATIC_LIB ON) if (ENABLE_ROARING_TESTS) From 8dd9ef07f95e5e6004479293fb64502c65445d08 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Thu, 25 Jan 2024 21:53:40 -0500 Subject: [PATCH 8/9] more silencing --- CMakeLists.txt | 12 +++++++++--- amalgamation.sh | 5 +++-- benchmarks/equals_benchmark.c | 6 +++--- include/roaring/array_util.h | 10 ++++++++-- include/roaring/bitset_util.h | 10 ++++++++-- microbenchmarks/bench.h | 10 ++++++++-- src/array_util.c | 8 ++++++++ src/bitset_util.c | 9 ++++++++- src/containers/bitset.c | 8 ++++++++ src/containers/run.c | 9 ++++++++- 10 files changed, 71 insertions(+), 16 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index cd437f953..d70d36efa 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,7 +115,10 @@ if(ENABLE_ROARING_TESTS) endif() find_program(BASH bash) -if(ENABLE_ROARING_TESTS AND BASH) +# we assume write access to the source directory +option(ROARING_DISABLE_AMAL "Forcefully disable amalgamation tests" OFF) + +if(ENABLE_ROARING_TESTS AND BASH AND !ROARING_DISABLE_AMAL) set(CROARING_SINGLEHEADER_FILES ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.c ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.cpp @@ -129,7 +132,7 @@ if(ENABLE_ROARING_TESTS AND BASH) OUTPUT ${CROARING_SINGLEHEADER_FILES} COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh ${CROARING_SINGLEHEADER_FILES} ) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.c PROPERTIES LANGUAGE C CMAKE_C_STANDARD 11) set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.cpp PROPERTIES LANGUAGE CXX CXX_STANDARD 11) @@ -143,8 +146,11 @@ if(ENABLE_ROARING_TESTS AND BASH) target_link_libraries(amalgamate_demo croaring-singleheader-include-source) add_test(amalgamate_demo amalgamate_demo) if(NOT MSVC) + add_library(croaring-singleheader-source-lib $) + target_include_directories(croaring-singleheader-source-lib PUBLIC $) + add_executable(amalgamate_demo_cpp $) - target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source) + target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source croaring-singleheader-source-lib) if(ROARING_EXCEPTIONS) target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=1) else() diff --git a/amalgamation.sh b/amalgamation.sh index e78bcad8b..9b01ae6dc 100755 --- a/amalgamation.sh +++ b/amalgamation.sh @@ -249,7 +249,8 @@ echo "Creating ${DEMOCPP}..." cat <<< ' #include #include "roaring.hh" -#include "roaring.c" +//#include "roaring.c" + int main() { roaring::Roaring r1; for (uint32_t i = 100; i < 1000; i++) { @@ -284,7 +285,7 @@ echo "For C, try:" echo "cc -O3 -std=c11 -o ${CBIN} ${DEMOC} && ./${CBIN} " newline echo "For C++, try:" -echo "c++ -O3 -std=c++11 -o ${CPPBIN} ${DEMOCPP} && ./${CPPBIN} " +echo "c++ -O3 -std=c++11 -o ${CPPBIN} ${DEMOCPP} ${AMAL_C} && ./${CPPBIN} " lowercase(){ echo "$1" | tr 'A-Z' 'a-z' diff --git a/benchmarks/equals_benchmark.c b/benchmarks/equals_benchmark.c index b665c3343..84bee85dc 100644 --- a/benchmarks/equals_benchmark.c +++ b/benchmarks/equals_benchmark.c @@ -8,9 +8,9 @@ #include "benchmark.h" #include "random.h" -inline int32_t array_container_get_nruns(const array_container_t *c) { (void) c; return -1; } -inline int32_t bitset_container_get_nruns(const bitset_container_t *c) { (void) c; return -1; } -inline int32_t run_container_get_nruns(const run_container_t *c) { return c->n_runs; } +static inline int32_t array_container_get_nruns(const array_container_t *c) { (void) c; return -1; } +static inline int32_t bitset_container_get_nruns(const bitset_container_t *c) { (void) c; return -1; } +static inline int32_t run_container_get_nruns(const run_container_t *c) { return c->n_runs; } #define BENCHMARK_CONTAINER(cname1, cname2, fname, n) \ { \ diff --git a/include/roaring/array_util.h b/include/roaring/array_util.h index d9baa2b3b..7d04a5c85 100644 --- a/include/roaring/array_util.h +++ b/include/roaring/array_util.h @@ -11,7 +11,11 @@ #error "CROARING_COMPILER_SUPPORTS_AVX512 needs to be defined." #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #ifdef __cplusplus extern "C" { namespace roaring { namespace internal { #endif @@ -259,5 +263,7 @@ bool memequals(const void *s1, const void *s2, size_t n); #ifdef __cplusplus } } } // extern "C" { namespace roaring { namespace internal { #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif #endif diff --git a/include/roaring/bitset_util.h b/include/roaring/bitset_util.h index 32bc6798a..ac0c09e02 100644 --- a/include/roaring/bitset_util.h +++ b/include/roaring/bitset_util.h @@ -11,7 +11,11 @@ #error "CROARING_COMPILER_SUPPORTS_AVX512 needs to be defined." #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #ifdef __cplusplus extern "C" { namespace roaring { namespace internal { #endif @@ -710,5 +714,7 @@ CROARING_UNTARGET_AVX512 #ifdef __cplusplus } } } // extern "C" { namespace roaring { namespace internal #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif #endif diff --git a/microbenchmarks/bench.h b/microbenchmarks/bench.h index 20904abac..b691d4744 100644 --- a/microbenchmarks/bench.h +++ b/microbenchmarks/bench.h @@ -26,7 +26,11 @@ #error "CROARING_COMPILER_SUPPORTS_AVX512 needs to be defined." #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif using roaring::Roaring64Map; event_collector collector; @@ -305,5 +309,7 @@ int load(const char *dirname) { if (bitmaps == NULL) return -1; return count; } - #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/src/array_util.c b/src/array_util.c index cddd27fb2..311bd7299 100644 --- a/src/array_util.c +++ b/src/array_util.c @@ -15,6 +15,11 @@ #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #ifdef __cplusplus using namespace ::roaring::internal; extern "C" { namespace roaring { namespace internal { @@ -2168,3 +2173,6 @@ CROARING_UNTARGET_AVX512 #ifdef __cplusplus } } } // extern "C" { namespace roaring { namespace internal { #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/src/bitset_util.c b/src/bitset_util.c index 3a22e6c03..45b5d2332 100644 --- a/src/bitset_util.c +++ b/src/bitset_util.c @@ -11,7 +11,11 @@ #error "CROARING_COMPILER_SUPPORTS_AVX512 needs to be defined." #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #ifdef __cplusplus using namespace ::roaring::internal; extern "C" { namespace roaring { namespace api { @@ -1126,3 +1130,6 @@ void bitset_flip_list(uint64_t *words, const uint16_t *list, uint64_t length) { #ifdef __cplusplus } } } // extern "C" { namespace roaring { namespace api { #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/src/containers/bitset.c b/src/containers/bitset.c index 6e0f871e5..e2ccb0ae3 100644 --- a/src/containers/bitset.c +++ b/src/containers/bitset.c @@ -23,6 +23,11 @@ #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #ifdef __cplusplus extern "C" { namespace roaring { namespace internal { #endif @@ -1298,3 +1303,6 @@ int bitset_container_index_equalorlarger(const bitset_container_t *container, ui #ifdef __cplusplus } } } // extern "C" { namespace roaring { namespace internal { #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif \ No newline at end of file diff --git a/src/containers/run.c b/src/containers/run.c index 8321c0d11..a6c36f4c0 100644 --- a/src/containers/run.c +++ b/src/containers/run.c @@ -10,7 +10,11 @@ #error "CROARING_COMPILER_SUPPORTS_AVX512 needs to be defined." #endif // CROARING_COMPILER_SUPPORTS_AVX512 #endif - +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#pragma GCC diagnostic ignored "-Wmaybe-uninitialized" +#endif #ifdef __cplusplus extern "C" { namespace roaring { namespace internal { #endif @@ -1065,3 +1069,6 @@ int run_container_cardinality(const run_container_t *run) { #ifdef __cplusplus } } } // extern "C" { namespace roaring { namespace internal { #endif +#if defined(__GNUC__) && !defined(__clang__) +#pragma GCC diagnostic pop +#endif \ No newline at end of file From 850caa2eb80d574eab159791e874ed51195a5d93 Mon Sep 17 00:00:00 2001 From: Daniel Lemire Date: Fri, 26 Jan 2024 10:01:02 -0500 Subject: [PATCH 9/9] other fixes --- CMakeLists.txt | 54 ++++++++++++++++++++++++------------------------- amalgamation.sh | 17 +++++++++------- 2 files changed, 36 insertions(+), 35 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index d70d36efa..828a6969c 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -115,50 +115,48 @@ if(ENABLE_ROARING_TESTS) endif() find_program(BASH bash) -# we assume write access to the source directory -option(ROARING_DISABLE_AMAL "Forcefully disable amalgamation tests" OFF) - -if(ENABLE_ROARING_TESTS AND BASH AND !ROARING_DISABLE_AMAL) +if(ENABLE_ROARING_TESTS AND BASH) + message(STATUS "Amalgamation tests enabled") set(CROARING_SINGLEHEADER_FILES - ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.c - ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.cpp - ${CMAKE_CURRENT_SOURCE_DIR}/roaring.c - ${CMAKE_CURRENT_SOURCE_DIR}/roaring.h - ${CMAKE_CURRENT_SOURCE_DIR}/roaring.hh + ${CMAKE_CURRENT_BINARY_DIR}/amalgamation_demo.c + ${CMAKE_CURRENT_BINARY_DIR}/amalgamation_demo.cpp + ${CMAKE_CURRENT_BINARY_DIR}/roaring.c + ${CMAKE_CURRENT_BINARY_DIR}/roaring.h + ${CMAKE_CURRENT_BINARY_DIR}/roaring.hh ) set_source_files_properties(${CROARING_SINGLEHEADER_FILES} PROPERTIES GENERATED TRUE) add_custom_command( OUTPUT ${CROARING_SINGLEHEADER_FILES} - COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh + COMMAND ${BASH} ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh ${CMAKE_CURRENT_BINARY_DIR} WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} - DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh ${CROARING_SINGLEHEADER_FILES} + DEPENDS ${CMAKE_CURRENT_SOURCE_DIR}/amalgamation.sh roaring ) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.c PROPERTIES LANGUAGE C CMAKE_C_STANDARD 11) - set_source_files_properties(${CMAKE_CURRENT_SOURCE_DIR}/amalgamation_demo.cpp PROPERTIES LANGUAGE CXX CXX_STANDARD 11) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/amalgamation_demo.c PROPERTIES LANGUAGE C CMAKE_C_STANDARD 11) + set_source_files_properties(${CMAKE_CURRENT_BINARY_DIR}/amalgamation_demo.cpp PROPERTIES LANGUAGE CXX CXX_STANDARD 11) add_custom_target(croaring-singleheader-files DEPENDS ${CROARING_SINGLEHEADER_FILES}) add_library(croaring-singleheader-include-source INTERFACE) - target_include_directories(croaring-singleheader-include-source INTERFACE $) + target_include_directories(croaring-singleheader-include-source INTERFACE $) add_dependencies(croaring-singleheader-include-source croaring-singleheader-files) - add_executable(amalgamate_demo $) + add_executable(amalgamate_demo $) target_link_libraries(amalgamate_demo croaring-singleheader-include-source) add_test(amalgamate_demo amalgamate_demo) - if(NOT MSVC) - add_library(croaring-singleheader-source-lib $) - target_include_directories(croaring-singleheader-source-lib PUBLIC $) - - add_executable(amalgamate_demo_cpp $) - target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source croaring-singleheader-source-lib) - if(ROARING_EXCEPTIONS) - target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=1) - else() - target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=0) - endif() - add_test(amalgamate_demo_cpp amalgamate_demo_cpp) - endif() + add_library(croaring-singleheader-source-lib $) + target_include_directories(croaring-singleheader-source-lib PUBLIC $) + + add_executable(amalgamate_demo_cpp $) + target_link_libraries(amalgamate_demo_cpp croaring-singleheader-include-source croaring-singleheader-source-lib) + if(ROARING_EXCEPTIONS) + target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=1) + else() + target_compile_definitions(amalgamate_demo_cpp PUBLIC ROARING_EXCEPTIONS=0) + endif() + add_test(amalgamate_demo_cpp amalgamate_demo_cpp) +else() + message(STATUS "Amalgamation tests disabled") endif() option(ENABLE_ROARING_MICROBENCHMARKS "Enable microbenchmarks" OFF) if(ENABLE_ROARING_MICROBENCHMARKS) diff --git a/amalgamation.sh b/amalgamation.sh index 9b01ae6dc..c17524aaf 100755 --- a/amalgamation.sh +++ b/amalgamation.sh @@ -5,6 +5,8 @@ ######################################################################## SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )" +DESTINATION=${1:-.} + case $SCRIPTPATH in (*\ *) echo "Path ($SCRIPTPATH) cannot contain whitespace"; exit 1 ;; esac @@ -141,7 +143,7 @@ echo "Creating ${AMAL_H}..." for h in ${ALL_PUBLIC_H}; do dofile $h done -} > "${AMAL_H}" +} > "${DESTINATION}/${AMAL_H}" echo "Creating ${AMAL_C}..." @@ -163,7 +165,7 @@ echo "Creating ${AMAL_C}..." for h in ${ALL_PRIVATE_H} ${ALL_PRIVATE_C}; do dofile $h done -} > "${AMAL_C}" +} > "${DESTINATION}/${AMAL_C}" echo "Creating ${DEMOC}..." @@ -214,7 +216,7 @@ int main() { return EXIT_SUCCESS; } ' -} > "${DEMOC}" +} > "${DESTINATION}/${DEMOC}" echo "Creating ${AMAL_HH}..." @@ -238,7 +240,7 @@ echo "Creating ${AMAL_HH}..." for hh in ${ALL_PUBLIC_HH}; do dofile $hh done -} > "${AMAL_HH}" +} > "${DESTINATION}/${AMAL_HH}" echo "Creating ${DEMOCPP}..." @@ -266,14 +268,14 @@ int main() { return 0; } ' -} > "${DEMOCPP}" +} > "${DESTINATION}/${DEMOCPP}" # Print out a directory listing of the output files and their sizes # newline -echo "Files have been written to current directory: $PWD " -ls -la ${AMAL_C} ${AMAL_H} ${AMAL_HH} ${DEMOC} ${DEMOCPP} +echo "Files have been written to ${DESTINATION} " +ls -la ${DESTINATION}/${AMAL_C} ${DESTINATION}/${AMAL_H} ${DESTINATION}/${AMAL_HH} ${DESTINATION}/${DEMOC} ${DESTINATION}/${DEMOCPP} newline CBIN=${DEMOC%%.*} @@ -281,6 +283,7 @@ CPPBIN=${DEMOCPP%%.*} echo "The interface is found in the file 'include/roaring/roaring.h'." newline +echo "Go to ${DESTINATION}/." echo "For C, try:" echo "cc -O3 -std=c11 -o ${CBIN} ${DEMOC} && ./${CBIN} " newline