Skip to content

Commit

Permalink
Fix some real and imagined data races.
Browse files Browse the repository at this point in the history
  • Loading branch information
devinamatthews committed Dec 1, 2016
1 parent 0cd23e6 commit 1b18083
Show file tree
Hide file tree
Showing 7 changed files with 24 additions and 11 deletions.
4 changes: 2 additions & 2 deletions src/external/tci/src/barrier.c
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ int tci_barrier_node_destroy(tci_barrier_node_t* barrier)

int tci_barrier_node_wait(tci_barrier_node_t* barrier)
{
const unsigned old_step = barrier->step;
const unsigned old_step = __sync_fetch_and_add(&barrier->step, 0);

if (__sync_add_and_fetch(&barrier->nwaiting, 1) == barrier->nchildren)
{
Expand All @@ -63,7 +63,7 @@ int tci_barrier_node_wait(tci_barrier_node_t* barrier)
}
else
{
while (barrier->step == old_step) tci_yield();
while (__sync_fetch_and_add(&barrier->step, 0) == old_step) tci_yield();
}

return 0;
Expand Down
2 changes: 1 addition & 1 deletion src/internal/1m/dot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void dot(const communicator& comm, const config& cfg, len_type m, len_type n,

len_type dummy;
reduce(comm, REDUCE_SUM, local_result, dummy);
result = local_result;
if (comm.master()) result = local_result;
}

#define FOREACH_TYPE(T) \
Expand Down
8 changes: 6 additions & 2 deletions src/internal/1m/reduce.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,12 @@ void reduce(const communicator& comm, const config& cfg, reduce_t op,
}

reduce(comm, op, local_result, local_idx);
result = local_result;
idx = local_idx;

if (comm.master())
{
result = local_result;
idx = local_idx;
}
}

#define FOREACH_TYPE(T) \
Expand Down
3 changes: 2 additions & 1 deletion src/internal/1t/dot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ void dot(const communicator& comm, const config& cfg,

len_type dummy = 0;
reduce(comm, REDUCE_SUM, local_result, dummy);
result = (conj_A ? conj(local_result) : local_result);
if (comm.master())
result = (conj_A ? conj(local_result) : local_result);
}

#define FOREACH_TYPE(T) \
Expand Down
8 changes: 6 additions & 2 deletions src/internal/1t/reduce.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -67,8 +67,12 @@ void reduce(const communicator& comm, const config& cfg, reduce_t op,
}

reduce(comm, op, local_result, local_idx);
result = local_result;
idx = local_idx;

if (comm.master())
{
result = local_result;
idx = local_idx;
}
}

#define FOREACH_TYPE(T) \
Expand Down
2 changes: 1 addition & 1 deletion src/internal/1v/dot.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ void dot(const communicator& comm, const config& cfg, len_type n,

len_type dummy;
reduce(comm, REDUCE_SUM, local_result, dummy);
result = local_result;
if (comm.master()) result = local_result;
}

#define FOREACH_TYPE(T) \
Expand Down
8 changes: 6 additions & 2 deletions src/internal/1v/reduce.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,12 @@ void reduce(const communicator& comm, const config& cfg, reduce_t op, len_type n
A + n_min*inc_A, inc_A, local_result, local_idx);

reduce(comm, op, local_result, local_idx);
result = local_result;
idx = local_idx;

if (comm.master())
{
result = local_result;
idx = local_idx;
}
}

#define FOREACH_TYPE(T) \
Expand Down

0 comments on commit 1b18083

Please sign in to comment.