Skip to content
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

[xla:cpu] Disable SVE LLVM codegen by default on AArch64 CPUs. #23931

Merged
merged 1 commit into from
Mar 20, 2025
Merged
Show file tree
Hide file tree
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
2 changes: 2 additions & 0 deletions xla/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1218,6 +1218,8 @@ cc_library(
"@com_google_absl//absl/log:check",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@tsl//tsl/platform",
"@tsl//tsl/platform:platform_port",
"@tsl//tsl/platform:protobuf",
],
)
Expand Down
16 changes: 15 additions & 1 deletion xla/debug_options_flags.cc
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,24 @@ limitations under the License.
#include "xla/stream_executor/cuda/ptx_compiler_support.h"
#include "xla/tsl/util/command_line_flags.h"
#include "xla/xla.pb.h"
#include "tsl/platform/cpu_info.h" // NOLINT
#include "tsl/platform/platform.h"
#include "tsl/platform/protobuf.h" // IWYU pragma: keep

namespace xla {

inline std::string DefaultMaxIsa() {
#ifdef PLATFORM_GOOGLE
return "";
#else
// There are many missing SVE lowerings in LLVM. Limit features to NEON for
// now. There shouldn't be significant performance impact as most AAarch64
// CPUs still use 128-bit registers.
// TODO(penporn): Remove this once SVE is fully supported.
return tsl::port::IsAarch64CPU() ? "NEON" : "";
#endif // PLATFORM_GOOGLE
}

DebugOptions DefaultDebugOptionsIgnoringFlags() {
DebugOptions opts;
opts.set_xla_llvm_enable_alias_scope_metadata(true);
Expand Down Expand Up @@ -96,7 +110,7 @@ DebugOptions DefaultDebugOptionsIgnoringFlags() {
opts.set_xla_cpu_copy_insertion_use_region_analysis(false);
opts.set_xla_cpu_enable_concurrency_optimized_scheduler(true);
opts.set_xla_cpu_prefer_vector_width(256);
opts.set_xla_cpu_max_isa("");
opts.set_xla_cpu_max_isa(DefaultMaxIsa());
opts.set_xla_cpu_generate_unique_c_style_kernel_entry_points(false);

opts.set_xla_cpu_enable_fast_math(false);
Expand Down
1 change: 1 addition & 0 deletions xla/service/cpu/tests/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -337,6 +337,7 @@ xla_cc_test(
"@llvm-project//llvm:ARMCodeGen", # fixdeps: keep
"@llvm-project//llvm:Target",
"@llvm-project//llvm:X86CodeGen", # fixdeps: keep
"@tsl//tsl/platform",
"@tsl//tsl/platform:platform_port",
],
)
Expand Down
15 changes: 15 additions & 0 deletions xla/service/cpu/tests/cpu_vectorization_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ limitations under the License.
#include "xla/xla.pb.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/cpu_info.h"
#include "tsl/platform/platform.h"

namespace xla {
namespace cpu {
Expand Down Expand Up @@ -233,6 +234,20 @@ INSTANTIATE_TEST_SUITE_P(AArch64MaxIsaTestInstantiation, AArch64MaxIsaTest,
::testing::ValuesIn(GetAArch64MaxIsaTestCases()),
AArch64MaxIsaTest::Name);

class DefaultMaxIsaTest : public CpuCodegenTest {};

TEST_F(DefaultMaxIsaTest, NeonForOssAArch64) {
if (!tsl::port::IsAarch64CPU()) {
GTEST_SKIP() << "This test is for AArch64 CPUs.";
}
DebugOptions debug_options = HloTestBase::GetDebugOptionsForTest();
#ifdef PLATFORM_GOOGLE
EXPECT_EQ(debug_options.xla_cpu_max_isa(), "");
#else
EXPECT_EQ(debug_options.xla_cpu_max_isa(), "NEON");
#endif // PLATFORM_GOOGLE
}

struct JitVectorizationTestSpec {
HloOpcode opcode;
std::string max_isa;
Expand Down