Skip to content

Commit

Permalink
detect clang 19, print in list_targets, enable SVE for clang 19
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 729654866
  • Loading branch information
scweng authored and copybara-github committed Feb 21, 2025
1 parent 40ace75 commit f1fc7e7
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 50 deletions.
4 changes: 1 addition & 3 deletions hwy/detect_compiler_arch.h
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,7 @@
// https://github.com/simd-everywhere/simde/blob/47d6e603de9d04ee05cdfbc57cf282a02be1bf2a/simde/simde-detect-clang.h#L59.
// Please send updates below to them as well, thanks!
#if defined(__apple_build_version__) || __clang_major__ >= 999
#if __has_warning("-Wreturn-mismatch")
#define HWY_COMPILER_CLANG 1901
#elif __has_warning("-Woverriding-option")
#if __has_warning("-Woverriding-option")
#define HWY_COMPILER_CLANG 1801
// No new warnings in 17.0, and Apple LLVM 15.3, which should be 1600, already
// has the unsafe_buffer_usage attribute, so we instead check for new builtins.
Expand Down
58 changes: 12 additions & 46 deletions hwy/tests/list_targets.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,30 +19,24 @@
#include <stdint.h>
#include <stdio.h>

#include "hwy/detect_compiler_arch.h"
#include "hwy/highway.h"

namespace {

void PrintCompiler() {
if (HWY_COMPILER_CLANG) {
fprintf(stderr, "Compiler: Clang %d\n", HWY_COMPILER_CLANG);
} else if (HWY_COMPILER_CLANGCL) {
fprintf(stderr, "Compiler: Clang-cl %d\n", HWY_COMPILER_CLANGCL);
} else if (HWY_COMPILER_GCC_ACTUAL) {
fprintf(stderr, "Compiler: GCC %d\n", HWY_COMPILER_GCC_ACTUAL);
} else if (HWY_COMPILER_ICC) {
fprintf(stderr, "Compiler: ICC %d\n", HWY_COMPILER_ICC);
} else if (HWY_COMPILER_ICX) {
fprintf(stderr, "Compiler: ISX %d\n", HWY_COMPILER_ICX);
} else if (HWY_COMPILER_MSVC) {
fprintf(stderr, "Compiler: MSVC %d\n", HWY_COMPILER_MSVC);
} else {
fprintf(stderr, "Compiler unknown!\n");
void PrintTargets(const char* msg, int64_t targets) {
fprintf(stderr, "%s", msg);
// For each bit other than the sign bit:
for (int64_t x = targets & hwy::LimitsMax<int64_t>(); x != 0;
x = x & (x - 1)) {
// Extract value of least-significant bit.
fprintf(stderr, " %s", hwy::TargetName(x & (~x + 1)));
}
fprintf(stderr, "\n");
}

void PrintConfig() {
} // namespace

int main() {
#ifdef HWY_COMPILE_ONLY_EMU128
const int only_emu128 = 1;
#else
Expand All @@ -68,38 +62,10 @@ void PrintConfig() {
#else
const int is_test = 0;
#endif

fprintf(stderr,
"Config: emu128:%d scalar:%d static:%d all_attain:%d is_test:%d\n",
only_emu128, only_scalar, only_static, all_attain, is_test);
}

void PrintHave() {
fprintf(stderr,
"Have: runtime_dispatch:%d auxv:%d f16 type:%d/ops%d bf16 "
"type:%d/ops%d\n",
HWY_HAVE_RUNTIME_DISPATCH, HWY_HAVE_AUXV, HWY_HAVE_SCALAR_F16_TYPE,
HWY_HAVE_SCALAR_F16_OPERATORS, HWY_HAVE_SCALAR_BF16_TYPE,
HWY_HAVE_SCALAR_BF16_OPERATORS);
}

void PrintTargets(const char* msg, int64_t targets) {
fprintf(stderr, "%s", msg);
// For each bit other than the sign bit:
for (int64_t x = targets & hwy::LimitsMax<int64_t>(); x != 0;
x = x & (x - 1)) {
// Extract value of least-significant bit.
fprintf(stderr, " %s", hwy::TargetName(x & (~x + 1)));
}
fprintf(stderr, "\n");
}

} // namespace

int main() {
PrintCompiler();
PrintConfig();
PrintHave();

PrintTargets("Compiled HWY_TARGETS: ", HWY_TARGETS);
PrintTargets("HWY_ATTAINABLE_TARGETS:", HWY_ATTAINABLE_TARGETS);
PrintTargets("HWY_BASELINE_TARGETS: ", HWY_BASELINE_TARGETS);
Expand Down
2 changes: 1 addition & 1 deletion hwy/tests/swizzle_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ struct TestInsertLane {
#endif

// TODO(janwas): file compiler bug report
#if HWY_COMPILER_CLANG && (HWY_COMPILER_CLANG < 2000) && HWY_ARCH_ARM
#if HWY_COMPILER_CLANG && (HWY_COMPILER_CLANG < 1900) && HWY_ARCH_ARM
if (IsSpecialFloat<T>()) return;
#endif

Expand Down

0 comments on commit f1fc7e7

Please sign in to comment.