8000 ENH: Detect CPU features on OpenBSD ARM and PowerPC64 by charris · Pull Request #29241 · numpy/numpy · GitHub
[go: up one dir, main page]

Skip to content

ENH: Detect CPU features on OpenBSD ARM and PowerPC64 #29241

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 20, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions numpy/_core/src/common/npy_cpu_features.c
Original file line number Diff line number Diff line change
Expand Up @@ -562,7 +562,7 @@ npy__cpu_init_features(void)

#elif defined(NPY_CPU_PPC64) || defined(NPY_CPU_PPC64LE)

#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#ifdef __FreeBSD__
#include <machine/cpu.h> // defines PPC_FEATURE_HAS_VSX
#endif
Expand All @@ -585,7 +585,7 @@ static void
npy__cpu_init_features(void)
{
memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
#ifdef __linux__
unsigned int hwcap = getauxval(AT_HWCAP);
if ((hwcap & PPC_FEATURE_HAS_VSX) == 0)
Expand All @@ -612,7 +612,7 @@ npy__cpu_init_features(void)
npy__cpu_have[NPY_CPU_FEATURE_VSX2] = (hwcap & PPC_FEATURE2_ARCH_2_07) != 0;
npy__cpu_have[NPY_CPU_FEATURE_VSX3] = (hwcap & PPC_FEATURE2_ARCH_3_00) != 0;
npy__cpu_have[NPY_CPU_FEATURE_VSX4] = (hwcap & PPC_FEATURE2_ARCH_3_1) != 0;
// TODO: AIX, OpenBSD
// TODO: AIX
#else
npy__cpu_have[NPY_CPU_FEATURE_VSX] = 1;
#if defined(NPY_CPU_PPC64LE) || defined(NPY_HAVE_VSX2)
Expand Down Expand Up @@ -698,7 +698,7 @@ npy__cpu_init_features_arm8(void)
npy__cpu_have[NPY_CPU_FEATURE_ASIMD] = 1;
}

#if defined(__linux__) || defined(__FreeBSD__)
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
/*
* we aren't sure of what kind kernel or clib we deal with
* so we play it safe
Expand All @@ -709,7 +709,7 @@ npy__cpu_init_features_arm8(void)
#if defined(__linux__)
__attribute__((weak)) unsigned long getauxval(unsigned long); // linker should handle it
#endif
#ifdef __FreeBSD__
#if defined(__FreeBSD__) || defined(__OpenBSD__)
__attribute__((weak)) int elf_aux_info(int, void *, int); // linker should handle it

static unsigned long getauxval(unsigned long k)
Expand Down Expand Up @@ -807,7 +807,7 @@ static void
npy__cpu_init_features(void)
{
memset(npy__cpu_have, 0, sizeof(npy__cpu_have[0]) * NPY_CPU_FEATURE_MAX);
#ifdef __linux__
#if defined(__linux__) || defined(__FreeBSD__) || defined(__OpenBSD__)
if (npy__cpu_init_features_linux())
return;
#endif
Expand Down
Loading
0