From 76f86ea03e2dad97596344aafe2bfebefef5ae5c Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <pedro.gonnet@durham.ac.uk> Date: Mon, 17 Jun 2013 09:01:47 +0000 Subject: [PATCH] bound splitting depth. Former-commit-id: a14a4574dd6e3ad9d78a6adc7d4b49f69be0eaae --- src/cell.h | 2 +- src/space.c | 18 ++++++++++-------- src/space.h | 1 + 3 files changed, 12 insertions(+), 9 deletions(-) diff --git a/src/cell.h b/src/cell.h index bbc731b33e..59d26413c6 100644 --- a/src/cell.h +++ b/src/cell.h @@ -55,7 +55,7 @@ struct cell { float dx_max; /* The depth of this cell in the tree. */ - int depth, split; + int depth, split, maxdepth; /* Nr of parts. */ int count; diff --git a/src/space.c b/src/space.c index 71bcded652..97fad5127e 100644 --- a/src/space.c +++ b/src/space.c @@ -922,7 +922,7 @@ void space_splittasks ( struct space *s ) { if ( ci->split ) { /* Make a sub? */ - if ( space_dosub && ci->count < space_subsize ) { + if ( space_dosub && ci->count < space_subsize && ci->maxdepth - ci->depth < space_maxsubdepth ) { /* convert to a self-subtask. */ t->type = task_type_sub; @@ -981,6 +981,7 @@ void space_splittasks ( struct space *s ) { /* Replace by a single sub-task? */ if ( space_dosub && ci->count < space_subsize && cj->count < space_subsize && + ci->maxdepth - ci->depth < space_maxsubdepth && cj->maxdepth - cj->depth < space_maxsubdepth && sid != 0 && sid != 2 && sid != 6 && sid != 8 ) { /* Make this task a sub task. */ @@ -1344,7 +1345,7 @@ void space_maketasks ( struct space *s , int do_sort ) { void space_split ( struct space *s , struct cell *c ) { - int k, count = c->count; + int k, count = c->count, maxdepth = 0; float h, h_max = 0.0f, dt, dt_min = c->parts[0].dt, dt_max = dt_min; double x[3]; struct cell *temp; @@ -1397,16 +1398,16 @@ void space_split ( struct space *s , struct cell *c ) { } else { space_split( s , c->progeny[k] ); - if ( c->progeny[k]->h_max > h_max ) - h_max = c->progeny[k]->h_max; - if ( c->progeny[k]->dt_min < dt_min ) - dt_min = c->progeny[k]->dt_min; - if ( c->progeny[k]->dt_max > dt_max ) - dt_max = c->progeny[k]->dt_max; + h_max = fmaxf( h_max , c->progeny[k]->h_max ); + dt_min = fminf( dt_min , c->progeny[k]->dt_min ); + dt_max = fmaxf( dt_max , c->progeny[k]->dt_max ); + if ( c->progeny[k]->maxdepth > maxdepth ) + maxdepth = c->progeny[k]->maxdepth; } c->h_max = h_max; c->dt_min = dt_min; c->dt_max = dt_max; + c->maxdepth = maxdepth; } @@ -1416,6 +1417,7 @@ void space_split ( struct space *s , struct cell *c ) { /* Clear the progeny. */ bzero( c->progeny , sizeof(struct cell *) * 8 ); c->split = 0; + c->maxdepth = c->depth; /* Get dt_min/dt_max. */ diff --git a/src/space.h b/src/space.h index 43c9837751..0e1b504710 100644 --- a/src/space.h +++ b/src/space.h @@ -26,6 +26,7 @@ #define space_splitratio 0.875f #define space_splitsize_default 400 #define space_subsize_default 5000 +#define space_maxsubdepth 3 #define space_dosub 1 #define space_stretch 1.05f #define space_maxtaskspercell 31 -- GitLab