Skip to content

Commit

Permalink
Support C++20 build
Browse files Browse the repository at this point in the history
This is only so far tested on GCC 12, and benchmarks must be turned off,
as Google Benchmark complains. Needs to be addressed separately.
  • Loading branch information
elshize committed Jan 27, 2023
1 parent f05cd02 commit f8739ab
Show file tree
Hide file tree
Showing 17 changed files with 90 additions and 48 deletions.
14 changes: 7 additions & 7 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,13 +11,11 @@ jobs:
runs-on: ubuntu-18.04
strategy:
matrix:
name: [gcc9, gcc10, gcc11, gcc12, clang11]
compiler: [gcc9, gcc10, gcc11, gcc12, clang11]
standard: [17]
include:
- name: gcc9
- name: gcc10
- name: gcc11
- name: gcc12
- name: clang11
- compiler: gcc12 # Extra test for C++20
standard: 20

steps:
- uses: actions/checkout@v2
Expand All @@ -26,7 +24,9 @@ jobs:

- name: Bulid docker image
shell: bash
run: docker build -t pisa -f- . < "${{runner.workspace}}/pisa/test/docker/${{matrix.name}}/Dockerfile"
run: |
docker build --build-arg CXX_STANDARD=${{matrix.standard}} \
-t pisa -f- . < "${{runner.workspace}}/pisa/test/docker/${{matrix.compiler}}/Dockerfile"
- name: Test
shell: bash
Expand Down
4 changes: 3 additions & 1 deletion CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,9 @@ cmake_policy(SET CMP0074 NEW)

project(PISA CXX C)

set(CMAKE_CXX_STANDARD 17)
if(NOT CMAKE_CXX_STANDARD)
set(CMAKE_CXX_STANDARD 17)
endif()
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

Expand Down
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,8 @@ resources:
3. The [documentation](https://pisa.readthedocs.io/en/latest/).
4. Drop in to our [Slack channel](https://join.slack.com/t/pisa-engine/shared_invite/zt-dbxrm1mf-RtQMZTqxxlhOJsv3GHUErw) and say hi!

## Contributing

If you want to get involved with PISA, please check out our [Contributing](https://github.com/pisa-engine/pisa/blob/master/.github/CONTRIBUTING.md) page.


Expand Down
5 changes: 3 additions & 2 deletions docs/source/getting_started.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,9 @@

### Requirements

Our continuous integration pipeline compiles PISA and runs tests in the
following configurations:
To compile PISA, you will need a compiler supporting at least the C++17
standard. Our continuous integration pipeline compiles PISA and runs
tests in the following configurations:
- Linux:
- GCC, versions: 9, 10, 11, 12
- Clang 11
Expand Down
1 change: 1 addition & 0 deletions external/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,7 @@ target_compile_options(fmt INTERFACE -Wno-deprecated-declarations)
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/spdlog)

# Add range-v3
set(RANGES_CXX_STD ${CMAKE_CXX_STANDARD})
add_subdirectory(${CMAKE_CURRENT_SOURCE_DIR}/range-v3)

# Add RapidCheck
Expand Down
2 changes: 0 additions & 2 deletions include/pisa/codec/varintgb.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@

#include "codec/block_codecs.hpp"

using namespace std;

namespace pisa {

template <bool delta = false>
Expand Down
11 changes: 6 additions & 5 deletions src/sharding.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

#include <range/v3/action/shuffle.hpp>
#include <range/v3/algorithm/for_each.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/chunk.hpp>
#include <range/v3/view/iota.hpp>
#include <range/v3/view/take.hpp>
Expand Down Expand Up @@ -97,8 +98,8 @@ auto mapping_from_files(std::string const& full_titles, gsl::span<std::string co
}
shard_is.push_back(std::make_unique<std::ifstream>(shard_file));
}
auto title_files =
shard_is | ranges::views::transform([](auto& is) { return is.get(); }) | ranges::to_vector;
auto title_files = shard_is | ranges::views::transform([](auto& is) { return is.get(); })
| ranges::to<std::vector>();
return mapping_from_files(&fis, gsl::make_span(title_files));
}

Expand All @@ -109,8 +110,8 @@ auto create_random_mapping(int document_count, int shard_count, std::optional<st
std::mt19937 g(seed.value_or(rd()));
VecMap<Document_Id, Shard_Id> mapping(document_count);
auto shard_size = ceil_div(document_count, shard_count);
auto documents = ranges::views::iota(0_d, Document_Id{document_count}) | ranges::to_vector
| ranges::actions::shuffle(g);
auto documents = ranges::views::iota(0_d, Document_Id{document_count})
| ranges::to<std::vector> | ranges::actions::shuffle(g);

ranges::for_each(
ranges::views::zip(
Expand Down Expand Up @@ -259,7 +260,7 @@ void partition_fwd_index(
{
auto terms = read_string_vec_map<Term_Id>(fmt::format("{}.terms", input_basename));
auto shard_count = *std::max_element(mapping.begin(), mapping.end()) + 1;
auto shard_ids = ranges::views::iota(0_s, shard_count) | ranges::to_vector;
auto shard_ids = ranges::views::iota(0_s, shard_count) | ranges::to<std::vector>();
rearrange_sequences(input_basename, output_basename, mapping, shard_count);
spdlog::info("Remapping shards");
pisa::for_each(pisa::execution::par_unseq, shard_ids.begin(), shard_ids.end(), [&](auto&& id) {
Expand Down
7 changes: 6 additions & 1 deletion test/docker/clang11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ RUN apt-get update -y && apt-get install -y --no-install-recommends \
COPY . /pisa
RUN mkdir /pisa/build
WORKDIR /pisa/build
RUN cmake -DCMAKE_BUILD_TYPE='Debug' -DPISA_BUILD_TOOLS='OFF' -DCMAKE_TOOLCHAIN_FILE='clang.cmake' .. \
RUN cmake \
-DCMAKE_BUILD_TYPE='Debug' \
-DPISA_BUILD_TOOLS='OFF' \
-DPISA_ENABLE_BENCHMARKING='OFF' \
-DCMAKE_TOOLCHAIN_FILE='clang.cmake' \
.. \
&& cmake --build . --config Debug -- -j 4

CMD ["ctest", "-VV", "-j", "4"]
17 changes: 17 additions & 0 deletions test/docker/cmake-3.25.2-SHA-256.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
82ef7846809a6cfe282a6196b300b081ff7878e40065c1d530352f8f7a2a0c2d cmake-3.25.2-files-v1.json
73a35cab2174a3eb8f35083d55c80871185dc3808f3dae3558cd5fbdb29a4614 cmake-3.25.2-linux-aarch64.sh
9216ecf0449ade700e66e0def11eeaebf9fa7d4428c02f49cb59f11418d3f8a5 cmake-3.25.2-linux-aarch64.tar.gz
4d98de8d605da676e71a889dd94f80c76abb377fade2f21e3510e62ece1e1ada cmake-3.25.2-linux-x86_64.sh
783da74f132fd1fea91b8236d267efa4df5b91c5eec1dea0a87f0cf233748d99 cmake-3.25.2-linux-x86_64.tar.gz
644f104ae744df582b54ae47a8188bedacadd67dd996d70caa8159a47feb8749 cmake-3.25.2-macos-universal.dmg
0b5def3f77617b2ce0ec6701f96e4123a7b14bd0b8a5674ab0556c364ff7cb52 cmake-3.25.2-macos-universal.tar.gz
1851eb7a824ec380ce5edeaa46b3ba568d6572965fb9d31b2ea6f1ef0a09ecea cmake-3.25.2-macos10.10-universal.dmg
a988e2a69c1d105987f12782ee0fa80d6be941b3e1a68b4bd6a661f0fdb56d75 cmake-3.25.2-macos10.10-universal.tar.gz
2fd16ceebd64be763b9c18025159ab5c5c4d484a8021e60f80ef720803063472 cmake-3.25.2-windows-arm64.msi
c54fb253ae184b391d5366b958c38b282d5f9b6a5854643c28e6887f5fd92590 cmake-3.25.2-windows-arm64.zip
61cb3f71b1fb8ca342b723e1b18e9c4957b8c7094b5667075b8cb0309087e5b8 cmake-3.25.2-windows-i386.msi
833abaa21bb673491def058cc38834fbd606d525ab271f37a3b8a3aed586c4a0 cmake-3.25.2-windows-i386.zip
f91867471b4ae59efd79eaea63a374193b377b5372c45d78ca5f899243560089 cmake-3.25.2-windows-x86_64.msi
0db9d3cebf894f64751141253fb9d9e310f325e2e03044f61249a359d6adf301 cmake-3.25.2-windows-x86_64.zip
c026f22cb931dd532f648f087d587f07a1843c6e66a3dfca4fb0ea21944ed33c cmake-3.25.2.tar.gz
2781c207c3c64ea8a829b8fc0229374fc874b68fb1264cff99055e5bce79bbae cmake-3.25.2.zip
13 changes: 7 additions & 6 deletions test/docker/gcc10/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ FROM gcc:10
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York

RUN apt-get update -y && apt-get install -y --no-install-recommends \
cmake=3.13.* \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY . /pisa
RUN ./pisa/test/docker/install-cmake.sh

RUN mkdir /pisa/build
WORKDIR /pisa/build
RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \
RUN cmake \
"-DCMAKE_BUILD_TYPE=Debug" \
"-DPISA_BUILD_TOOLS=OFF" \
"-DPISA_ENABLE_BENCHMARKING=OFF" \
.. \
&& cmake --build . --config Debug -- -j 4

CMD ["ctest", "-VV", "-j", "4"]
13 changes: 7 additions & 6 deletions test/docker/gcc11/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ FROM gcc:11
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York

RUN apt-get update -y && apt-get install -y --no-install-recommends \
cmake=3.18.* \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY . /pisa
RUN ./pisa/test/docker/install-cmake.sh

RUN mkdir /pisa/build
WORKDIR /pisa/build
RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \
RUN cmake \
"-DCMAKE_BUILD_TYPE=Debug" \
"-DPISA_BUILD_TOOLS=OFF" \
"-DPISA_ENABLE_BENCHMARKING=OFF" \
.. \
&& cmake --build . --config Debug -- -j 4

CMD ["ctest", "-VV", "-j", "4"]
16 changes: 10 additions & 6 deletions test/docker/gcc12/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,17 +1,21 @@
FROM gcc:12

ARG CXX_STANDARD=17

ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York

RUN apt-get update -y && apt-get install -y --no-install-recommends \
cmake=3.18.* \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY . /pisa
RUN ./pisa/test/docker/install-cmake.sh

RUN mkdir /pisa/build
WORKDIR /pisa/build
RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \
RUN cmake \
"-DCMAKE_BUILD_TYPE=Debug" \
"-DPISA_BUILD_TOOLS=OFF" \
"-DPISA_ENABLE_BENCHMARKING=OFF" \
"-DCMAKE_CXX_STANDARD=$CXX_STANDARD" \
.. \
&& cmake --build . --config Debug -- -j 4

CMD ["ctest", "-VV", "-j", "4"]
13 changes: 7 additions & 6 deletions test/docker/gcc9/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,16 @@ FROM gcc:9
ENV DEBIAN_FRONTEND=noninteractive
ENV TZ=America/New_York

RUN apt-get update -y && apt-get install -y --no-install-recommends \
cmake=3.13.* \
&& apt-get clean \
&& rm -rf /var/lib/apt/lists/*

COPY . /pisa
RUN ./pisa/test/docker/install-cmake.sh

RUN mkdir /pisa/build
WORKDIR /pisa/build
RUN cmake "-DCMAKE_BUILD_TYPE=Debug" "-DPISA_BUILD_TOOLS=OFF" .. \
RUN cmake \
"-DCMAKE_BUILD_TYPE=Debug" \
"-DPISA_BUILD_TOOLS=OFF" \
"-DPISA_ENABLE_BENCHMARKING=OFF" \
.. \
&& cmake --build . --config Debug -- -j 4

CMD ["ctest", "-VV", "-j", "4"]
6 changes: 6 additions & 0 deletions test/docker/install-cmake.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
#!/usr/bin/env bash
wget -q 'https://github.com/Kitware/CMake/releases/download/v3.25.2/cmake-3.25.2-linux-x86_64.tar.gz'
sha256sum -c '/pisa/test/docker/cmake-3.25.2-SHA-256.txt' --ignore-missing
tar -xzvf 'cmake-3.25.2-linux-x86_64.tar.gz'
cp cmake-3.25.2-linux-x86_64/bin/* '/usr/local/bin'
cp -r 'cmake-3.25.2-linux-x86_64/share/cmake-3.25' '/usr/local/share'
3 changes: 2 additions & 1 deletion test/test_bmw_queries.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#define CATCH_CONFIG_MAIN
#include "catch2/catch.hpp"

#include <memory>
#include <unordered_map>

#include "test_common.hpp"
Expand Down Expand Up @@ -70,7 +71,7 @@ struct IndexData {
};

template <typename Index>
std::unordered_map<std::string, unique_ptr<IndexData<Index>>> IndexData<Index>::data = {};
std::unordered_map<std::string, std::unique_ptr<IndexData<Index>>> IndexData<Index>::data = {};

template <typename Wand>
auto test(Wand& wdata, std::string const& s_name)
Expand Down
9 changes: 5 additions & 4 deletions test/test_partition_fwd_index.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include <gsl/span>
#include <range/v3/action/transform.hpp>
#include <range/v3/algorithm/stable_sort.hpp>
#include <range/v3/range/conversion.hpp>
#include <range/v3/view/drop.hpp>
#include <range/v3/view/iota.hpp>
#include <range/v3/view/stride.hpp>
Expand Down Expand Up @@ -82,8 +83,8 @@ TEST_CASE("mapping_from_files", "[invert][unit]")
shards.push_back(std::make_unique<std::istringstream>("D00\nD01\nD02"));
shards.push_back(std::make_unique<std::istringstream>("D02\nD03\nD04"));
shards.push_back(std::make_unique<std::istringstream>("D06\nD07\nD08\nD09\nD010\nD11"));
auto stream_pointers =
ranges::views::transform(shards, [](auto const& s) { return s.get(); }) | ranges::to_vector;
auto stream_pointers = ranges::views::transform(shards, [](auto const& s) { return s.get(); })
| ranges::to<std::vector>();
REQUIRE(
mapping_from_files(&full, gsl::span<std::istream*>(stream_pointers)).as_vector()
== std::vector<Shard_Id>{0_s, 0_s, 0_s, 1_s, 1_s, 0_s, 2_s, 2_s, 2_s, 2_s, 2_s, 2_s});
Expand All @@ -103,7 +104,7 @@ TEST_CASE("create_random_mapping", "[invert][unit]")

REQUIRE(
documents.as_vector()
== ranges::to_vector(ranges::views::iota(Document_Id{}, Document_Id{1000U})));
== ranges::to<std::vector>(ranges::views::iota(Document_Id{}, Document_Id{1000U})));
REQUIRE(
counts.as_vector() == std::vector<int>{77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 77, 76});
}
Expand Down Expand Up @@ -211,7 +212,7 @@ TEST_CASE("Rearrange sequences", "[invert][integration]")
expected =
ranges::views::transform(
sorted_mapping, [&](auto&& entry) { return expected[entry.first.as_int()]; })
| ranges::to_vector;
| ranges::to<std::vector>();

auto pos = expected.begin();
for (auto shard: shard_ids) {
Expand Down
2 changes: 1 addition & 1 deletion test/test_ranked_queries.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ struct IndexData {
};

template <typename Index>
std::unordered_map<std::string, unique_ptr<IndexData<Index>>> IndexData<Index>::data = {};
std::unordered_map<std::string, std::unique_ptr<IndexData<Index>>> IndexData<Index>::data = {};

template <typename Acc>
class ranked_or_taat_query_acc: public ranked_or_taat_query {
Expand Down

0 comments on commit f8739ab

Please sign in to comment.