Commit afb02ce5 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Correct use of caches in the self-PP gravity task. Make sure we can run...

Correct use of caches in the self-PP gravity task. Make sure we can run without vectorization. Make sure we can run without hydro.
parent e0e14468
......@@ -154,7 +154,7 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
struct scheduler *s = &e->sched;
const int periodic = e->s->periodic;
const int is_hydro = (e->policy & engine_policy_hydro);
const int is_with_hydro = (e->policy & engine_policy_hydro);
const int is_self_gravity = (e->policy & engine_policy_self_gravity);
const int is_with_cooling = (e->policy & engine_policy_cooling);
const int is_with_sourceterms = (e->policy & engine_policy_sourceterms);
......@@ -163,15 +163,19 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
if (c->super == c) {
/* Add the sort task. */
c->sorts =
scheduler_addtask(s, task_type_sort, task_subtype_none, 0, 0, c, NULL);
if (is_with_hydro) {
c->sorts =
scheduler_addtask(s, task_type_sort, task_subtype_none, 0, 0, c, NULL);
}
/* Local tasks only... */
if (c->nodeID == e->nodeID) {
/* Add the drift task. */
c->drift_part = scheduler_addtask(s, task_type_drift_part,
task_subtype_none, 0, 0, c, NULL);
if (is_with_hydro) {
c->drift_part = scheduler_addtask(s, task_type_drift_part,
task_subtype_none, 0, 0, c, NULL);
}
/* Add the two half kicks */
c->kick1 = scheduler_addtask(s, task_type_kick1, task_subtype_none, 0, 0,
......@@ -208,7 +212,7 @@ void engine_make_hierarchical_tasks(struct engine *e, struct cell *c) {
}
/* Generate the ghost tasks. */
if (is_hydro) {
if (is_with_hydro) {
c->ghost_in =
scheduler_addtask(s, task_type_ghost, task_subtype_none, 0,
/* implicit = */ 1, c, NULL);
......@@ -4548,16 +4552,16 @@ void engine_init(struct engine *e, struct space *s,
e->runners[k].qid = k * nr_queues / e->nr_threads;
}
#ifdef WITH_VECTORIZATION
/* Allocate particle caches. */
e->runners[k].ci_cache.count = 0;
e->runners[k].cj_cache.count = 0;
cache_init(&e->runners[k].ci_cache, CACHE_SIZE);
cache_init(&e->runners[k].cj_cache, CACHE_SIZE);
e->runners[k].ci_gravity_cache.count = 0;
e->runners[k].cj_gravity_cache.count = 0;
gravity_cache_init(&e->runners[k].ci_gravity_cache, space_splitsize);
gravity_cache_init(&e->runners[k].cj_gravity_cache, space_splitsize);
#ifdef WITH_VECTORIZATION
e->runners[k].ci_cache.count = 0;
e->runners[k].cj_cache.count = 0;
cache_init(&e->runners[k].ci_cache, CACHE_SIZE);
cache_init(&e->runners[k].cj_cache, CACHE_SIZE);
#endif
if (verbose) {
......
......@@ -936,7 +936,7 @@ void runner_doself_grav_pp_full(struct runner *r, struct cell *c) {
/* Check that we fit in cache */
if (gcount > ci_cache->count)
error("Not enough space in the caches! gcount_i=%d", gcount);
error("Not enough space in the cache! gcount=%d", gcount);
/* Computed the padded counts */
const int gcount_padded = gcount - (gcount % VEC_SIZE) + VEC_SIZE;
......@@ -1032,9 +1032,9 @@ void runner_doself_grav_pp_full(struct runner *r, struct cell *c) {
}
/* Store everything back in cache */
ci_cache->a_x[pid] += a_x;
ci_cache->a_y[pid] += a_y;
ci_cache->a_z[pid] += a_z;
ci_cache->a_x[pid] = a_x;
ci_cache->a_y[pid] = a_y;
ci_cache->a_z[pid] = a_z;
}
/* Write back to the particles */
......@@ -1150,7 +1150,7 @@ void runner_doself_grav_pp_truncated(struct runner *r, struct cell *c) {
/* Check that we fit in cache */
if (gcount > ci_cache->count)
error("Not enough space in the caches! gcount_i=%d", gcount);
error("Not enough space in the caches! gcount=%d", gcount);
/* Computed the padded counts */
const int gcount_padded = gcount - (gcount % VEC_SIZE) + VEC_SIZE;
......@@ -1251,9 +1251,9 @@ void runner_doself_grav_pp_truncated(struct runner *r, struct cell *c) {
}
/* Store everything back in cache */
ci_cache->a_x[pid] += a_x;
ci_cache->a_y[pid] += a_y;
ci_cache->a_z[pid] += a_z;
ci_cache->a_x[pid] = a_x;
ci_cache->a_y[pid] = a_y;
ci_cache->a_z[pid] = a_z;
}
/* Write back to the particles */
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment