Revision: 54975
http://brlcad.svn.sourceforge.net/brlcad/?rev=54975&view=rev
Author: brlcad
Date: 2013-03-29 16:54:56 +0000 (Fri, 29 Mar 2013)
Log Message:
-----------
need to test this theory, but we shouldn't need to look up the current affinity
mask to set a cpu preference. bu_parallel_id() modded with the number of avail
cpus should set all threads with the appropriate affinity mask.
Modified Paths:
--------------
brlcad/trunk/src/libbu/affinity.c
Modified: brlcad/trunk/src/libbu/affinity.c
===================================================================
--- brlcad/trunk/src/libbu/affinity.c 2013-03-29 16:46:29 UTC (rev 54974)
+++ brlcad/trunk/src/libbu/affinity.c 2013-03-29 16:54:56 UTC (rev 54975)
@@ -71,33 +71,10 @@
cpuset_t set_of_cpus;
#endif
+ /* Clear CPU set and assign our number */
CPU_ZERO(&set_of_cpus);
+ CPU_SET(bu_parallel_id() & bu_avail_cpus(), &set_of_cpus);
- for (j = 0; j < ncpu; j++) {
- /* Set affinity mask to include CPUs 0 to max available CPU */
- CPU_SET(j, &set_of_cpus);
- }
-
- /* Check current affinity mask assigned to thread */
- status = pthread_getaffinity_np(curr_thread, sizeof(set_of_cpus),
&set_of_cpus);
- if (status != 0) {
- /* Error in getting affinity mask */
- return -1;
- }
-
- for (j = 0; j < CPU_SETSIZE; j++) {
- /* Check which set has been returned by pthread_get_affinity */
- if (CPU_ISSET(j, &set_of_cpus)) {
- /* found affinity mask */
- cpu = j;
- break;
- }
- }
-
- /* Clear CPU set and assign CPUs */
- CPU_ZERO(&set_of_cpus);
- CPU_SET(cpu, &set_of_cpus);
-
/* set affinity mask of current thread */
status = pthread_setaffinity_np(curr_thread, sizeof(set_of_cpus),
&set_of_cpus);
if (status != 0) {
@@ -128,7 +105,7 @@
return -1;
/* put each thread into a separate group */
- apolicy.affinity_tag = curr_thread;
+ apolicy.affinity_tag = bu_parallel_id() % bu_avail_cpus();
ret = thread_policy_set(curr_thread, THREAD_EXTENDED_POLICY,
(thread_policy_t) &apolicy, THREAD_EXTENDED_POLICY_COUNT);
if (ret != KERN_SUCCESS)
return -1;
@@ -136,7 +113,7 @@
return 0;
#elif defined(HAVE_WINDOWS_H)
- BOOL ret = SetThreadAffinityMask(GetCurrentThread(), 1 <<
bu_parallel_id());
+ BOOL ret = SetThreadAffinityMask(GetCurrentThread(), 1 << bu_parallel_id()
% bu_avail_cpus());
if (ret == 0)
return -1;
This was sent by the SourceForge.net collaborative development platform, the
world's largest Open Source development site.
------------------------------------------------------------------------------
Own the Future-Intel(R) Level Up Game Demo Contest 2013
Rise to greatness in Intel's independent game demo contest. Compete
for recognition, cash, and the chance to get your game on Steam.
$5K grand prize plus 10 genre and skill prizes. Submit your demo
by 6/6/13. http://altfarm.mediaplex.com/ad/ck/12124-176961-30367-2
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits