Skip to content

Commit

Permalink
#ifdef out random_shuffle deprecated in later c++
Browse files Browse the repository at this point in the history
  • Loading branch information
biddisco committed Dec 11, 2017
1 parent a0d73d2 commit 04ea962
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 0 deletions.
Expand Up @@ -18,6 +18,7 @@
#include <stdexcept>
#include <string>
#include <vector>
#include <utility>

#include "worker_timed.hpp"

Expand Down Expand Up @@ -183,10 +184,16 @@ int hpx_main(
payloads.push_back(payload);
}

#if defined(HPX_HAVE_CXX11_STD_SHUFFLE)
std::random_device random_device;
std::mt19937 generator(random_device());
std::shuffle(payloads.begin(), payloads.end(), std::move(generator));
#else
// Randomly shuffle the entire sequence to deal with drift.
using hpx::util::placeholders::_1;
std::random_shuffle(payloads.begin(), payloads.end(),
hpx::util::bind(&shuffler, std::ref(prng), _1));
#endif

///////////////////////////////////////////////////////////////////////
// Validate the payloads.
Expand Down
7 changes: 7 additions & 0 deletions tests/performance/local/print_heterogeneous_payloads.cpp
Expand Up @@ -20,6 +20,7 @@
#include <random>
#include <stdexcept>
#include <vector>
#include <utility>

using boost::program_options::variables_map;
using boost::program_options::options_description;
Expand Down Expand Up @@ -137,8 +138,14 @@ int app_main(
}

// Randomly shuffle the entire sequence to deal with drift.
#if defined(HPX_HAVE_CXX11_STD_SHUFFLE)
std::random_device random_device;
std::mt19937 generator(random_device());
std::shuffle(payloads.begin(), payloads.end(), std::move(generator));
#else
std::random_shuffle(payloads.begin(), payloads.end(),
boost::bind(&shuffler, std::ref(prng), _1));
#endif

///////////////////////////////////////////////////////////////////////
// Validate the payloads.
Expand Down
Expand Up @@ -45,6 +45,7 @@
#include <stdexcept>
#include <string>
#include <vector>
#include <utility>

#include <qthread/qthread.h>

Expand Down Expand Up @@ -216,9 +217,15 @@ int qthreads_main(
}

// Randomly shuffle the entire sequence to deal with drift.
#if defined(HPX_HAVE_CXX11_STD_SHUFFLE)
std::random_device random_device;
std::mt19937 generator(random_device());
std::shuffle(payloads.begin(), payloads.end(), std::move(generator));
#else
using hpx::util::placeholders::_1;
std::random_shuffle(payloads.begin(), payloads.end(),
hpx::util::bind(&shuffler, std::ref(prng), _1));
#endif

///////////////////////////////////////////////////////////////////////
// Validate the payloads.
Expand Down

0 comments on commit 04ea962

Please sign in to comment.