Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Integrate POOLSTL_STD_SUPPLEMENT. #1605

Merged
merged 2 commits into from
Feb 10, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
2 changes: 1 addition & 1 deletion test/hash/hash.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -290,7 +290,7 @@ const auto sha_5 = data_chunk(1'000'000_size, to_byte('a'));
constexpr auto alpha_count = 16'777'216_size;
constexpr auto long_alpha_size = alpha_size * alpha_count;
const auto alpha2 = to_array<alpha_size>("abcdefghbcdefghicdefghijdefghijkefghijklfghijklmghijklmnhijklmno");
const std_vector<long_hash> long_alpha(alpha2_count, alpha2);
const std_vector<long_hash> long_alpha(alpha_count, alpha2);
const auto long_alpha_data = pointer_cast<const uint8_t>(long_alpha.front().data());
const auto sha_6 = to_chunk(unsafe_array_cast<uint8_t, long_alpha_size>(long_alpha_data));
#endif // !HAVE_SLOW_TESTS
Expand Down
Loading