From e39f6a63b061a4ac0da9b3e136e32e23fd08ffd1 Mon Sep 17 00:00:00 2001 From: Pedro Gonnet <pedro.gonnet@durham.ac.uk> Date: Wed, 26 Jun 2013 09:34:22 +0000 Subject: [PATCH] set initial cell ownership relative to parts array. Former-commit-id: 9afddac98ec7caa1d9087df5463f2ecd8546da35 --- src/engine.c | 1 + src/space.c | 14 ++++++++++---- src/space.h | 3 +++ 3 files changed, 14 insertions(+), 4 deletions(-) diff --git a/src/engine.c b/src/engine.c index 9677b151b9..999bd59af7 100644 --- a/src/engine.c +++ b/src/engine.c @@ -783,6 +783,7 @@ void engine_init ( struct engine *e , struct space *s , float dt , int nr_thread /* Init the scheduler. */ scheduler_init( &e->sched , e->s , nr_queues , scheduler_flag_steal ); + s->nr_queues = nr_queues; /* Append a kick1 task to each cell. */ scheduler_reset( &e->sched , s->tot_cells ); diff --git a/src/space.c b/src/space.c index 41d6d04f08..a1fb6074f9 100644 --- a/src/space.c +++ b/src/space.c @@ -686,10 +686,12 @@ void space_split ( struct space *s , struct cell *c ) { 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; + + /* Set the values for this cell. */ + c->h_max = h_max; + c->dt_min = dt_min; + c->dt_max = dt_max; + c->maxdepth = maxdepth; } @@ -723,6 +725,9 @@ void space_split ( struct space *s , struct cell *c ) { c->dt_max = dt_max; } + + /* Set ownership accorind to the start of the parts array. */ + c->owner = ( c->parts - s->parts ) * s->nr_queues / s->nr_parts; } @@ -838,6 +843,7 @@ void space_init ( struct space *s , double dim[3] , struct part *parts , int N , s->nr_parts = N; s->parts = parts; s->cell_min = h_max; + s->nr_queues = 1; /* Allocate and link the xtra parts array. */ if ( posix_memalign( (void *)&s->xparts , 32 , N * sizeof(struct xpart) ) != 0 ) diff --git a/src/space.h b/src/space.h index 40788bd24f..2f970091c8 100644 --- a/src/space.h +++ b/src/space.h @@ -93,6 +93,9 @@ struct space { /* General-purpose lock for this space. */ lock_type lock; + /* Number of queues in the system. */ + int nr_queues; + }; -- GitLab