Commit 8c688c99 authored by Matthieu Schaller's avatar Matthieu Schaller
Browse files

Merge branch 'entry_affinity_as_static' into 'master'

Make the entry affinity pointer a static variable in a function rather a global

Here is what I hinted to in #204. I find this clearer to read. Do you agree with that change ?

See merge request !229
parents 55333951 57490cba
......@@ -85,11 +85,6 @@ const char *engine_policy_names[13] = {"none",
/** The rank of the engine as a global variable (for messages). */
int engine_rank;
/** The initial affinity of the main thread (set by engin_pin()) */
static cpu_set_t entry_affinity;
* @brief Link a density/force task to a cell.
......@@ -3010,6 +3005,7 @@ void engine_dump_snapshot(struct engine *e) {
static cpu_set_t *engine_entry_affinity() {
static int use_entry_affinity = 0;
static cpu_set_t entry_affinity;
if (!use_entry_affinity) {
pthread_t engine = pthread_self();
......@@ -3050,7 +3046,8 @@ void engine_pin() {
void engine_unpin() {
pthread_t main_thread = pthread_self();
pthread_setaffinity_np(main_thread, sizeof(entry_affinity), &entry_affinity);
cpu_set_t *entry_affinity = engine_entry_affinity();
pthread_setaffinity_np(main_thread, sizeof(*entry_affinity), entry_affinity);
error("SWIFT was not compiled with support for pinning.");
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