Skip to content

Commit

Permalink
SCHEDULE: fixes race on n_deps_satisfied (#618)
Browse files Browse the repository at this point in the history
A task can depend on 2 other tasks (e.g. from another frag of of
    schedule and prev task in a given frag). In that case when those 2
    frags a progressed by mutliple threads ucc_dependency_handler may
    be called concurrently which results in a race on n_deps_satisfied.

(cherry picked from commit b8c78d8)
  • Loading branch information
valentin petrov authored Sep 5, 2022
1 parent 97f8008 commit 9f22d78
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/schedule/ucc_schedule_pipelined.c
Original file line number Diff line number Diff line change
Expand Up @@ -210,11 +210,13 @@ ucc_status_t ucc_dependency_handler(ucc_coll_task_t *parent,
ucc_coll_task_t *task)
{
ucc_status_t status;
uint8_t n_deps_satisfied;

n_deps_satisfied = ucc_atomic_fadd8(&task->n_deps_satisfied, 1);

task->n_deps_satisfied++;
ucc_trace_req("task %p, n_deps %d, satisfied %d", task, task->n_deps,
task->n_deps_satisfied);
if (task->n_deps == task->n_deps_satisfied) {
n_deps_satisfied);
if (task->n_deps == n_deps_satisfied + 1) {
task->start_time = parent->start_time;
status = task->post(task);
if (status >= 0) {
Expand Down
1 change: 1 addition & 0 deletions src/utils/ucc_atomic.h
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@

#define ucc_atomic_add32 ucs_atomic_add32
#define ucc_atomic_fadd32 ucs_atomic_fadd32
#define ucc_atomic_fadd8 ucs_atomic_fadd8
#define ucc_atomic_sub32 ucs_atomic_sub32
#define ucc_atomic_add64 ucs_atomic_add64
#define ucc_atomic_sub64 ucs_atomic_sub64
Expand Down

0 comments on commit 9f22d78

Please sign in to comment.