Skip to content

Commit

Permalink
GCC9 comes with parallel STL, which can break the build
Browse files Browse the repository at this point in the history
  • Loading branch information
vbeffara committed Jan 17, 2020
1 parent 8d8eafe commit a5eee76
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 9 deletions.
13 changes: 13 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,19 @@ if (${COROUTINES_TS})
add_compile_options(-fcoroutines-ts)
endif ()

include(CheckIncludeFileCXX)
set (CMAKE_REQUIRED_INCLUDES ${CONAN_INCLUDE_DIRS_TBB})
set (CMAKE_REQUIRED_FLAGS "-L${CONAN_LIB_DIRS_TBB}")
set (CMAKE_REQUIRED_LIBRARIES ${CONAN_LIBS_TBB})
cmake_policy(SET CMP0075 NEW)
CHECK_INCLUDE_FILE_CXX(execution EXECUTION)
if (${EXECUTION})
message("Using native <execution> header")
add_compile_options(-DEXECUTION)
else()
message("Using parallel STL from Conan")
endif()

if (${COV})
add_compile_options(-g -O0 --coverage -fprofile-arcs -ftest-coverage)
add_link_options(--coverage -fprofile-arcs -ftest-coverage)
Expand Down
22 changes: 13 additions & 9 deletions tests/test_parallel.cpp
Original file line number Diff line number Diff line change
@@ -1,12 +1,16 @@
#include <functional>
#include <future>
#include <numeric>
#include <tbb/task_group.h>
#include <vb/util/misc.h>

#ifdef EXECUTION
#include <execution>
#else
#include <pstl/algorithm>
#include <pstl/execution>
#include <pstl/memory>
#include <pstl/numeric>
#include <tbb/task_group.h>
#include <vb/util/misc.h>
#endif

using namespace std;
using namespace vb;
Expand Down Expand Up @@ -128,45 +132,45 @@ auto main(int argc, char **argv) -> int {
timing(H, "Map+reduce | PSTL, transform+accumulate, execution::par", [=] {
vector<double> X(l);
std::iota(X.begin(), X.end(), 0);
std::transform(pstl::execution::par, X.begin(), X.end(), X.begin(), cost);
std::transform(execution::par, X.begin(), X.end(), X.begin(), cost);
double s = std::accumulate(X.begin(), X.end(), 0.0);
return s - int64_t(s);
});

timing(H, "Map+reduce | PSTL, transform+accumulate, execution::unseq", [=] {
vector<double> X(l);
std::iota(X.begin(), X.end(), 0);
std::transform(pstl::execution::unseq, X.begin(), X.end(), X.begin(), cost);
std::transform(execution::unseq, X.begin(), X.end(), X.begin(), cost);
double s = std::accumulate(X.begin(), X.end(), 0.0);
return s - int64_t(s);
});

timing(H, "Map+reduce | PSTL, transform+accumulate, execution::par_unseq", [=] {
vector<double> X(l);
std::iota(X.begin(), X.end(), 0);
std::transform(pstl::execution::par_unseq, X.begin(), X.end(), X.begin(), cost);
std::transform(execution::par_unseq, X.begin(), X.end(), X.begin(), cost);
double s = std::accumulate(X.begin(), X.end(), 0.0);
return s - int64_t(s);
});

timing(H, "Map+reduce | PSTL, transform_reduce, execution::par", [=] {
vector<double> X(l);
std::iota(X.begin(), X.end(), 0);
double s = std::transform_reduce(pstl::execution::par, begin(X), end(X), 0.0, std::plus<>(), cost);
double s = std::transform_reduce(execution::par, begin(X), end(X), 0.0, std::plus<>(), cost);
return s - int64_t(s);
});

timing(H, "Map+reduce | PSTL, transform_reduce, execution::unseq", [=] {
vector<double> X(l);
std::iota(X.begin(), X.end(), 0);
double s = std::transform_reduce(pstl::execution::unseq, begin(X), end(X), 0.0, std::plus<>(), cost);
double s = std::transform_reduce(execution::unseq, begin(X), end(X), 0.0, std::plus<>(), cost);
return s - int64_t(s);
});

timing(H, "Map+reduce | PSTL, transform_reduce, execution::par_unseq", [=] {
vector<double> X(l);
std::iota(X.begin(), X.end(), 0);
double s = std::transform_reduce(pstl::execution::par_unseq, begin(X), end(X), 0.0, std::plus<>(), cost);
double s = std::transform_reduce(execution::par_unseq, begin(X), end(X), 0.0, std::plus<>(), cost);
return s - int64_t(s);
});

Expand Down

0 comments on commit a5eee76

Please sign in to comment.