From 5e72eb1b8d6d868513eb618215c18d47a76c9c5d Mon Sep 17 00:00:00 2001 From: Mikhail Karasikov Date: Mon, 16 Sep 2019 17:14:04 +0000 Subject: [PATCH 1/2] build with llvm --- CMakeLists.txt | 46 ++++++++++++++++++++++++++++++++++- cobs/query/classic_search.cpp | 6 ++--- src/main_performance.cpp | 4 +-- 3 files changed, 50 insertions(+), 6 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 891094e..e9da4bb 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -109,7 +109,51 @@ if(${Boost_FOUND}) set(COBS_LINK_LIBRARIES ${Boost_LIBRARIES} ${COBS_LINK_LIBRARIES}) endif() -set(COBS_LINK_LIBRARIES stdc++fs ${COBS_LINK_LIBRARIES}) +include(CheckCXXSourceRuns) +set(CMAKE_REQUIRED_FLAGS " -std=c++17") +check_cxx_source_runs(" + #include + #include + int main() { + std::cout << std::filesystem::temp_directory_path(); + return 0; + } +" CPPNOFS) +if(NOT CPPNOFS) + set(CMAKE_REQUIRED_FLAGS " -std=c++17") + set(CMAKE_REQUIRED_LIBRARIES "c++fs") + check_cxx_source_runs(" + #include + #include + int main() { + std::cout << std::filesystem::temp_directory_path(); + return 0; + } + " CPPFS) + unset(CMAKE_REQUIRED_FLAGS) + unset(CMAKE_REQUIRED_LIBRARIES) + if(CPPFS) + set(COBS_LINK_LIBRARIES c++fs ${COBS_LINK_LIBRARIES}) + else() + set(CMAKE_REQUIRED_FLAGS " -std=c++17") + set(CMAKE_REQUIRED_LIBRARIES "stdc++fs") + check_cxx_source_runs(" + #include + #include + int main() { + std::cout << std::filesystem::temp_directory_path(); + return 0; + } + " STDCPPFS) + unset(CMAKE_REQUIRED_FLAGS) + unset(CMAKE_REQUIRED_LIBRARIES) + if(STDCPPFS) + set(COBS_LINK_LIBRARIES stdc++fs ${COBS_LINK_LIBRARIES}) + else() + message(FATAL_ERROR "std::filesystem not found") + endif() + endif() +endif() ### use TLX ### diff --git a/cobs/query/classic_search.cpp b/cobs/query/classic_search.cpp index 390c4cb..f60908f 100644 --- a/cobs/query/classic_search.cpp +++ b/cobs/query/classic_search.cpp @@ -111,12 +111,12 @@ void ClassicSearch::compute_counts( const uint8_t* rows, size_t size, size_t buffer_size) { #if __SSE2__ - auto expansion_128 = reinterpret_cast(s_expansion_128); + auto expansion_128 = reinterpret_cast(s_expansion_128); #endif uint64_t num_hashes = index_file_.num_hashes(); #if __SSE2__ - auto counts_128 = reinterpret_cast<__m128i_u*>(scores); + auto counts_128 = reinterpret_cast<__m128i*>(scores); #else auto counts_64 = reinterpret_cast(scores); #endif @@ -264,7 +264,7 @@ const uint64_t ClassicSearch::s_expansion[] = { 281479271677952, 281479271677953, 281479271743488, 281479271743489 }; -const uint16_t ClassicSearch::s_expansion_128[] = { +alignas(16) const uint16_t ClassicSearch::s_expansion_128[] = { 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, 0, 0, 1, 0, 0, 0, 0, 0, 0, diff --git a/src/main_performance.cpp b/src/main_performance.cpp index 6e25c0a..9866323 100644 --- a/src/main_performance.cpp +++ b/src/main_performance.cpp @@ -289,7 +289,7 @@ const uint16_t expansion[] = { 1, 1, 1, 1, 1, 1, 1, 1 }; -const auto expansion_128 = reinterpret_cast(expansion); +const auto expansion_128 = reinterpret_cast(expansion); void compute_counts(size_t hashes_size, std::vector& counts, const uint8_t* rows, size_t row_size) { #pragma omp declare reduction (merge : std::vector : \ @@ -298,7 +298,7 @@ void compute_counts(size_t hashes_size, std::vector& counts, const uin #pragma omp parallel reduction(merge: counts) { // auto counts_64 = reinterpret_cast(counts.data()); - auto counts_128 = reinterpret_cast<__m128i_u*>(counts.data()); + auto counts_128 = reinterpret_cast<__m128i*>(counts.data()); #pragma omp for for (uint64_t i = 0; i < hashes_size; i += 1) { auto rows_8 = rows + i * row_size; From 63ba36f042c59e14f721018e68e36e20a8bf4936 Mon Sep 17 00:00:00 2001 From: Mikhail Karasikov Date: Mon, 4 Nov 2019 22:48:05 +0100 Subject: [PATCH 2/2] use experimental::filesystem This works only for old compilers... --- CMakeLists.txt | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index e9da4bb..1d577b7 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -113,9 +113,9 @@ include(CheckCXXSourceRuns) set(CMAKE_REQUIRED_FLAGS " -std=c++17") check_cxx_source_runs(" #include - #include + #include int main() { - std::cout << std::filesystem::temp_directory_path(); + std::cout << std::experimental::filesystem::temp_directory_path(); return 0; } " CPPNOFS) @@ -124,9 +124,9 @@ if(NOT CPPNOFS) set(CMAKE_REQUIRED_LIBRARIES "c++fs") check_cxx_source_runs(" #include - #include + #include int main() { - std::cout << std::filesystem::temp_directory_path(); + std::cout << std::experimental::filesystem::temp_directory_path(); return 0; } " CPPFS) @@ -139,9 +139,9 @@ if(NOT CPPNOFS) set(CMAKE_REQUIRED_LIBRARIES "stdc++fs") check_cxx_source_runs(" #include - #include + #include int main() { - std::cout << std::filesystem::temp_directory_path(); + std::cout << std::experimental::filesystem::temp_directory_path(); return 0; } " STDCPPFS) @@ -150,7 +150,7 @@ if(NOT CPPNOFS) if(STDCPPFS) set(COBS_LINK_LIBRARIES stdc++fs ${COBS_LINK_LIBRARIES}) else() - message(FATAL_ERROR "std::filesystem not found") + message(FATAL_ERROR "std::experimental::filesystem not found") endif() endif() endif()