Skip to content

Commit

Permalink
Merge pull request #384 from eseiler/feature/clang
Browse files Browse the repository at this point in the history
[FEATURE] Clang support
  • Loading branch information
eseiler committed Sep 29, 2023
2 parents 042c20d + be1a5bf commit fab4512
Show file tree
Hide file tree
Showing 13 changed files with 67 additions and 57 deletions.
18 changes: 14 additions & 4 deletions .github/workflows/ci_linux.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,29 @@ jobs:
fail-fast: false
matrix:
include:
- name: "clang17"
compiler: "clang-17"
build: unit
build_type: Release
cxx_flags: "-std=c++20"

- name: "gcc13"
compiler: "gcc-13"
build: unit
build_type: Release
cxx_flags: "-std=c++23"
cxx_flags: "-std=c++23 -Wno-interference-size"

- name: "gcc12"
compiler: "gcc-12"
build: unit
build_type: Release
cxx_flags: "-std=c++23"
cxx_flags: "-std=c++23 -Wno-interference-size"

- name: "gcc11"
compiler: "gcc-11"
build: unit
build_type: Release
cxx_flags: "-std=c++23"
cxx_flags: "-std=c++23 -Wno-interference-size"

steps:
- name: Checkout
Expand All @@ -63,6 +69,10 @@ jobs:
compiler: ${{ matrix.compiler }}
ccache_size: 150M

- name: Install OpenMP
if: contains(matrix.name, 'clang')
run: install libomp-17-dev

- name: Install CMake
uses: seqan/actions/setup-cmake@main
with:
Expand All @@ -73,7 +83,7 @@ jobs:
mkdir build
cd build
cmake ../raptor/test/${{ matrix.build }} -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }} -Wno-interference-size" \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}" \
-DRAPTOR_NATIVE_BUILD=OFF
make -j2 gtest_build
Expand Down
18 changes: 14 additions & 4 deletions .github/workflows/ci_sanitizer.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ env:
SHARG_NO_VERSION_CHECK: 1
TZ: Europe/Berlin
ASAN_OPTIONS: strict_string_checks=1:detect_stack_use_after_return=1:check_initialization_order=1:strict_init_order=1
TSAN_OPTIONS: ignore_noninstrumented_modules=1
UBSAN_OPTIONS: print_stacktrace=1

defaults:
Expand All @@ -32,13 +33,16 @@ jobs:
build_type: [Release, Debug]
include:
- name: "AddressSanitizer"
cxx_flags: "-std=c++23 -fno-omit-frame-pointer -fsanitize=address -Wno-maybe-uninitialized"
compiler: gcc-13
cxx_flags: "-std=c++23 -fno-omit-frame-pointer -fsanitize=address -Wno-maybe-uninitialized -Wno-interference-size"

- name: "ThreadSanitizer"
cxx_flags: "-std=c++23 -fno-omit-frame-pointer -fsanitize=thread"
compiler: clang-17
cxx_flags: "-std=c++20 -fno-omit-frame-pointer -fsanitize=thread"

- name: "UndefinedBehaviorSanitizer"
cxx_flags: "-std=c++23 -fno-omit-frame-pointer -fsanitize=undefined"
compiler: gcc-13
cxx_flags: "-std=c++23 -fno-omit-frame-pointer -fsanitize=undefined -Wno-interference-size"

steps:
- name: Checkout
Expand All @@ -53,6 +57,12 @@ jobs:
with:
compiler: gcc-13

- name: Install OpenMP
if: contains(matrix.name, 'clang')
run: |
install libomp-17-dev
echo "OMP_TOOL_LIBRARIES=/usr/lib/llvm-17/lib/libarcher.so" >> "$GITHUB_ENV"
- name: Configure OS
run: |
sudo bash -c "echo 0 > /proc/sys/vm/overcommit_memory"
Expand All @@ -68,7 +78,7 @@ jobs:
mkdir build
cd build
cmake ../raptor/test/unit -DCMAKE_BUILD_TYPE=${{ matrix.build_type }} \
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }} -Wno-interference-size"
-DCMAKE_CXX_FLAGS="${{ matrix.cxx_flags }}"
make -j2 gtest_build
- name: Build tests
Expand Down
13 changes: 8 additions & 5 deletions build_system/raptor-config.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -247,7 +247,8 @@ endif ()

check_cxx_compiler_flag ("-fopenmp-simd" RAPTOR_HAS_OPENMP_SIMD)
if (RAPTOR_HAS_OPENMP_SIMD)
set (RAPTOR_CXX_FLAGS "${RAPTOR_CXX_FLAGS} -fopenmp-simd -DSIMDE_ENABLE_OPENMP")
set (RAPTOR_CXX_FLAGS "${RAPTOR_CXX_FLAGS} -fopenmp-simd")
set (RAPTOR_DEFINITIONS ${RAPTOR_DEFINITIONS} "-DSIMDE_ENABLE_OPENMP")
raptor_config_print ("SIMD-OpenMP Support: via -fopenmp-simd")
else ()
raptor_config_print ("SIMD-OpenMP Support: not found")
Expand Down Expand Up @@ -290,10 +291,12 @@ endif ()
if (RAPTOR_IS_DEBUG)
raptor_config_print ("Link Time Optimization: disabled")
else ()
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set (RAPTOR_LTO_FLAGS "-flto=auto")
# CMake's check_ipo_supported uses hardcoded lto flags
# macOS GCC supports -flto-auto, but not the hardcoded flag "-fno-fat-lto-objects"
if ("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" AND NOT "${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
set (RAPTOR_LTO_FLAGS "-flto=auto -ffat-lto-objects")
else ()
set (RAPTOR_LTO_FLAGS "-flto=auto -fno-fat-lto-objects")
set (RAPTOR_LTO_FLAGS "-flto=auto")
endif ()

set (LTO_CMAKE_SOURCE
Expand Down Expand Up @@ -326,7 +329,7 @@ else ()
endif ()

option (RAPTOR_STRIP_BINARY "Enable binary-stripping. Not supported on macOS." ON)
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin")
if ("${CMAKE_SYSTEM_NAME}" MATCHES "Darwin" OR "${CMAKE_CXX_COMPILER_ID}" STREQUAL "Clang")
raptor_config_print ("Binary-stripping: not supported")
elseif (RAPTOR_IS_DEBUG OR NOT RAPTOR_STRIP_BINARY)
raptor_config_print ("Binary-stripping: disabled")
Expand Down
18 changes: 9 additions & 9 deletions include/raptor/argument_parsing/search_arguments.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -81,15 +81,15 @@ struct search_arguments

raptor::threshold::threshold_parameters make_threshold_parameters() const noexcept
{
return {.window_size{window_size},
.shape{shape},
.query_length{query_length},
.errors{errors},
.percentage{threshold},
.p_max{p_max},
.tau{tau},
.cache_thresholds{cache_thresholds},
.output_directory{index_file.parent_path()}};
return {.window_size = window_size,
.shape = shape,
.query_length = query_length,
.errors = errors,
.percentage = threshold,
.p_max = p_max,
.tau = tau,
.cache_thresholds = cache_thresholds,
.output_directory = index_file.parent_path()};
}
};

Expand Down
9 changes: 6 additions & 3 deletions include/raptor/build/index_factory.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,8 +31,8 @@ class index_factory
index_factory() = default;
index_factory(index_factory const &) = default;
index_factory(index_factory &&) = default;
index_factory & operator=(index_factory const &) = default;
index_factory & operator=(index_factory &&) = default;
index_factory & operator=(index_factory const &) = delete; // const member
index_factory & operator=(index_factory &&) = delete; // const member
~index_factory() = default;

explicit index_factory(build_arguments const & args) : arguments{std::addressof(args)}
Expand Down Expand Up @@ -76,11 +76,14 @@ class index_factory
seqan::hibf::serial_timer local_timer{};
auto & ibf = index.ibf();
local_timer.start();
for (auto && [file_names, bin_number] : zipped_view)
// https://godbolt.org/z/PeKnxzjn1
for (auto && zipped : zipped_view)
{
std::visit(
[&](auto const & reader)
{
auto && [file_names, bin_number] = zipped;

if (config == nullptr)
reader.hash_into(file_names, emplacer(ibf, seqan::hibf::bin_index{bin_number}));
else
Expand Down
4 changes: 4 additions & 0 deletions include/raptor/search/search_singular_ibf.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,11 @@ void search_singular_ibf(search_arguments const & arguments, index_t && index)
seqan::hibf::serial_timer local_query_ibf_timer{};
seqan::hibf::serial_timer local_generate_results_timer{};

#if defined(__clang__)
auto counter = [&index]()
#else
auto counter = [&index, is_ibf]()
#endif
{
if constexpr (is_ibf)
return index.ibf().template counting_agent<uint16_t>();
Expand Down
8 changes: 4 additions & 4 deletions include/raptor/search/sync_out.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,10 +26,10 @@ class sync_out
{
public:
sync_out() = default;
sync_out(sync_out const &) = default;
sync_out & operator=(sync_out const &) = default;
sync_out(sync_out &&) = default;
sync_out & operator=(sync_out &&) = default;
sync_out(sync_out const &) = delete; // std::ofstream
sync_out & operator=(sync_out const &) = delete; // std::ofstream
sync_out(sync_out &&) = delete; // std::mutex
sync_out & operator=(sync_out &&) = delete; // std::mutex
~sync_out() = default;

sync_out(search_arguments const & arguments) : file{arguments.out_file}
Expand Down
2 changes: 1 addition & 1 deletion src/layout/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@ cmake_minimum_required (VERSION 3.15)

if (NOT TARGET raptor_layout)
add_library ("raptor_layout" STATIC raptor_layout.cpp)

target_compile_options (chopper_layout_lib PRIVATE "-w")
target_link_libraries ("raptor_layout" PUBLIC "raptor_interface" "chopper_layout_lib" xxHash::xxhash)
endif ()
2 changes: 1 addition & 1 deletion test/include/raptor/test/cli_test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,7 @@ struct raptor_base : public cli_test
using strong_bool::value;
};

static inline auto const get_repeated_bins(size_t const repetitions) noexcept
static inline auto get_repeated_bins(size_t const repetitions) noexcept
{
using vec_t = std::vector<std::string>;

Expand Down
8 changes: 4 additions & 4 deletions test/include/raptor/test/tmp_test_file.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,10 @@ class tmp_test_file
{
public:
tmp_test_file() = default;
tmp_test_file(tmp_test_file const &) = default;
tmp_test_file & operator=(tmp_test_file const &) = default;
tmp_test_file(tmp_test_file &&) = default;
tmp_test_file & operator=(tmp_test_file &&) = default;
tmp_test_file(tmp_test_file const &) = delete;
tmp_test_file & operator=(tmp_test_file const &) = delete;
tmp_test_file(tmp_test_file &&) = delete;
tmp_test_file & operator=(tmp_test_file &&) = delete;
~tmp_test_file() = default;

template <typename... t>
Expand Down
14 changes: 0 additions & 14 deletions test/unit/cli/build/build_hibf_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,22 +7,12 @@

#include <raptor/test/cli_test.hpp>

#if defined(__SANITIZE_THREAD__)
# define RAPTOR_USES_TSAN true
#else
# define RAPTOR_USES_TSAN false
#endif

struct build_hibf : public raptor_base, public testing::WithParamInterface<std::tuple<size_t, size_t, bool>>
{};

TEST_P(build_hibf, with_file)
{
auto const [number_of_repeated_bins, window_size, run_parallel_tmp] = GetParam();

if (RAPTOR_USES_TSAN && run_parallel_tmp)
GTEST_SKIP() << "Threadsantizier + OpenMP causes false positives.";

bool const run_parallel = run_parallel_tmp && number_of_repeated_bins >= 32;

cli_test_result const result = execute_app("raptor",
Expand All @@ -47,10 +37,6 @@ TEST_P(build_hibf, with_file)
TEST_P(build_hibf, with_shape)
{
auto const [number_of_repeated_bins, window_size, run_parallel_tmp] = GetParam();

if (RAPTOR_USES_TSAN && run_parallel_tmp)
GTEST_SKIP() << "Threadsantizier + OpenMP causes false positives.";

bool const run_parallel = run_parallel_tmp && number_of_repeated_bins >= 32;

cli_test_result const result = execute_app("raptor",
Expand Down
8 changes: 1 addition & 7 deletions test/unit/cli/search/search_hibf_preprocessing_test.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@

#include <raptor/test/cli_test.hpp>

#if defined(__SANITIZE_THREAD__)
# define RAPTOR_USES_TSAN true
#else
# define RAPTOR_USES_TSAN false
#endif

struct search_hibf_preprocessing :
public raptor_base,
public testing::WithParamInterface<std::tuple<size_t, size_t, bool, size_t>>
Expand Down Expand Up @@ -74,7 +68,7 @@ TEST_P(search_hibf_preprocessing, pipeline)
cli_test_result const result2 = execute_app("raptor",
"build",
"--threads ",
(run_parallel && !RAPTOR_USES_TSAN) ? "2" : "1",
run_parallel ? "2" : "1",
"--output raptor.index",
"--quiet",
"--input raptor_cli_test.layout");
Expand Down

1 comment on commit fab4512

@vercel
Copy link

@vercel vercel bot commented on fab4512 Sep 29, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Successfully deployed to the following URLs:

raptor – ./

raptor-seqan.vercel.app
raptor-git-main-seqan.vercel.app
seqan-raptor.vercel.app

Please sign in to comment.