From fd077c1bed6a0ba56118644eaf6dd739cdd3ffd0 Mon Sep 17 00:00:00 2001
From: James Willis <james.s.willis@durham.ac.uk>
Date: Mon, 4 Jun 2018 14:12:46 +0100
Subject: [PATCH] Placed TODOs where atomic operations may be necessary.

---
 src/fof.c | 11 +++++++++++
 1 file changed, 11 insertions(+)

diff --git a/src/fof.c b/src/fof.c
index 0c1b904975..d63d3d71bc 100644
--- a/src/fof.c
+++ b/src/fof.c
@@ -32,6 +32,9 @@ __attribute__((always_inline)) INLINE static int fof_find(const int i,
                                                           int *group_id) {
 
   int root = i;
+  /* TODO: May need this atomic here:
+   * while (root != atomic_cas(&group_id[root], group_id[root], group_id[root])) 
+   *   root = atomic_cas(&group_id[root], group_id[root], group_id[root]); */
   while (root != group_id[root]) root = group_id[root];
 
   /* Perform path compression. */
@@ -298,11 +301,15 @@ void fof_search_cell(struct space *s, struct cell *c) {
         /* If the root ID of pj is lower than pi's root ID set pi's root to point to pj's. 
          * Otherwise set pj's to root to point to pi's.*/
         if (root_j < root_i) {
+          /* TODO: May need this atomic here:
+          *  atomic_cas(&group_id[root_i], group_id[root_i], root_j); */
           group_id[root_i] = root_j;
           /* Update root_i on the fly. */
           root_i = root_j;
         }
         else
+          /* TODO: May need this atomic here:
+             atomic_cas(&group_id[root_j], group_id[root_j], root_i); */
           group_id[root_j] = root_i;
 
       }
@@ -382,11 +389,15 @@ void fof_search_pair_cells(struct space *s, struct cell *ci, struct cell *cj) {
         /* If the root ID of pj is lower than pi's root ID set pi's root to point to pj's. 
          * Otherwise set pj's to root to point to pi's.*/
         if (root_j < root_i) {
+          /* TODO: May need this atomic here:
+             atomic_cas(&group_id[root_i], group_id[root_i], root_j); */
           group_id[root_i] = root_j;
           /* Update root_i on the fly. */
           root_i = root_j;
         }
         else
+          /* TODO: May need this atomic here:
+             atomic_cas(&group_id[root_j], group_id[root_j], root_i); */
           group_id[root_j] = root_i;
 
       }
-- 
GitLab