]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph.git/commitdiff
arch: add support for HW_CAP based neon runtime detection 3035/head
authorLoic Dachary <ldachary@redhat.com>
Fri, 28 Nov 2014 17:47:58 +0000 (18:47 +0100)
committerLoic Dachary <ldachary@redhat.com>
Thu, 4 Dec 2014 22:53:01 +0000 (23:53 +0100)
Rename the files from neon to arm to reflect the fact that it's related
to arm processors and also because NEON was renamed ASIMD later. The
NEON and ASIMD features are mutually exclusive. 32bits binaries will get
NEON and never ASIMD, if they run on ARMv7 or ARMv8. 64bits binaries
will only run on ARMv8 and get ASIMD and never NEON.

The flag remains with _neon and no other flag is introduced since there
is no risk of confusion. Besides people who care usually know NEON but
are not yet aware of the ASIMD renaming. Keeping the _neon name probably
saves some questions.

http://tracker.ceph.com/issues/10197 Fixes: #10197

Signed-off-by: Loic Dachary <ldachary@redhat.com>
src/arch/Makefile.am
src/arch/arm.c [new file with mode: 0644]
src/arch/arm.h [new file with mode: 0644]
src/arch/neon.c [deleted file]
src/arch/neon.h [deleted file]
src/arch/probe.cc
src/erasure-code/jerasure/ErasureCodePluginSelectJerasure.cc
src/test/erasure-code/TestErasureCodePluginJerasure.cc
src/test/test_arch.cc

index 273420781509d95121159728098e28a30ea1682b..81df60e0e2d51c404c1dc3ebaf665ca644106290 100644 (file)
@@ -1,11 +1,11 @@
 libarch_la_SOURCES = \
        arch/intel.c \
-       arch/neon.c \
+       arch/arm.c \
        arch/probe.cc
 
 noinst_LTLIBRARIES += libarch.la
 
 noinst_HEADERS += \
        arch/intel.h \
-       arch/neon.h \
+       arch/arm.h \
        arch/probe.h
diff --git a/src/arch/arm.c b/src/arch/arm.c
new file mode 100644 (file)
index 0000000..93d079a
--- /dev/null
@@ -0,0 +1,56 @@
+#include "arch/probe.h"
+
+/* flags we export */
+int ceph_arch_neon = 0;
+
+#include <stdio.h>
+
+#if __linux__
+
+#include <elf.h>
+#include <link.h> // ElfW macro
+
+#if __arm__ || __aarch64__
+#include <asm/hwcap.h>
+#endif // __arm__
+
+static unsigned long get_auxval(unsigned long type)
+{
+       unsigned long result = 0;
+       int read = 0;
+       FILE *f = fopen("/proc/self/auxv", "r");
+       if (f) {
+               ElfW(auxv_t) entry;
+               while ((read = fread(&entry, sizeof(entry), 1, f)) > 0) {
+                       if (read != 1)
+                               break;
+                       if (entry.a_type == type) {
+                               result = entry.a_un.a_val;
+                               break;
+                       }
+               }
+               fclose(f);
+       }
+       return result;
+}
+
+static unsigned long get_hwcap(void)
+{
+       return get_auxval(AT_HWCAP);
+}
+
+#endif // __linux__
+
+int ceph_arch_arm_probe(void)
+{
+#if __arm__ && __linux__
+       ceph_arch_neon = (get_hwcap() & HWCAP_NEON) == HWCAP_NEON;
+#elif __aarch64__ && __linux__
+       ceph_arch_neon = (get_hwcap() & HWCAP_ASIMD) == HWCAP_ASIMD;
+#else
+       if (0)
+               get_hwcap();  // make compiler shut up
+#endif
+       return 0;
+}
+
diff --git a/src/arch/arm.h b/src/arch/arm.h
new file mode 100644 (file)
index 0000000..f613438
--- /dev/null
@@ -0,0 +1,16 @@
+#ifndef CEPH_ARCH_ARM_H
+#define CEPH_ARCH_ARM_H
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern int ceph_arch_neon;  /* true if we have ARM NEON or ASIMD abilities */
+
+extern int ceph_arch_arm_probe(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
diff --git a/src/arch/neon.c b/src/arch/neon.c
deleted file mode 100644 (file)
index f059080..0000000
+++ /dev/null
@@ -1,56 +0,0 @@
-#include "arch/probe.h"
-
-/* flags we export */
-int ceph_arch_neon = 0;
-
-#include <stdio.h>
-
-#if __linux__
-
-#include <elf.h>
-#include <link.h> // ElfW macro
-
-#if __arm__ || __aarch64__
-#include <asm/hwcap.h>
-#endif // __arm__
-
-static unsigned long get_auxval(unsigned long type)
-{
-       unsigned long result = 0;
-       int read = 0;
-       FILE *f = fopen("/proc/self/auxv", "r");
-       if (f) {
-               ElfW(auxv_t) entry;
-               while ((read = fread(&entry, sizeof(entry), 1, f)) > 0) {
-                       if (read != 1)
-                               break;
-                       if (entry.a_type == type) {
-                               result = entry.a_un.a_val;
-                               break;
-                       }
-               }
-               fclose(f);
-       }
-       return result;
-}
-
-static unsigned long get_hwcap(void)
-{
-       return get_auxval(AT_HWCAP);
-}
-
-#endif // __linux__
-
-int ceph_arch_neon_probe(void)
-{
-#if __arm__ && __linux__
-       ceph_arch_neon = (get_hwcap() & HWCAP_NEON) == HWCAP_NEON;
-#elif __aarch64__ && __linux__
-       ceph_arch_neon = (get_hwcap() & HWCAP_ASIMD) == HWCAP_ASIMD;
-#else
-       if (0)
-               get_hwcap();  // make compiler shut up
-#endif
-       return 0;
-}
-
diff --git a/src/arch/neon.h b/src/arch/neon.h
deleted file mode 100644 (file)
index 0c8aacf..0000000
+++ /dev/null
@@ -1,16 +0,0 @@
-#ifndef CEPH_ARCH_NEON_H
-#define CEPH_ARCH_NEON_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-extern int ceph_arch_neon;  /* true if we have ARM NEON abilities */
-
-extern int ceph_arch_neon_probe(void);
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif
index 8648e54d9457759fcf06c057cd1fb6b95f7bf0c8..b95921ae51f6a228fdec004092821931d957daa4 100644 (file)
@@ -4,7 +4,7 @@
 #include "arch/probe.h"
 
 #include "arch/intel.h"
-#include "arch/neon.h"
+#include "arch/arm.h"
 
 int ceph_arch_probe(void)
 {
@@ -12,7 +12,7 @@ int ceph_arch_probe(void)
     return 1;
 
   ceph_arch_intel_probe();
-  ceph_arch_neon_probe();
+  ceph_arch_arm_probe();
 
   ceph_arch_probed = 1;
   return 1;
index 32560b40fcbb7872f6ea32c5a81e40180dbbc50b..808cf014734d601b90c31927265990b1249b1c58 100644 (file)
@@ -19,7 +19,7 @@
 #include "common/debug.h"
 #include "arch/probe.h"
 #include "arch/intel.h"
-#include "arch/neon.h"
+#include "arch/arm.h"
 #include "erasure-code/ErasureCodePlugin.h"
 
 #define dout_subsys ceph_subsys_osd
index e8128a8bdee16ebfb406485077135b6a12c008d1..d7dbe3cad46ccdcdd2fc05980d2af1ffd1790661 100644 (file)
@@ -18,7 +18,7 @@
 #include <errno.h>
 #include "arch/probe.h"
 #include "arch/intel.h"
-#include "arch/neon.h"
+#include "arch/arm.h"
 #include "global/global_init.h"
 #include "erasure-code/ErasureCodePlugin.h"
 #include "common/ceph_argparse.h"
index 3b0cd8267f22877206442e29fe71a28abd80ed3e..b129262af277cb2abd1f618958a100d33e9d3e6d 100644 (file)
@@ -18,7 +18,7 @@
 
 #include "arch/probe.h"
 #include "arch/intel.h"
-#include "arch/neon.h"
+#include "arch/arm.h"
 #include "global/global_init.h"
 #include "common/ceph_argparse.h"
 #include "global/global_context.h"
@@ -47,7 +47,7 @@ TEST(Arch, all)
 
   int expected;
 
-  expected = strstr(flags, " neon ") ? 1 : 0;
+  expected = (strstr(flags, " neon ") || strstr(flags, " asimd ")) ? 1 : 0;
   EXPECT_EQ(expected, ceph_arch_neon);
 
   expected = strstr(flags, " pclmulqdq ") ? 1 : 0;