Skip to content

Commit

Permalink
Integrate POOLSTL_STD_SUPPLEMENT.
Browse files Browse the repository at this point in the history
  • Loading branch information
evoskuil committed Feb 10, 2025
1 parent 4426565 commit ce54e11
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 43 deletions.
12 changes: 0 additions & 12 deletions include/bitcoin/system/define.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,4 @@ namespace bc = libbitcoin;
namespace libbitcoin { constexpr auto with_arm = false; };
#endif

/// Workarounds for C++ noncompliance.
/// ---------------------------------------------------------------------------

/// C++17 (partial), see HAVE_EXECUTION.
#if defined(HAVE_EXECUTION)
namespace libbitcoin { constexpr auto par_unseq = std::execution::par_unseq; }
namespace libbitcoin { constexpr auto seq = std::execution::seq; }
#else
namespace libbitcoin { constexpr auto par_unseq = false; }
namespace libbitcoin { constexpr auto seq = false; }
#endif

#endif
10 changes: 0 additions & 10 deletions include/bitcoin/system/have.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -204,16 +204,6 @@
#endif
#endif

/// None on xcode.
/// Requires link with -ltbb on gcc (v9).
/// Experimental on clang (libcxx.llvm.org/Status/PSTL.html), requires:
/// -fexperimental-library
#if defined(HAVE_CPP17)
#if defined(HAVE_MSC)
#define HAVE_EXECUTION
#endif
#endif

/// These are manually configured here.
/// ---------------------------------------------------------------------------

Expand Down
6 changes: 3 additions & 3 deletions include/bitcoin/system/impl/hash/scrypt.ipp
Original file line number Diff line number Diff line change
Expand Up @@ -45,9 +45,9 @@ CONSTEVAL auto& CLASS::
concurrency() NOEXCEPT
{
if constexpr (Concurrent)
return bc::par_unseq;
return poolstl::execution::par;
else
return bc::seq;
return poolstl::execution::seq;
}

// protected
Expand Down Expand Up @@ -499,7 +499,7 @@ CLASS::hash(data_array<Size>& out, const data_slice& password,
// B[i] = scryptROMix (r, B[i], N)
// end for
std::atomic_bool success{ true };
std_for_each(concurrency(), prblocks.begin(), prblocks.end(),
std::for_each(concurrency(), prblocks.begin(), prblocks.end(),
[&](rblock_t& rblock) NOEXCEPT
{
success = success && romix(rblock);
Expand Down
21 changes: 6 additions & 15 deletions include/bitcoin/system/preprocessor.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -212,21 +212,12 @@
#define FALLTHROUGH [[fallthrough]]

/// C++17 (partial)
#if defined(HAVE_EXECUTION)
#include <execution>
#define std_any_of(p, b, e, l) std::any_of((p), (b), (e), (l))
#define std_all_of(p, b, e, l) std::all_of((p), (b), (e), (l))
#define std_for_each(p, b, e, l) std::for_each((p), (b), (e), (l))
#define std_reduce(p, b, e, i, l) std::reduce((p), (b), (e), (i), (l))
#define std_transform(p, b, e, t, l) std::transform((p), (b), (e), (t), (l))
#else
#include <bitcoin/system/execution.hpp>
#define std_any_of(p, b, e, l) std::any_of((b), (e), (l))
#define std_all_of(p, b, e, l) std::all_of((b), (e), (l))
#define std_for_each(p, b, e, l) std::for_each((b), (e), (l))
#define std_reduce(p, b, e, i, l) std::reduce((b), (e), (i), (l))
#define std_transform(p, b, e, t, l) std::transform((b), (e), (t), (l))
#endif
/// None on xcode.
/// Requires link with -ltbb on gcc (v9).
/// Experimental on clang (libcxx.llvm.org/Status/PSTL.html), requires:
/// -fexperimental-library
/// using poolstl, do not include <execution>.
#include <bitcoin/system/execution.hpp>

/// C++20 (partial)
#if defined(HAVE_CONSTEVAL)
Expand Down
6 changes: 3 additions & 3 deletions test/hacks.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "test.hpp"
#include <utility>

#if defined(DISABLED) && defined(HAVE_EXECUTION)
#if defined(DISABLED)

BOOST_AUTO_TEST_SUITE(skip_parser_tests)

Expand Down Expand Up @@ -274,7 +274,7 @@ BOOST_AUTO_TEST_CASE(skip_parser__skip_parse_concurrent_tx__factor__expected)

for (size_t i = 0; i < factor; ++i)
{
std::for_each(std::execution::par_unseq, jobs.begin(), jobs.end(),
std::for_each(poolstl::execution::par, jobs.begin(), jobs.end(),
[&](const auto job)
{
if (job)
Expand All @@ -299,7 +299,7 @@ BOOST_AUTO_TEST_CASE(skip_parser__skip_parse_concurrent_block__factor_txs__expec
const auto expected1 = bitcoin_hash(tx_2);
constexpr std_array<bool, factor> jobs{};

std::for_each(std::execution::par_unseq, jobs.begin(), jobs.end(),
std::for_each(poolstl::execution::par, jobs.begin(), jobs.end(),
[&](const auto)
{
stream::in::copy input(tx_2);
Expand Down

0 comments on commit ce54e11

Please sign in to comment.