[commit: ghc] master: rts: Fix NUMA when cross compiling (2bb6ba6)
git at git.haskell.org
git at git.haskell.org
Mon Jun 13 09:21:25 UTC 2016
Repository : ssh://git@git.haskell.org/ghc
On branch : master
Link : http://ghc.haskell.org/trac/ghc/changeset/2bb6ba62b8d0e9c79b59e39e225758cf999eff83/ghc
>---------------------------------------------------------------
commit 2bb6ba62b8d0e9c79b59e39e225758cf999eff83
Author: Erik de Castro Lopo <erikd at mega-nerd.com>
Date: Mon Jun 13 19:24:18 2016 +1000
rts: Fix NUMA when cross compiling
The NUMA code was enabled whenever numa.h and numaif.h are detected.
Unfortunately, the hosts' header files were being detected even then
cross compiling in the absence of a target libnuma.
Fix that by relying on the the presence of libnuma instead of the
presence of the header files. The test for libnuma does `AC_TRY_LINK`
which will fail if the test program (compiled for the target) can't
be linked against libnuma.
Test Plan:
Build on x86_64/linux and make sure NUMA works and cross compile to
armhf/linux.
Reviewers: austin, bgamari, hvr, simonmar
Reviewed By: simonmar
Subscribers: thomie
Differential Revision: https://phabricator.haskell.org/D2329
>---------------------------------------------------------------
2bb6ba62b8d0e9c79b59e39e225758cf999eff83
configure.ac | 9 ++++++---
rts/posix/OSMem.c | 8 ++++----
rts/posix/OSThreads.c | 2 +-
3 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/configure.ac b/configure.ac
index 070bae5..664deb4 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1105,10 +1105,13 @@ AC_DEFINE_UNQUOTED([USE_LIBDW], [$USE_LIBDW], [Set to 1 to use libdw])
dnl ** Have libnuma?
dnl --------------------------------------------------------------
+HaveLibNuma=0
AC_CHECK_HEADERS([numa.h numaif.h])
-AC_CHECK_LIB(numa, numa_available,
- [AC_DEFINE([HAVE_LIBNUMA], [1], [Define to 1 if you have libnuma.])]
- [])
+
+if test "$ac_cv_header_numa_h$ac_cv_header_numaif_h" = "yesyes" ; then
+ AC_CHECK_LIB(numa, numa_available,HaveLibNuma=1)
+fi
+AC_DEFINE_UNQUOTED([USE_LIBNUMA], [$HaveLibNuma], [Define to 1 if you have libnuma])
dnl ** Documentation
dnl --------------------------------------------------------------
diff --git a/rts/posix/OSMem.c b/rts/posix/OSMem.c
index 58310fe..99620ee 100644
--- a/rts/posix/OSMem.c
+++ b/rts/posix/OSMem.c
@@ -306,7 +306,7 @@ void osBindMBlocksToNode(
StgWord size STG_UNUSED,
uint32_t node STG_UNUSED)
{
-#ifdef HAVE_NUMAIF_H
+#if HAVE_LIBNUMA
int ret;
StgWord mask = 0;
mask |= 1 << node;
@@ -548,7 +548,7 @@ void osReleaseHeapMemory(void)
rtsBool osNumaAvailable(void)
{
-#ifdef HAVE_NUMA_H
+#if HAVE_LIBNUMA
return (numa_available() != -1);
#else
return rtsFalse;
@@ -557,7 +557,7 @@ rtsBool osNumaAvailable(void)
uint32_t osNumaNodes(void)
{
-#ifdef HAVE_NUMA_H
+#if HAVE_LIBNUMA
return numa_num_configured_nodes();
#else
return 1;
@@ -566,7 +566,7 @@ uint32_t osNumaNodes(void)
StgWord osNumaMask(void)
{
-#ifdef HAVE_NUMA_H
+#if HAVE_LIBNUMA
struct bitmask *mask;
mask = numa_get_mems_allowed();
if (mask->size > sizeof(StgWord)*8) {
diff --git a/rts/posix/OSThreads.c b/rts/posix/OSThreads.c
index 72538c1..35ea2bd 100644
--- a/rts/posix/OSThreads.c
+++ b/rts/posix/OSThreads.c
@@ -318,7 +318,7 @@ setThreadAffinity (uint32_t n STG_UNUSED,
}
#endif
-#ifdef HAVE_NUMA_H
+#if HAVE_LIBNUMA
void setThreadNode (uint32_t node)
{
ASSERT(node < RtsFlags.GcFlags.nNumaNodes);
More information about the ghc-commits
mailing list