[brlcad-commits] SF.net SVN: brlcad:[60487] brlcad/trunk/src/libbu/affinity.c
Open Source Solid Modeling CAD
Brought to you by:
brlcad
From: <br...@us...> - 2014-05-05 16:19:27
|
Revision: 60487 http://sourceforge.net/p/brlcad/code/60487 Author: brlcad Date: 2014-05-05 16:19:22 +0000 (Mon, 05 May 2014) Log Message: ----------- allowing movement on a core sounds like a great idea, but apparently too clever for the default linux scheduler. multiple threads are getting assigned to the same core (on the same cpu), leaving one or more cores idle (even though their affinity mask clearly lists all N cores before and after they're set). ugh. Modified Paths: -------------- brlcad/trunk/src/libbu/affinity.c Modified: brlcad/trunk/src/libbu/affinity.c =================================================================== --- brlcad/trunk/src/libbu/affinity.c 2014-05-05 16:16:04 UTC (rev 60486) +++ brlcad/trunk/src/libbu/affinity.c 2014-05-05 16:19:22 UTC (rev 60487) @@ -69,30 +69,8 @@ CPU_ZERO(&set_of_cpus); - if (ncpus % 4 == 0 && (ncpus / 4) % 2 == 0 && ncpus > 4) { - /* Set affinity in fours to allow thread movement but keeping - * threads near the same cache, hopefully on the same core. - * Assumes multi-core (quad or octo) architecture. - */ - CPU_SET((((cpu / 4) * 4) + 0) % ncpus, &set_of_cpus); - CPU_SET((((cpu / 4) * 4) + 1) % ncpus, &set_of_cpus); - CPU_SET((((cpu / 4) * 4) + 2) % ncpus, &set_of_cpus); - CPU_SET((((cpu / 4) * 4) + 3) % ncpus, &set_of_cpus); - bu_log("Setting affinity of %d to (%d, %d, %d, %d)\n", cpu, (((cpu / 4) * 4) + 0) % ncpus, (((cpu / 4) * 4) + 1) % ncpus, (((cpu / 4) * 4) + 2) % ncpus, (((cpu / 4) * 4) + 3) % ncpus); - } else if (ncpus % 2 == 0 && ncpus > 2) { - /* Set affinity in pairs to allow thread movement but keeping - * threads near the same cache, hopefully on the same core. - * Assumes multi-core (dual or hexa) architecture. - */ - CPU_SET((((cpu / 2) * 2) + 0) % ncpus, &set_of_cpus); - CPU_SET((((cpu / 2) * 2) + 1) % ncpus, &set_of_cpus); - bu_log("Setting affinity of %d to (%d, %d)\n", cpu, (((cpu / 2) * 2) + 0) % ncpus, (((cpu / 2) * 2) + 1) % ncpus); - } else { - /* Set affinity to a single CPU core */ - CPU_SET(cpu % ncpus, &set_of_cpus); - } - - /* set affinity mask of current thread */ + /* Set affinity to a single CPU core */ + CPU_SET(cpu % ncpus, &set_of_cpus); ret = pthread_setaffinity_np(pthread_self(), sizeof(set_of_cpus), &set_of_cpus); return ret; This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |