From 02ea89431c177911f67dba38c90bcecd14b84db8 Mon Sep 17 00:00:00 2001
From: d74ksy <aidan.chalk@durham.ac.uk>
Date: Thu, 15 Oct 2015 14:22:05 +0100
Subject: [PATCH] Ensured we checked for child or parent resources that are
 locked by parent tasks too.

---
 src/qsched.c      | 39 ++++++++++++++++++++++++++++++++++++++-
 tests/Makefile.am |  2 +-
 2 files changed, 39 insertions(+), 2 deletions(-)

diff --git a/src/qsched.c b/src/qsched.c
index 02ae50f..8bb6bd8 100644
--- a/src/qsched.c
+++ b/src/qsched.c
@@ -1859,10 +1859,12 @@ for(i = 0; i < count; i++)
         for(k = num_parents; k >= 0; k--)
         {
             struct task *t2 = &s->tasks[ gettaskindex(tid[parents[k]], s)];
+            int found = 0;
             for(l = 0; l < t2->nr_locks; l++)
             {
                 if(t2->locks[l] == t->locks[j])
                 {
+                    found = 1;
                     current_parents[num_current++] = k;
                     if(k > last_index)
                         last_index = k;
@@ -1871,7 +1873,42 @@ for(i = 0; i < count; i++)
                         num_skipped++;
                     break;
                 }
-            }
+                struct res *r = &s->res[getindex(t2->locks[l],s)];
+                while(r->parent != -1)
+                {
+                    r = &s->res[getindex(r->parent,s)];
+                    if(r->ID == t->locks[j])
+                    {
+                        found = 1;
+                        current_parents[num_current++] = k;
+                        if(k > last_index)
+                            last_index = k;
+                        /* If we skipped the parent task, increment the number we skipped. */
+                        if(t2->flags & task_flag_skip)
+                            num_skipped++;
+                        break;
+                    }
+                }
+                if(found)
+                    continue;
+
+                r = &s->res[getindex(t->locks[l],s)];
+                while(r->parent != -1)
+                {
+                    r = &s->res[getindex(r->parent,s)];
+                    if(r->ID == t2->locks[l])
+                    {
+                        found = 1;
+                        current_parents[num_current++] = k;
+                        if(k > last_index)
+                            last_index = k;
+                        /* If we skipped the parent task, increment the number we skipped. */
+                        if(t2->flags & task_flag_skip)
+                            num_skipped++;
+                        break;
+                    }
+                }
+            } /* l over locks*/
         }/* k over parents. */
 
         /* We have the current parents. */
diff --git a/tests/Makefile.am b/tests/Makefile.am
index c6b5a7d..38dcb0f 100644
--- a/tests/Makefile.am
+++ b/tests/Makefile.am
@@ -39,4 +39,4 @@ test_mpi_CFLAGS = $(AM_CFLAGS) -DWITH_MPI
 #test_mpi_synchronize_LDFLAGS = $(MPI_THREAD_LIBS)
 #test_mpi_synchronize_SOURCES = test_mpi_synchronize.c
 #test_mpi_synchronize_CFLAGS = $(AM_CFLAGS) -DWITH_MPI
-test_mpi_synchronize_LDADD =  ../src/.libs/libquickschedMPI.a
+#test_mpi_synchronize_LDADD =  ../src/.libs/libquickschedMPI.a
-- 
GitLab