Skip to content

Commit

Permalink
disable AVX512 until Zig issue is resolved
Browse files Browse the repository at this point in the history
  • Loading branch information
mitchellh committed Jun 24, 2024
1 parent 13d4ec4 commit 09080eb
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 6 deletions.
30 changes: 25 additions & 5 deletions build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -1028,11 +1028,31 @@ fn addDeps(
// C++ files
step.linkLibCpp();
step.addIncludePath(b.path("src"));
step.addCSourceFiles(.{ .files = &.{
"src/simd/codepoint_width.cpp",
"src/simd/index_of.cpp",
"src/simd/vt.cpp",
} });
{
// From hwy/detect_targets.h
const HWY_AVX3_SPR: c_int = 1 << 4;
const HWY_AVX3_ZEN4: c_int = 1 << 6;
const HWY_AVX3_DL: c_int = 1 << 7;
const HWY_AVX3: c_int = 1 << 8;

// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// To workaround this we just disable AVX512 support completely.
// The performance difference between AVX2 and AVX512 is not
// significant for our use case and AVX512 is very rare on consumer
// hardware anyways.
const HWY_DISABLED_TARGETS: c_int = HWY_AVX3_SPR | HWY_AVX3_ZEN4 | HWY_AVX3_DL | HWY_AVX3;

step.addCSourceFiles(.{
.files = &.{
"src/simd/codepoint_width.cpp",
"src/simd/index_of.cpp",
"src/simd/vt.cpp",
},
.flags = if (step.rootModuleTarget().cpu.arch == .x86_64) &.{
b.fmt("-DHWY_DISABLED_TARGETS={}", .{HWY_DISABLED_TARGETS}),
} else &.{},
});
}

// If we're building a lib we have some different deps
const lib = step.kind == .lib;
Expand Down
4 changes: 3 additions & 1 deletion pkg/simdutf/build.zig
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,9 @@ pub fn build(b: *std.Build) !void {

var flags = std.ArrayList([]const u8).init(b.allocator);
defer flags.deinit();
try flags.appendSlice(&.{});
// Zig 0.13 bug: https://github.com/ziglang/zig/issues/20414
// (See root Ghostty build.zig on why we do this)
try flags.appendSlice(&.{"-DSIMDUTF_IMPLEMENTATION_ICELAKE=0"});

lib.addCSourceFiles(.{
.flags = flags.items,
Expand Down

0 comments on commit 09080eb

Please sign in to comment.