Revision: 55031
          http://brlcad.svn.sourceforge.net/brlcad/?rev=55031&view=rev
Author:   brlcad
Date:     2013-04-04 02:56:37 +0000 (Thu, 04 Apr 2013)
Log Message:
-----------
provide a LIBBU_AFFINITY environment variable to allow run-time disabling of 
cpu affinity since it defaults to always on for all bu_parallel() threads.  
check the environment variable from the parent thread (where we can, most 
modern platforms)

Modified Paths:
--------------
    brlcad/trunk/src/libbu/parallel.c

Modified: brlcad/trunk/src/libbu/parallel.c
===================================================================
--- brlcad/trunk/src/libbu/parallel.c   2013-04-03 15:33:12 UTC (rev 55030)
+++ brlcad/trunk/src/libbu/parallel.c   2013-04-04 02:56:37 UTC (rev 55031)
@@ -121,6 +121,7 @@
     genptr_t user_arg;
     int cpu_id;
     int counted;
+    int affinity;
 };
 
 
@@ -347,8 +348,10 @@
     /* keep track of our parallel ID number */
     thread_set_cpu(user_thread_data->cpu_id);
 
-    /* lock us onto a core corresponding to our parallel ID number */
-    parallel_set_affinity(user_thread_data->cpu_id);
+    if (user_thread_data->affinity) {
+       /* lock us onto a core corresponding to our parallel ID number */
+       parallel_set_affinity(user_thread_data->cpu_id);
+    }
 
     if (!user_thread_data->counted) {
        bu_semaphore_acquire(BU_SEM_SYSCALL);
@@ -382,6 +385,8 @@
 parallel_interface(void)
 {
     struct thread_data user_thread_data_pi;
+    char *libbu_affinity = NULL;
+    int affinity = 1;
 
     user_thread_data_pi.user_func = parallel_func;
     user_thread_data_pi.user_arg  = parallel_arg;
@@ -390,7 +395,12 @@
     user_thread_data_pi.cpu_id = parallel_nthreads_started++;
     bu_semaphore_release(BU_SEM_SYSCALL);
 
+    libbu_affinity = getenv("LIBBU_AFFINITY");
+    if (libbu_affinity)
+       affinity = (int)strtol(libbu_affinity, NULL, 0x10);
+
     user_thread_data_pi.counted = 1;
+    user_thread_data_pi.affinity = affinity;
 
     parallel_interface_arg(&user_thread_data_pi);
 
@@ -417,6 +427,9 @@
     int avail_cpus = 1;
     int x;
 
+    char *libbu_affinity = NULL;
+    int affinity = 1;
+
     /*
      * multithreading support for SunOS 5.X / Solaris 2.x
      */
@@ -448,6 +461,10 @@
     parallel_func = func;
     parallel_arg = arg;
 
+    libbu_affinity = getenv("LIBBU_AFFINITY");
+    if (libbu_affinity)
+       affinity = (int)strtol(libbu_affinity, NULL, 0x10);
+
     user_thread_data_bu = (struct thread_data *)bu_calloc(ncpu, 
sizeof(*user_thread_data_bu), "struct thread_data *user_thread_data_bu");
 
     /* Fill in the data of user_thread_data_bu structures of all threads */
@@ -456,6 +473,7 @@
        user_thread_data_bu[x].user_arg  = arg;
        user_thread_data_bu[x].cpu_id    = x;
        user_thread_data_bu[x].counted   = 0;
+       user_thread_data_bu[x].affinity  = affinity;
     }
 
     /* if we're in debug mode, allow additional cpus */

This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.


------------------------------------------------------------------------------
Minimize network downtime and maximize team effectiveness.
Reduce network management and security costs.Learn how to hire 
the most talented Cisco Certified professionals. Visit the 
Employer Resources Portal
http://www.cisco.com/web/learning/employer_resources/index.html
_______________________________________________
BRL-CAD Source Commits mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/brlcad-commits

Reply via email to