aboutsummaryrefslogtreecommitdiff
path: root/Carpet/LoopControl/src
diff options
context:
space:
mode:
authorErik Schnetter <schnetter@gmail.com>2013-02-09 11:09:31 -0500
committerErik Schnetter <schnetter@gmail.com>2013-02-09 11:09:31 -0500
commit9337f7fb9840b44bdbcda401f50f06b1ec3a68dc (patch)
tree272731d75ceff15248b770db2ea0bc713d10811f /Carpet/LoopControl/src
parentb4277735d56ae023bd52bc19214d5a6280ce932f (diff)
LoopControl: Correct parallelisation errors (mark variables volatile)
Diffstat (limited to 'Carpet/LoopControl/src')
-rw-r--r--Carpet/LoopControl/src/loopcontrol.cc12
1 files changed, 6 insertions, 6 deletions
diff --git a/Carpet/LoopControl/src/loopcontrol.cc b/Carpet/LoopControl/src/loopcontrol.cc
index 95165e754..9d9a30130 100644
--- a/Carpet/LoopControl/src/loopcontrol.cc
+++ b/Carpet/LoopControl/src/loopcontrol.cc
@@ -67,14 +67,14 @@ using namespace std;
struct lc_thread_info_t {
char padding1[128]; // pad to ensure cache lines are not shared
- int idx; // linear index of next coarse thread block
+ volatile int idx; // linear index of next coarse thread block
char padding2[128];
};
struct lc_fine_thread_comm_t {
char padding1[128]; // pad to ensure cache lines are not shared
- int state; // waiting threads
- int value; // broadcast value
+ volatile int state; // waiting threads
+ volatile int value; // broadcast value
char padding2[128];
};
@@ -315,7 +315,7 @@ namespace {
}
// Wait until *ptr is different from old_value
- void thread_wait(int const *const ptr, int const old_value)
+ void thread_wait(volatile int const *const ptr, int const old_value)
{
while (*ptr == old_value) {
#pragma omp flush
@@ -340,7 +340,7 @@ namespace {
#pragma omp flush
for (;;) {
int const state = comm->state;
- if (comm->state == all_threads_mask) break;
+ if (state == all_threads_mask) break;
thread_wait(&comm->state, state);
}
// mark the value as invalid
@@ -361,7 +361,7 @@ namespace {
#pragma omp flush
for (;;) {
int const state = comm->state;
- if ((comm->state & (master_mask | thread_mask)) == master_mask) break;
+ if ((state & (master_mask | thread_mask)) == master_mask) break;
thread_wait(&comm->state, state);
}
// read value