Commit 62a57e77 authored by Tiago Peixoto's avatar Tiago Peixoto
Browse files

Fix compilation error with clang and openmp

This fixes issue #289
parent 41471e3c
Pipeline #127 failed with stage
......@@ -2638,21 +2638,21 @@ void move_sweep(vector<BlockState>& states, vector<MEntries>& m_entries_r,
vector<int64_t>& vlist, vector<int64_t>& block_list,
bool deg_corr, bool dense, bool multigraph, double beta,
Eprop eweight, Vprop vweight, Graph& g, bool sequential,
bool parallel, bool random_move, double c, size_t nmerges,
Vprop merge_map, size_t niter, size_t B, bool verbose, RNG& rng,
double& S, size_t& nmoves)
bool parallel_enabled, bool random_move, double c,
size_t nmerges, Vprop merge_map, size_t niter, size_t B,
bool verbose, RNG& rng, double& S, size_t& nmoves)
{
typedef typename graph_traits<Graph>::vertex_descriptor vertex_t;
if (vlist.size() < 100)
parallel = false;
parallel_enabled = false;
nmoves = 0;
S = 0;
vector<rng_t*> rngs;
size_t num_threads = 1;
if (parallel)
if (parallel_enabled)
{
#ifdef USING_OPENMP
num_threads = omp_get_max_threads();
......@@ -2690,7 +2690,7 @@ void move_sweep(vector<BlockState>& states, vector<MEntries>& m_entries_r,
// used only if merging
gt_hash_set<vertex_t> past_moves;
vector<pair<vertex_t, double> > best_move;
if (nmerges > 0 || parallel)
if (nmerges > 0 || parallel_enabled)
best_move.resize(num_vertices(g), make_pair(vertex_t(0), numeric_limits<double>::max()));
std::uniform_int_distribution<size_t> s_rand(0, block_list.size() - 1);
......@@ -2699,17 +2699,17 @@ void move_sweep(vector<BlockState>& states, vector<MEntries>& m_entries_r,
for (size_t iter = 0; iter < niter; ++iter)
{
if (nmerges == 0 && !parallel)
if (nmerges == 0 && !parallel_enabled)
std::shuffle(vlist.begin(), vlist.end(), rng);
int i = 0, N = vlist.size();
#pragma omp parallel for default(shared) private(i) \
firstprivate(past_moves, m_entries) \
schedule(runtime) if (parallel)
schedule(runtime) if (parallel_enabled)
for (i = 0; i < N; ++i)
{
size_t tid = 0;
if (parallel)
if (parallel_enabled)
{
#ifdef USING_OPENMP
tid = omp_get_thread_num();
......@@ -2862,7 +2862,7 @@ void move_sweep(vector<BlockState>& states, vector<MEntries>& m_entries_r,
if (accept)
{
if (!parallel)
if (!parallel_enabled)
{
assert(b[v] == int(r));
move_vertex(v, s, b, cv, vmap, deg_corr, states,
......@@ -2884,7 +2884,7 @@ void move_sweep(vector<BlockState>& states, vector<MEntries>& m_entries_r,
}
}
if (parallel && (nmerges == 0))
if (parallel_enabled && (nmerges == 0))
{
for (vertex_t v : vlist)
{
......@@ -2910,7 +2910,7 @@ void move_sweep(vector<BlockState>& states, vector<MEntries>& m_entries_r,
}
}
if (parallel && (nmerges == 0))
if (parallel_enabled && (nmerges == 0))
{
for (auto r : rngs)
delete r;
......
......@@ -1287,7 +1287,7 @@ void move_sweep_overlap(vector<BlockState>& states,
VLprop cv, VVprop vmap, Vprop clabel,
vector<int64_t>& vlist, vector<int64_t>& block_list,
bool deg_corr, bool dense, bool multigraph, double beta,
Vprop vweight, Graph& g, bool sequential, bool parallel,
Vprop vweight, Graph& g, bool sequential, bool parallel_enabled,
bool random_move, double c, size_t niter, size_t B,
bool verbose, RNG& rng, double& S, size_t& nmoves)
{
......@@ -1297,11 +1297,11 @@ void move_sweep_overlap(vector<BlockState>& states,
S = 0;
if (vlist.size() < 100)
parallel = false;
parallel_enabled = false;
vector<pair<vertex_t, double> > best_move;
vector<rng_t*> rngs;
if (parallel)
if (parallel_enabled)
{
best_move.resize(num_vertices(g), make_pair(vertex_t(0), numeric_limits<double>::max()));
......@@ -1334,11 +1334,11 @@ void move_sweep_overlap(vector<BlockState>& states,
int i = 0, N = vlist.size();
#pragma omp parallel for default(shared) private(i) \
firstprivate(m_entries) schedule(runtime) if (parallel)
firstprivate(m_entries) schedule(runtime) if (parallel_enabled)
for (i = 0; i < N; ++i)
{
size_t tid = 0;
if (parallel)
if (parallel_enabled)
{
#ifdef USING_OPENMP
tid = omp_get_thread_num();
......@@ -1464,7 +1464,7 @@ void move_sweep_overlap(vector<BlockState>& states,
if (accept)
{
if (!parallel)
if (!parallel_enabled)
{
assert(b[v] == int(r));
......@@ -1488,7 +1488,7 @@ void move_sweep_overlap(vector<BlockState>& states,
}
}
if (parallel)
if (parallel_enabled)
{
for (vertex_t v : vlist)
{
......@@ -1512,7 +1512,7 @@ void move_sweep_overlap(vector<BlockState>& states,
}
}
if (parallel)
if (parallel_enabled)
{
for (auto r : rngs)
delete r;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment