diff --git a/README.md b/README.md index efb843f..ff11898 100644 --- a/README.md +++ b/README.md @@ -71,7 +71,10 @@ std.debug.print("{f}\n", .{ten}); // 0-306-40615-2 ## Build options - `-Dsimd=[bool]` — use SIMD vector operations for computing check - digits (default: `true`). + digits (default: `false`). It is off because it does not pay: `zig + build bench` measures both implementations, and nine or twelve lanes + of multiply-and-add do not earn back the cost of widening the digits + and assembling the vector. ## Standards diff --git a/build.zig b/build.zig index a837ece..8245245 100644 --- a/build.zig +++ b/build.zig @@ -7,7 +7,13 @@ pub fn build(b: *std.Build) void { const target = b.standardTargetOptions(.{}); const optimize = b.standardOptimizeOption(.{}); - const simd = b.option(bool, "simd", "Use SIMD for computing check digits.") orelse true; + // Off by default, because it does not pay. `zig build bench` measures + // both: the ISBN-13 checksum comes out about level and the ISBN-10 one + // comes out slower, since nine lanes of multiply-and-add do not earn + // back the cost of widening the digits and assembling the vector. The + // option stays so the two implementations can be compared, and so + // anyone whose target says otherwise can turn it on. + const simd = b.option(bool, "simd", "Use SIMD for computing check digits.") orelse false; const options = b.addOptions(); options.addOption(bool, "simd", simd);