From 1b0c57dfb65b0a7302429e5d19da5b8e809bd7d6 Mon Sep 17 00:00:00 2001
From: Pedro Gonnet <pedro.gonnet@durham.ac.uk>
Date: Tue, 25 Jun 2013 15:45:34 +0000
Subject: [PATCH] make kick1 recursive when cell is sufficiently small.

Former-commit-id: 58f259d0fb33f31724cdbaefc1b756075d4b9d5f
---
 src/runner.c    | 2 ++
 src/runner.h    | 2 ++
 src/scheduler.c | 8 +++++---
 3 files changed, 9 insertions(+), 3 deletions(-)

diff --git a/src/runner.c b/src/runner.c
index 518bac4874..fe9f0d91bc 100644
--- a/src/runner.c
+++ b/src/runner.c
@@ -738,6 +738,8 @@ void runner_dokick1 ( struct runner *r , struct cell *c ) {
         /* Loop over the progeny. */
         for ( k = 0 ; k < 8 ; k++ )
             if ( c->progeny[k] != NULL ) {
+                if ( c->count < space_subsize )
+                    runner_dokick1( r , c->progeny[k] );
                 dt_min = fminf( dt_min , c->progeny[k]->dt_min );
                 dt_max = fmaxf( dt_max , c->progeny[k]->dt_max );
                 h_max = fmaxf( h_max , c->progeny[k]->h_max );
diff --git a/src/runner.h b/src/runner.h
index 58ecf128f5..5ee1ee3a95 100644
--- a/src/runner.h
+++ b/src/runner.h
@@ -74,4 +74,6 @@ void runner_dopair_density ( struct runner *r , struct cell *ci , struct cell *c
 void runner_doself_density ( struct runner *r , struct cell *c );
 void runner_dosub_density ( struct runner *r , struct cell *ci , struct cell *cj , int flags );
 void runner_dosort ( struct runner *r , struct cell *c , int flag , int clock );
+void runner_dokick1 ( struct runner *r , struct cell *c );
+void runner_dokick2 ( struct runner *r , struct cell *c );
 void *runner_main ( void *data );
diff --git a/src/scheduler.c b/src/scheduler.c
index ced1dab562..80d9d74441 100644
--- a/src/scheduler.c
+++ b/src/scheduler.c
@@ -72,9 +72,11 @@ void scheduler_map_mkghosts ( struct cell *c , void *data ) {
         c->ghost = scheduler_addtask( s , task_type_ghost , task_subtype_none , 0 , 0 , c , NULL , 0 );
 
     /* Append a kick1 task and make sure the parent depends on it. */
-    c->kick1 = scheduler_addtask( s , task_type_kick1 , task_subtype_none , 0 , 0 , c , NULL , 0 );
-    if ( c->parent != NULL )
-        task_addunlock( c->kick1 , c->parent->kick1 );
+    if ( c->parent == NULL || c->parent->count >= space_subsize ) {
+        c->kick1 = scheduler_addtask( s , task_type_kick1 , task_subtype_none , 0 , 0 , c , NULL , 0 );
+        if ( c->parent != NULL )
+            task_addunlock( c->kick1 , c->parent->kick1 );
+        }
     
     /* Append a kick2 task if we are the active super cell. */
     if ( c->super == c && c->nr_tasks > 0 )
-- 
GitLab