Commit 637853ce authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'affinity-fixes' into 'master'

Don't touch the pinning of the main thread when not using affinity.

There is a problem when the cpu mask is empty and using multiple MPI ranks on a node, in that case all the main threads end up pinned to one core during the reading of the initial conditions (and any other tasks done before engine_init is called).


See merge request !423
parents b569a893 4e364995
......@@ -153,12 +153,6 @@ int main(int argc, char *argv[]) {
#endif
/* Let's pin the main thread */
#if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE)
if (((ENGINE_POLICY)&engine_policy_setaffinity) == engine_policy_setaffinity)
engine_pin();
#endif
/* Welcome to SWIFT, you made the right choice */
if (myrank == 0) greetings();
......@@ -329,6 +323,12 @@ int main(int argc, char *argv[]) {
return 1;
}
/* Let's pin the main thread, now we know if affinity will be used. */
#if defined(HAVE_SETAFFINITY) && defined(HAVE_LIBNUMA) && defined(_GNU_SOURCE)
if (with_aff && ((ENGINE_POLICY)&engine_policy_setaffinity) == engine_policy_setaffinity)
engine_pin();
#endif
/* Genesis 1.1: And then, there was time ! */
clocks_set_cpufreq(cpufreq);
......
......@@ -4468,8 +4468,9 @@ void engine_init(struct engine *e, struct space *s,
/* Avoid (unexpected) interference between engine and runner threads. We can
* do this once we've made at least one call to engine_entry_affinity and
* maybe numa_node_of_cpu(sched_getcpu()), even if the engine isn't already
* pinned. Also unpin this when asked to not pin at all (!with_aff). */
engine_unpin();
* pinned. */
if (with_aff)
engine_unpin();
#endif
if (with_aff) {
......
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