From 4f1bd22f2f655f94e5652f89b9b8c1445f25c87b Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Wed, 13 Dec 2017 14:04:59 +0000
Subject: [PATCH] Call vectorised version of dopair_subset.

---
 src/runner.c        | 11 ++++++++++-
 src/runner_doiact.h |  7 +++++++
 2 files changed, 17 insertions(+), 1 deletion(-)

diff --git a/src/runner.c b/src/runner.c
index 3dc51861aa..5185875197 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -787,12 +787,21 @@ void runner_do_ghost(struct runner *r, struct cell *c, int timer) {
 
               /* Left or right? */
               if (l->t->ci == finger)
+#ifdef WITH_VECTORIZATION
+                runner_dopair_subset_density_vec(r, finger, parts, pid, count,
+                                             l->t->cj);
+#else
                 runner_dopair_subset_density(r, finger, parts, pid, count,
                                              l->t->cj);
+#endif
               else
+#ifdef WITH_VECTORIZATION
+                runner_dopair_subset_density_vec(r, finger, parts, pid, count,
+                                             l->t->ci);
+#else
                 runner_dopair_subset_density(r, finger, parts, pid, count,
                                              l->t->ci);
-
+#endif
             }
 
             /* Otherwise, sub-self interaction? */
diff --git a/src/runner_doiact.h b/src/runner_doiact.h
index 7910502cd2..d72f4d2789 100644
--- a/src/runner_doiact.h
+++ b/src/runner_doiact.h
@@ -603,9 +603,11 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci,
       const double di = hi * kernel_gamma + dxj + pix * runner_shift[sid][0] +
                         piy * runner_shift[sid][1] + piz * runner_shift[sid][2];
 
+//      int ctr = 0;
       /* Loop over the parts in cj. */
       for (int pjd = 0; pjd < count_j && sort_j[pjd].d < di; pjd++) {
 
+//        ctr++;
         /* Get a pointer to the jth particle. */
         struct part *restrict pj = &parts_j[sort_j[pjd].i];
         const float hj = pj->h;
@@ -631,6 +633,7 @@ void DOPAIR_SUBSET(struct runner *r, struct cell *restrict ci,
           IACT_NONSYM(r2, dx, hi, hj, pi, pj);
         }
       } /* loop over the parts in cj. */
+//      message("pi: %lld, iterations in inner loop: %d", pi->id, ctr);
     }   /* loop over the parts in ci. */
   }
 
@@ -2950,7 +2953,11 @@ void DOSUB_SUBSET(struct runner *r, struct cell *ci, struct part *parts,
       /* Do any of the cells need to be drifted first? */
       if (!cell_are_part_drifted(cj, e)) error("Cell should be drifted!");
 
+#ifdef WITH_VECTORIZATION
+      runner_dopair_subset_density_vec(r, ci, parts, ind, count, cj);
+#else
       DOPAIR_SUBSET(r, ci, parts, ind, count, cj);
+#endif
     }
 
   } /* otherwise, pair interaction. */
-- 
GitLab