fi
# don't add LIBS/CFLAGS/REQUIRES yet, depends on plugins
- # Try to compile the cpuid inlines
- AC_MSG_CHECKING([for cpuid])
+ # Try to compile the x86 cpuid inlines
+ AC_MSG_CHECKING([for x86 cpuid])
old_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$HWLOC_top_srcdir/include"
# We need hwloc_uint64_t but we can't use hwloc/autogen/config.h before configure ends.
CPUID_CHECK_HEADERS=
CPUID_CHECK_DEFINE=
if test "x$hwloc_windows" = xyes; then
- CPUID_CHECK_HEADERS="#include <windows.h>"
- CPUID_CHECK_DEFINE="#define hwloc_uint64_t DWORDLONG"
+ X86_CPUID_CHECK_HEADERS="#include <windows.h>"
+ X86_CPUID_CHECK_DEFINE="#define hwloc_uint64_t DWORDLONG"
else
- CPUID_CHECK_DEFINE="#define hwloc_uint64_t uint64_t"
+ X86_CPUID_CHECK_DEFINE="#define hwloc_uint64_t uint64_t"
if test "x$ac_cv_header_stdint_h" = xyes; then
- CPUID_CHECK_HEADERS="#include <stdint.h>"
+ X86_CPUID_CHECK_HEADERS="#include <stdint.h>"
fi
fi
AC_LINK_IFELSE([AC_LANG_PROGRAM([[
#include <stdio.h>
- $CPUID_CHECK_HEADERS
- $CPUID_CHECK_DEFINE
+ $X86_CPUID_CHECK_HEADERS
+ $X86_CPUID_CHECK_DEFINE
#define __hwloc_inline
- #include <private/cpuid.h>
+ #include <private/cpuid-x86.h>
]], [[
- if (hwloc_have_cpuid()) {
+ if (hwloc_have_x86_cpuid()) {
unsigned eax = 0, ebx, ecx = 0, edx;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
- printf("highest cpuid %x\n", eax);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
+ printf("highest x86 cpuid %x\n", eax);
return 0;
}
]])],
[AC_MSG_RESULT([yes])
- AC_DEFINE(HWLOC_HAVE_CPUID, 1, [Define to 1 if you have cpuid])
- hwloc_have_cpuid=yes],
+ AC_DEFINE(HWLOC_HAVE_X86_CPUID, 1, [Define to 1 if you have x86 cpuid])
+ hwloc_have_x86_cpuid=yes],
[AC_MSG_RESULT([no])])
- if test "x$hwloc_have_cpuid" = xyes; then
+ if test "x$hwloc_have_x86_cpuid" = xyes; then
hwloc_components="$hwloc_components x86"
fi
CPPFLAGS="$old_CPPFLAGS"
AM_CONDITIONAL([HWLOC_HAVE_X86_32], [test "x$hwloc_x86_32" = "xyes"])
AM_CONDITIONAL([HWLOC_HAVE_X86_64], [test "x$hwloc_x86_64" = "xyes"])
- AM_CONDITIONAL([HWLOC_HAVE_CPUID], [test "x$hwloc_have_cpuid" = "xyes"])
+ AM_CONDITIONAL([HWLOC_HAVE_X86_CPUID], [test "x$hwloc_have_x86_cpuid" = "xyes"])
AM_CONDITIONAL([HWLOC_HAVE_PLUGINS], [test "x$hwloc_have_plugins" = "xyes"])
AM_CONDITIONAL([HWLOC_PCI_BUILD_STATIC], [test "x$hwloc_pci_component" = "xstatic"])
-# Copyright © 2009-2013 Inria. All rights reserved.
+# Copyright © 2009-2014 Inria. All rights reserved.
# Copyright © 2009-2010 Université Bordeaux 1
# Copyright © 2009-2011 Cisco Systems, Inc. All rights reserved.
# Copyright © 2011 Oracle and/or its affiliates. All rights reserved.
private/misc.h \
private/xml.h \
private/components.h \
- private/cpuid.h
+ private/cpuid-x86.h
if HWLOC_HAVE_LINUX
include_hwloc_HEADERS += \
#define hwloc_flsl_from_fls32 HWLOC_NAME(flsl_from_fls32)
#define hwloc_weight_long HWLOC_NAME(weight_long)
-/* private/cpuid.h */
+/* private/cpuid-x86.h */
-#define hwloc_have_cpuid HWLOC_NAME(have_cpuid)
-#define hwloc_cpuid HWLOC_NAME(cpuid)
+#define hwloc_have_x86_cpuid HWLOC_NAME(have_x86_cpuid)
+#define hwloc_x86_cpuid HWLOC_NAME(x86_cpuid)
/* private/xml.h */
--- /dev/null
+/*
+ * Copyright © 2010-2012 Université Bordeaux 1
+ * Copyright © 2010 Cisco Systems, Inc. All rights reserved.
+ * Copyright © 2014 Inria. All rights reserved.
+ *
+ * See COPYING in top-level directory.
+ */
+
+/* Internals for x86's cpuid. */
+
+#ifndef HWLOC_PRIVATE_CPUID_X86_H
+#define HWLOC_PRIVATE_CPUID_X86_H
+
+#ifdef HWLOC_X86_32_ARCH
+static __hwloc_inline int hwloc_have_x86_cpuid(void)
+{
+ int ret;
+ unsigned tmp, tmp2;
+ asm(
+ "mov $0,%0\n\t" /* Not supported a priori */
+
+ "pushfl \n\t" /* Save flags */
+
+ "pushfl \n\t" \
+ "pop %1 \n\t" /* Get flags */ \
+
+#define TRY_TOGGLE \
+ "xor $0x00200000,%1\n\t" /* Try to toggle ID */ \
+ "mov %1,%2\n\t" /* Save expected value */ \
+ "push %1 \n\t" \
+ "popfl \n\t" /* Try to toggle */ \
+ "pushfl \n\t" \
+ "pop %1 \n\t" \
+ "cmp %1,%2\n\t" /* Compare with expected value */ \
+ "jnz Lhwloc1\n\t" /* Unexpected, failure */ \
+
+ TRY_TOGGLE /* Try to set/clear */
+ TRY_TOGGLE /* Try to clear/set */
+
+ "mov $1,%0\n\t" /* Passed the test! */
+
+ "Lhwloc1: \n\t"
+ "popfl \n\t" /* Restore flags */
+
+ : "=r" (ret), "=&r" (tmp), "=&r" (tmp2));
+ return ret;
+}
+#endif /* HWLOC_X86_32_ARCH */
+#ifdef HWLOC_X86_64_ARCH
+static __hwloc_inline int hwloc_have_x86_cpuid(void) { return 1; }
+#endif /* HWLOC_X86_64_ARCH */
+
+static __hwloc_inline void hwloc_x86_cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
+{
+ /* Note: gcc might want to use bx or the stack for %1 addressing, so we can't
+ * use them :/ */
+#ifdef HWLOC_X86_64_ARCH
+ hwloc_uint64_t sav_rbx;
+ asm(
+ "mov %%rbx,%2\n\t"
+ "cpuid\n\t"
+ "xchg %2,%%rbx\n\t"
+ "movl %k2,%1\n\t"
+ : "+a" (*eax), "=m" (*ebx), "=&r"(sav_rbx),
+ "+c" (*ecx), "=&d" (*edx));
+#elif defined(HWLOC_X86_32_ARCH)
+ unsigned long sav_ebx;
+ asm(
+ "mov %%ebx,%2\n\t"
+ "cpuid\n\t"
+ "xchg %2,%%ebx\n\t"
+ "movl %k2,%1\n\t"
+ : "+a" (*eax), "=m" (*ebx), "=&r"(sav_ebx),
+ "+c" (*ecx), "=&d" (*edx));
+#else
+#error unknown architecture
+#endif
+}
+
+#endif /* HWLOC_PRIVATE_X86_CPUID_H */
+++ /dev/null
-/*
- * Copyright © 2010-2012 Université Bordeaux 1
- * Copyright © 2010 Cisco Systems, Inc. All rights reserved.
- * Copyright © 2014 Inria. All rights reserved.
- *
- * See COPYING in top-level directory.
- */
-
-/* Internals for x86's cpuid. */
-
-#ifndef HWLOC_PRIVATE_CPUID_H
-#define HWLOC_PRIVATE_CPUID_H
-
-#ifdef HWLOC_X86_32_ARCH
-static __hwloc_inline int hwloc_have_cpuid(void)
-{
- int ret;
- unsigned tmp, tmp2;
- asm(
- "mov $0,%0\n\t" /* Not supported a priori */
-
- "pushfl \n\t" /* Save flags */
-
- "pushfl \n\t" \
- "pop %1 \n\t" /* Get flags */ \
-
-#define TRY_TOGGLE \
- "xor $0x00200000,%1\n\t" /* Try to toggle ID */ \
- "mov %1,%2\n\t" /* Save expected value */ \
- "push %1 \n\t" \
- "popfl \n\t" /* Try to toggle */ \
- "pushfl \n\t" \
- "pop %1 \n\t" \
- "cmp %1,%2\n\t" /* Compare with expected value */ \
- "jnz Lhwloc1\n\t" /* Unexpected, failure */ \
-
- TRY_TOGGLE /* Try to set/clear */
- TRY_TOGGLE /* Try to clear/set */
-
- "mov $1,%0\n\t" /* Passed the test! */
-
- "Lhwloc1: \n\t"
- "popfl \n\t" /* Restore flags */
-
- : "=r" (ret), "=&r" (tmp), "=&r" (tmp2));
- return ret;
-}
-#endif /* HWLOC_X86_32_ARCH */
-#ifdef HWLOC_X86_64_ARCH
-static __hwloc_inline int hwloc_have_cpuid(void) { return 1; }
-#endif /* HWLOC_X86_64_ARCH */
-
-static __hwloc_inline void hwloc_cpuid(unsigned *eax, unsigned *ebx, unsigned *ecx, unsigned *edx)
-{
- /* Note: gcc might want to use bx or the stack for %1 addressing, so we can't
- * use them :/ */
-#ifdef HWLOC_X86_64_ARCH
- hwloc_uint64_t sav_rbx;
- asm(
- "mov %%rbx,%2\n\t"
- "cpuid\n\t"
- "xchg %2,%%rbx\n\t"
- "movl %k2,%1\n\t"
- : "+a" (*eax), "=m" (*ebx), "=&r"(sav_rbx),
- "+c" (*ecx), "=&d" (*edx));
-#elif defined(HWLOC_X86_32_ARCH)
- unsigned long sav_ebx;
- asm(
- "mov %%ebx,%2\n\t"
- "cpuid\n\t"
- "xchg %2,%%ebx\n\t"
- "movl %k2,%1\n\t"
- : "+a" (*eax), "=m" (*ebx), "=&r"(sav_ebx),
- "+c" (*ecx), "=&d" (*edx));
-#else
-#error unknown architecture
-#endif
-}
-
-#endif /* HWLOC_PRIVATE_CPUID_H */
-# Copyright © 2009-2013 Inria. All rights reserved.
+# Copyright © 2009-2014 Inria. All rights reserved.
# Copyright © 2009-2012 Université Bordeaux 1
# Copyright © 2009-2010 Cisco Systems, Inc. All rights reserved.
# Copyright © 2011-2012 Oracle and/or its affiliates. All rights reserved.
ldflags += -lpthread
endif HWLOC_HAVE_NETBSD
-if HWLOC_HAVE_CPUID
+if HWLOC_HAVE_X86_CPUID
sources += topology-x86.c
-endif HWLOC_HAVE_CPUID
+endif HWLOC_HAVE_X86_CPUID
if HWLOC_HAVE_GCC
ldflags += -no-undefined
#include <private/debug.h>
#include <private/misc.h>
-#include <private/cpuid.h>
+#include <private/cpuid-x86.h>
#define has_topoext(features) ((features)[6] & (1 << 22))
infos->present = 1;
eax = 0x01;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
infos->apicid = ebx >> 24;
if (edx & (1 << 28))
infos->max_log_proc = 1 << hwloc_flsl(((ebx >> 16) & 0xff) - 1);
memset(regs, 0, sizeof(regs));
regs[0] = 0;
- hwloc_cpuid(®s[0], ®s[1], ®s[3], ®s[2]);
+ hwloc_x86_cpuid(®s[0], ®s[1], ®s[3], ®s[2]);
memcpy(infos->cpuvendor, regs+1, 4*3);
infos->cpuvendor[12] = '\0';
memset(regs, 0, sizeof(regs));
regs[0] = 1;
- hwloc_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
+ hwloc_x86_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
_model = (regs[0]>>4) & 0xf;
_extendedmodel = (regs[0]>>16) & 0xf;
_family = (regs[0]>>8) & 0xf;
if (highest_ext_cpuid >= 0x80000004) {
memset(regs, 0, sizeof(regs));
regs[0] = 0x80000002;
- hwloc_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
+ hwloc_x86_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
memcpy(infos->cpumodel, regs, 4*4);
regs[0] = 0x80000003;
- hwloc_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
+ hwloc_x86_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
memcpy(infos->cpumodel + 4*4, regs, 4*4);
regs[0] = 0x80000004;
- hwloc_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
+ hwloc_x86_cpuid(®s[0], ®s[1], ®s[2], ®s[3]);
memcpy(infos->cpumodel + 4*4*2, regs, 4*4);
infos->cpumodel[3*4*4] = 0;
} else
if (cpuid_type != intel && highest_ext_cpuid >= 0x80000008) {
unsigned coreidsize;
eax = 0x80000008;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
coreidsize = (ecx >> 12) & 0xf;
hwloc_debug("core ID size: %u\n", coreidsize);
if (!coreidsize) {
unsigned apic_id, node_id, nodes_per_proc, unit_id, cores_per_unit;
eax = 0x8000001e;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
infos->apicid = apic_id = eax;
infos->nodeid = node_id = ecx & 0xff;
nodes_per_proc = ((ecx >> 8) & 7) + 1;
unsigned type;
eax = 0x8000001d;
ecx = cachenum;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
type = eax & 0x1f;
if (type == 0)
break;
unsigned type;
eax = 0x8000001d;
ecx = cachenum;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
type = eax & 0x1f;
/* Intel doesn't actually provide 0x80000005 information */
if (cpuid_type != intel && highest_ext_cpuid >= 0x80000005) {
eax = 0x80000005;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
fill_amd_cache(infos, 1, ecx);
}
/* Intel doesn't actually provide 0x80000006 information */
if (cpuid_type != intel && highest_ext_cpuid >= 0x80000006) {
eax = 0x80000006;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
fill_amd_cache(infos, 2, ecx);
fill_amd_cache(infos, 3, edx);
}
unsigned type;
eax = 0x04;
ecx = cachenum;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
type = eax & 0x1f;
unsigned type;
eax = 0x04;
ecx = cachenum;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
type = eax & 0x1f;
for (level = 0; ; level++) {
ecx = level;
eax = 0x0b;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
if (!eax && !ebx)
break;
}
for (level = 0; ; level++) {
ecx = level;
eax = 0x0b;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
if (!eax && !ebx)
break;
apic_nextshift = eax & 0x1f;
set_cpubind = fake_set_cpubind;
}
- if (!hwloc_have_cpuid())
+ if (!hwloc_have_x86_cpuid())
goto out;
infos = calloc(nbprocs, sizeof(struct procinfo));
}
eax = 0x00;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
highest_cpuid = eax;
if (ebx == INTEL_EBX && ecx == INTEL_ECX && edx == INTEL_EDX)
cpuid_type = intel;
}
eax = 0x01;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
features[0] = edx;
features[4] = ecx;
eax = 0x80000000;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
highest_ext_cpuid = eax;
hwloc_debug("highest extended cpuid %x\n", highest_ext_cpuid);
if (highest_cpuid >= 0x7) {
eax = 0x7;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
features[9] = ebx;
}
if (cpuid_type != intel && highest_ext_cpuid >= 0x80000001) {
eax = 0x80000001;
- hwloc_cpuid(&eax, &ebx, &ecx, &edx);
+ hwloc_x86_cpuid(&eax, &ebx, &ecx, &edx);
features[1] = edx;
features[6] = ecx;
}
const void *_data3 __hwloc_attribute_unused)
{
struct hwloc_backend *backend;
+
backend = hwloc_backend_alloc(component);
if (!backend)
return NULL;
#include "private/autogen/config.h"
#include "private/components.h"
-#include "private/cpuid.h"
+#include "private/cpuid-x86.h"
#include "private/debug.h"
#include "private/misc.h"
#include "private/private.h"