Skip to content

Commit bccaaba

Browse files
jan-wassenbergcopybara-github
authored andcommitted
Disable AVX10.2 as further fallout from llvm/llvm-project/pull/157034
Also expand list_targets to use foreach_target so that it prints the best available target attributes. PiperOrigin-RevId: 810355944
1 parent dfe4049 commit bccaaba

File tree

4 files changed

+46
-13
lines changed

4 files changed

+46
-13
lines changed

BUILD

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,10 @@ cc_test(
502502
name = "list_targets",
503503
size = "small",
504504
srcs = ["hwy/tests/list_targets.cc"],
505-
deps = [":hwy"],
505+
deps = [
506+
":hwy",
507+
":timer",
508+
],
506509
)
507510

508511
cc_test(

hwy/detect_targets.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -195,10 +195,10 @@
195195
#endif // HWY_BROKEN_MSVC
196196

197197
#ifndef HWY_BROKEN_AVX10_2 // allow override
198-
// AVX10_2 requires clang >= 20.1 (postpone to 22 due to "avx10.2-512" remnant,
198+
// AVX10_2 requires clang >= 20.1 (postpone to 23 due to "avx10.2-512" remnant,
199199
// only removed in https://github.com/llvm/llvm-project/pull/157034) or
200200
// gcc >= 15.2 with binutils 2.44.
201-
#if (HWY_COMPILER_CLANG < 2200) && (HWY_COMPILER_GCC_ACTUAL < 1502)
201+
#if (HWY_COMPILER_CLANG < 2300) && (HWY_COMPILER_GCC_ACTUAL < 1502)
202202
#define HWY_BROKEN_AVX10_2 HWY_AVX10_2
203203
#else
204204
#define HWY_BROKEN_AVX10_2 0

hwy/ops/set_macros-inl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,11 @@
188188
#endif
189189

190190
#if HWY_COMPILER_GCC_ACTUAL >= 1500 || HWY_COMPILER_CLANG >= 2200
191+
#if HWY_HAVE_EVEX512
192+
#define HWY_TARGET_STR_AVX10_2 HWY_TARGET_STR_AVX3_SPR ",avx10.2-512"
193+
#else
191194
#define HWY_TARGET_STR_AVX10_2 HWY_TARGET_STR_AVX3_SPR ",avx10.2"
195+
#endif // HWY_HAVE_EVEX512
192196
#else
193197
#define HWY_TARGET_STR_AVX10_2 HWY_TARGET_STR_AVX3_SPR
194198
#endif

hwy/tests/list_targets.cc

Lines changed: 36 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,16 @@
2020
#include <stdio.h>
2121

2222
#include "hwy/detect_compiler_arch.h"
23+
#include "hwy/timer.h" // GetCpuString
24+
25+
#undef HWY_TARGET_INCLUDE
26+
#define HWY_TARGET_INCLUDE "hwy/tests/list_targets.cc"
27+
#include "hwy/foreach_target.h" // IWYU pragma: keep
2328
#include "hwy/highway.h"
2429

25-
namespace {
30+
HWY_BEFORE_NAMESPACE();
31+
namespace hwy {
32+
namespace HWY_NAMESPACE {
2633

2734
void PrintCompiler() {
2835
if (HWY_COMPILER_ICX) {
@@ -80,9 +87,8 @@ void PrintConfig() {
8087
const char* target_str = "";
8188
#endif
8289
fprintf(stderr,
83-
"Target attributes: %s\nConfig: emu128:%d scalar:%d static:%d "
84-
"all_attain:%d "
85-
"is_test:%d\n",
90+
"Target attributes: %s\n"
91+
"Config: emu128:%d scalar:%d static:%d all_attain:%d is_test:%d\n",
8692
target_str, only_emu128, only_scalar, only_static, all_attain,
8793
is_test);
8894
}
@@ -99,8 +105,7 @@ void PrintHave() {
99105
void PrintTargets(const char* msg, int64_t targets) {
100106
fprintf(stderr, "%s", msg);
101107
// For each bit other than the sign bit:
102-
for (int64_t x = targets & hwy::LimitsMax<int64_t>(); x != 0;
103-
x = x & (x - 1)) {
108+
for (int64_t x = targets & 0x7FFFFFFFFFFFFFFFLL; x != 0; x = x & (x - 1)) {
104109
// Extract value of least-significant bit.
105110
fprintf(stderr, " %s", hwy::TargetName(x & (~x + 1)));
106111
}
@@ -116,9 +121,7 @@ void TestVisitor() {
116121
}
117122
}
118123

119-
} // namespace
120-
121-
int main() {
124+
void PrintAll() {
122125
PrintCompiler();
123126
PrintConfig();
124127
PrintHave();
@@ -129,7 +132,30 @@ int main() {
129132
PrintTargets("HWY_STATIC_TARGET: ", HWY_STATIC_TARGET);
130133
PrintTargets("HWY_BROKEN_TARGETS: ", HWY_BROKEN_TARGETS);
131134
PrintTargets("HWY_DISABLED_TARGETS: ", HWY_DISABLED_TARGETS);
132-
PrintTargets("Current CPU supports: ", hwy::SupportedTargets());
135+
PrintTargets("CPU supports: ", hwy::SupportedTargets());
136+
137+
char cpu100[100];
138+
(void)platform::GetCpuString(cpu100);
139+
fprintf(stderr, "CPU: %s\n", cpu100);
140+
133141
TestVisitor();
142+
}
143+
144+
// NOLINTNEXTLINE(google-readability-namespace-comments)
145+
} // namespace HWY_NAMESPACE
146+
} // namespace hwy
147+
HWY_AFTER_NAMESPACE();
148+
149+
#if HWY_ONCE
150+
namespace hwy {
151+
namespace {
152+
HWY_EXPORT(PrintAll);
153+
void CallPrintAll() { HWY_DYNAMIC_DISPATCH(PrintAll)(); }
154+
} // namespace
155+
} // namespace hwy
156+
157+
int main() {
158+
hwy::CallPrintAll();
134159
return 0;
135160
}
161+
#endif // HWY_ONCE

0 commit comments

Comments
 (0)