[MLton-commit] r6645

spoons at mlton.org spoons at mlton.org
Fri Jun 6 08:54:18 PDT 2008


only set cpu affinity where available (on linux)

----------------------------------------------------------------------

U   mlton/branches/shared-heap-multicore/include/c-main.h
U   mlton/branches/shared-heap-multicore/runtime/cenv.h
U   mlton/branches/shared-heap-multicore/runtime/platform/linux.h

----------------------------------------------------------------------

Modified: mlton/branches/shared-heap-multicore/include/c-main.h
===================================================================
--- mlton/branches/shared-heap-multicore/include/c-main.h	2008-06-05 20:34:40 UTC (rev 6644)
+++ mlton/branches/shared-heap-multicore/include/c-main.h	2008-06-06 15:54:16 UTC (rev 6645)
@@ -48,14 +48,8 @@
         uint32_t num = Proc_processorNumber (s)                         \
                 * s->controls->affinityStride                           \
                 + s->controls->affinityBase;                            \
-        plpa_cpu_set_t cpuset;                                          \
+        set_cpu_affinity(num);                                          \
                                                                         \
-        PLPA_CPU_ZERO (&cpuset);                                        \
-        PLPA_CPU_SET (num, &cpuset);                                    \
-        if (plpa_sched_setaffinity (0, sizeof(cpuset), &cpuset)) {      \
-                fprintf (stderr, "Warning: unable to set CPU affinity\n"); \
-        }                                                               \
-                                                                        \
         /* Save our state locally */                                    \
         pthread_setspecific (gcstate_key, s);                           \
         if (s->amOriginal) {                                            \

Modified: mlton/branches/shared-heap-multicore/runtime/cenv.h
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/cenv.h	2008-06-05 20:34:40 UTC (rev 6644)
+++ mlton/branches/shared-heap-multicore/runtime/cenv.h	2008-06-06 15:54:16 UTC (rev 6645)
@@ -41,7 +41,6 @@
 // #include <locale.h>
 #include <math.h>
 #include <pthread.h>
-#include <plpa.h>
 // #include <setjmp.h>
 #include <signal.h>
 #include <stdarg.h>
@@ -67,6 +66,9 @@
 #define __Darwin__
 #endif
 
+// No-op on most platforms for now
+#define set_cpu_affinity(num) do {} while (0)
+
 #if (defined (_AIX))
 #include "platform/aix.h"
 #elif (defined (__CYGWIN__))
@@ -78,6 +80,7 @@
 #elif (defined (__hpux__))
 #include "platform/hpux.h"
 #elif (defined (__linux__))
+#undef set_cpu_affinity
 #include "platform/linux.h"
 #elif (defined (__MINGW32__))
 #include "platform/mingw.h"

Modified: mlton/branches/shared-heap-multicore/runtime/platform/linux.h
===================================================================
--- mlton/branches/shared-heap-multicore/runtime/platform/linux.h	2008-06-05 20:34:40 UTC (rev 6644)
+++ mlton/branches/shared-heap-multicore/runtime/platform/linux.h	2008-06-06 15:54:16 UTC (rev 6645)
@@ -10,6 +10,7 @@
 #include <netdb.h>
 #include <netinet/in.h>
 #include <netinet/tcp.h>
+#include <plpa.h>
 #include <poll.h>
 #include <pwd.h>
 #include <sys/ioctl.h>
@@ -41,3 +42,13 @@
 #ifndef _GNU_SOURCE
 extern char **environ; /* for Posix_ProcEnv_environ */
 #endif
+
+#define set_cpu_affinity(num) do {                                      \
+        plpa_cpu_set_t cpuset;                                          \
+                                                                        \
+        PLPA_CPU_ZERO (&cpuset);                                        \
+        PLPA_CPU_SET (num, &cpuset);                                    \
+        if (plpa_sched_setaffinity (0, sizeof(cpuset), &cpuset)) {      \
+                fprintf (stderr, "Warning: unable to set CPU affinity\n"); \
+        }                                                               \
+      } while (0) 




More information about the MLton-commit mailing list