From be8dc130b6f872aae1a26f51d24212e11dcf517b Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 3 Feb 2020 15:30:10 -0500 Subject: replace openmp parallelization with std::foreach --- hadamard_pt.hpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/hadamard_pt.hpp b/hadamard_pt.hpp index 8d0a1f7..f07c9ec 100644 --- a/hadamard_pt.hpp +++ b/hadamard_pt.hpp @@ -2,6 +2,7 @@ #pragma once #include "hadamard_mcmc.hpp" #include +#include void swap(MCMC& s1, MCMC& s2) { std::swap(s1.M, s2.M); @@ -68,10 +69,7 @@ public: std::vector nd(Ms.size(), 0); for (unsigned i = 0; i < n; i++) { -#pragma omp parallel for - for (unsigned j = 0; j < Ms.size(); j++) { - Ms[j].tune(m, ε); - } + std::for_each(std::execution::par_unseq, Ms.begin(), Ms.end(), [m, ε](MCMC& M) {M.tune(m, ε);}); for (unsigned k = 0; k < m * Ms.size(); k++) { unsigned j = rng.uniform((unsigned)0, (unsigned)(Ms.size() - 2)); @@ -151,10 +149,7 @@ public: void run(unsigned n, unsigned m, bool dry = false) { for (unsigned i = 0; i < n; i++) { -#pragma omp parallel for - for (unsigned j = 0; j < Ms.size(); j++) { - Ms[j].run(m, dry); - } + std::for_each(std::execution::par_unseq, Ms.begin(), Ms.end(), [m, dry](MCMC& M) {M.run(m, dry);}); for (unsigned j = 0; j < Ms.size(); j++) { unsigned k = rng.uniform((unsigned)0, (unsigned)(Ms.size() - 2)); this->step(k, k + 1, dry); -- cgit v1.2.3-70-g09d2