Skip to content
Open
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
35 changes: 31 additions & 4 deletions src/common/cpuinfo/CpuInfo.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -58,8 +58,10 @@
#include <asm/hwcap.h> /* Get HWCAP bits from asm/hwcap.h */
#include <sys/auxv.h>
#elif (defined(__OpenBSD__) || defined(__FreeBSD__) || defined(__APPLE__)) && defined(__aarch64__)
#include <sys/auxv.h>
Copy link
Copy Markdown
Contributor

@gunes-arm gunes-arm Mar 30, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

src/common/cpuinfo/CpuInfo.cpp:61:10: fatal error: 'sys/auxv.h' file not found

[2026-03-30T10:27:39.458Z]    61 | #include <sys/auxv.h>

We had this error in the CI for macOS build. It'd be better if you confine these inclusions to OpenBSD and FreeBSD as you don't change anything for macOS HW capability detection.

#include <sys/sysctl.h>
#include <sys/types.h>
#include <unistd.h>
#endif /* defined(__APPLE__) && defined(__aarch64__)) */
#endif /* !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && !defined(__FreeBSD__) && !defined(__QNX__) && (defined(__arm__) || defined(__aarch64__)) */

Expand Down Expand Up @@ -435,8 +437,33 @@ CpuInfo CpuInfo::build()
std::vector<CpuModel> cpus_model(1, midr_to_model(midr));
CpuInfo info(isa, cpus_model);
return info;
#elif defined(__aarch64__) && (defined(__OpenBSD__) || defined(__FreeBSD__) || \
defined(__APPLE__)) /* #elif(BARE_METAL) && defined(__aarch64__) */

#elif defined(__aarch64__) && (defined(__OpenBSD__) || defined(__FreeBSD__))
/* #elif(BARE_METAL) && defined(__aarch64__) */
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't seem to be in the right place. And, is this accurate?

int ncpus = sysconf(_SC_NPROCESSORS_ONLN);

unsigned long hwcap = 0, hwcap2 = 0;
elf_aux_info(AT_HWCAP, &hwcap, sizeof(hwcap));
elf_aux_info(AT_HWCAP2, &hwcap2, sizeof(hwcap2));

CpuIsaInfo isainfo;
std::vector<CpuModel> cpus_model(ncpus);

isainfo.neon = (hwcap & HWCAP_ASIMD) != 0;
isainfo.fp16 = (hwcap & HWCAP_FPHP) != 0;
isainfo.dot = (hwcap & HWCAP_ASIMDDP) != 0;
isainfo.bf16 = (hwcap2 & HWCAP2_BF16) != 0;
isainfo.i8mm = (hwcap2 & HWCAP2_I8MM) != 0;
isainfo.sme = (hwcap2 & HWCAP2_SME) != 0;
isainfo.sme2 = (hwcap2 & HWCAP2_SME2) != 0;
isainfo.sme_f32f32 = (hwcap2 & HWCAP2_SME_F32F32) != 0;
isainfo.sme_i8i32 = (hwcap2 & HWCAP2_SME_I8I32) != 0;
isainfo.sme_f16f32 = (hwcap2 & HWCAP2_SME_F16F32) != 0;
isainfo.sme_b16f32 = (hwcap2 & HWCAP2_SME_B16F32) != 0;
CpuInfo info(isainfo, cpus_model);
return info;

#elif defined(__aarch64__) && defined(__APPLE__)
int ncpus = get_hw_capability("hw.perflevel0.logicalcpu");
CpuIsaInfo isainfo;
std::vector<CpuModel> cpus_model(ncpus);
Expand All @@ -453,7 +480,7 @@ CpuInfo CpuInfo::build()
isainfo.sme2 = get_hw_capability("hw.optional.arm.FEAT_SME2");
CpuInfo info(isainfo, cpus_model);
return info;
#elif defined(__aarch64__) && defined(_WIN64) /* #elif defined(__aarch64__) && defined(__APPLE__) */
#elif defined(__aarch64__) && defined(_WIN64) /* #elif defined(__aarch64__) && defined(__APPLE__) */
CpuIsaInfo isainfo;

isainfo.neon = IsProcessorFeaturePresent(PF_ARM_NEON_INSTRUCTIONS_AVAILABLE);
Expand Down Expand Up @@ -485,7 +512,7 @@ CpuInfo CpuInfo::build()
std::vector<CpuModel> cpus_model(ncpus);
CpuInfo info(isainfo, cpus_model);
return info;
#else /* #elif defined(__aarch64__) && defined(_WIN64) */
#else /* #elif defined(__aarch64__) && defined(_WIN64) */
CpuInfo info(CpuIsaInfo(), {CpuModel::GENERIC});
return info;
#endif /* !defined(BARE_METAL) && !defined(__APPLE__) && !defined(__OpenBSD__) && (defined(__arm__) || defined(__aarch64__)) */
Expand Down