Skip to content

Commit 065cb80

Browse files
authored
fix: avx check in conditional (#7893)
**Motivation** Fix check for AVX conditional. Needs to follow what was done in: https://github.com/OffchainLabs/hashtree/blob/main/bindings_amd64.go Original PR just looked at the hashtree bindings here: https://github.com/OffchainLabs/hashtree/blob/main/src/hashtree.c#L42
1 parent b3a6f46 commit 065cb80

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

packages/cli/src/applyPreset.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ import CpuFeatures from "cpu-features";
77
// without setting this first, persistent-merkle-tree will use noble instead
88
const cpuFeatures = CpuFeatures();
99
if (
10-
cpuFeatures.arch === "x86" &&
11-
!(cpuFeatures.flags.avx || cpuFeatures.flags.avx2 || cpuFeatures.flags.avx512f || cpuFeatures.flags.avx512vl)
10+
(cpuFeatures.arch === "x86" &&
11+
!(
12+
(cpuFeatures.flags.avx512f && cpuFeatures.flags.avx512vl) ||
13+
(cpuFeatures.flags.avx2 && cpuFeatures.flags.bmi2) ||
14+
(cpuFeatures.flags.avx && cpuFeatures.flags.sha)
15+
)) ||
16+
(cpuFeatures.arch === "aarch64" && !cpuFeatures.flags.sha2)
1217
) {
1318
console.log(
1419
"Hashtree hasher is preferred but the CPU architecture does not support AVX, AVX2 or the correct AVX512 instruction sets. Falling back to as-sha256 hasher instead."

packages/prover/src/cli/applyPreset.ts

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,13 @@ import CpuFeatures from "cpu-features";
77
// without setting this first, persistent-merkle-tree will use noble instead
88
const cpuFeatures = CpuFeatures();
99
if (
10-
cpuFeatures.arch === "x86" &&
11-
!(cpuFeatures.flags.avx || cpuFeatures.flags.avx2 || cpuFeatures.flags.avx512f || cpuFeatures.flags.avx512vl)
10+
(cpuFeatures.arch === "x86" &&
11+
!(
12+
(cpuFeatures.flags.avx512f && cpuFeatures.flags.avx512vl) ||
13+
(cpuFeatures.flags.avx2 && cpuFeatures.flags.bmi2) ||
14+
(cpuFeatures.flags.avx && cpuFeatures.flags.sha)
15+
)) ||
16+
(cpuFeatures.arch === "aarch64" && !cpuFeatures.flags.sha2)
1217
) {
1318
// biome-ignore lint/suspicious/noConsole: let consumer know that the default hasher is not supported
1419
console.log(

0 commit comments

Comments
 (0)