Skip to content

Toolchain: Remove OpenBLAS-based architecture detection - #7971

Merged
mohanchen merged 1 commit into
deepmodeling:developfrom
Growl1234:toolchain
Sep 27, 2026
Merged

mohanchen merged 1 commit into
deepmodeling:developfrom
Growl1234:toolchain

Conversation

@Growl1234

Copy link
Copy Markdown

Replace OPENBLAS_ARCH with a lightweight host architecture detection based on uname -m, normalizing only known equivalent names such as x86_64/amd64 and aarch64/arm64.

Also remove OPENBLAS_LIBCORE and get_openblas_arch.sh. For native builds, OpenBLAS already performs its own CPU/core detection when TARGET is not specified, while the existing DYNAMIC_ARCH fallback is preserved.

This removes an unnecessary OpenBLAS download/probe from the early toolchain stages and simplifies the architecture handling.

See also cp2k/cp2k#6023.

Copilot AI lite review requested due to automatic review settings September 15, 2026 09:56
@Growl1234

Copy link
Copy Markdown
Author

Toolchain Quick Test failed because cmake.org is down.

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

Preserve the existing MKL i386/ia32 mapping and clarify or restore the changed OpenBLAS fallback behavior.

Get a fresh assessment by requesting another Copilot review.

Pull request overview

Replaces OpenBLAS-based architecture probing with normalized uname -m detection and simplifies toolchain architecture handling.

Changes:

  • Adds SYSTEM_ARCH normalization across toolchain installers.
  • Updates OpenBLAS target and fallback behavior.
  • Removes obsolete OpenBLAS variables and probe script.
File summaries
File Summary
toolchain/scripts/stage3/install_elpa.sh Uses normalized architecture for CPU feature detection.
toolchain/scripts/stage2/install_openblas.sh Updates target selection and fallback behavior; fallback policy requires clarification.
toolchain/scripts/stage2/install_mkl.sh Uses SYSTEM_ARCH; currently rejects i386 before the prior ia32 mapping.
toolchain/scripts/stage1/install_openmpi.sh Uses normalized architecture for compatibility flags.
toolchain/scripts/stage0/setup_buildtools.sh Removes the OpenBLAS architecture probe.
toolchain/scripts/stage0/install_cmake.sh Selects CMake artifacts by system architecture.
toolchain/scripts/package_versions.sh Removes OpenBLAS-dependent checksum selection.
toolchain/scripts/get_openblas_arch.sh Removes the obsolete probe script.
toolchain/scripts/common_vars.sh Defines normalized host architecture detection.
Review details
  • Files reviewed: 9/9 changed files
  • Comments generated: 2
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

Comment thread toolchain/scripts/stage2/install_mkl.sh Outdated
Comment thread toolchain/scripts/stage2/install_openblas.sh Outdated
@Growl1234
Growl1234 force-pushed the toolchain branch 4 times, most recently from 40564f4 to bbb1972 Compare September 15, 2026 14:05
@mohanchen mohanchen added the Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS label Sep 16, 2026
QuantumMisaka

This comment was marked as duplicate.

@QuantumMisaka

QuantumMisaka commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

Additional runtime/benchmark evidence

Using a reviewer-side validation copy that preserves this PR’s strategy but changes OpenBLAS to “build first, then install separately”:

  • evox3 / AMD Zen5: the old base generic strategy maps to NEHALEM; this PR’s DYNAMIC_ARCH=1 selects Cooperlake at runtime.
  • SAI / Intel Sapphire Rapids: this PR’s DYNAMIC_ARCH=1 selects SapphireRapids at runtime.
  • Local / AMD Zen2: native selects ZEN, and an ABACUS Si2 PW SCF smoke test converges.

evox3 DGEMM comparison:

OpenBLAS strategy Runtime core n / threads GFLOPS
base generic -> NEHALEM NEHALEM 2048 / 8 208.0
corrected PR generic -> DYNAMIC_ARCH=1 Cooperlake 2048 / 8 915.9
base generic -> NEHALEM NEHALEM 4096 / 16 420.9
corrected PR generic -> DYNAMIC_ARCH=1 Cooperlake 4096 / 16 1566.9

SAI corrected dynamic results:

n / threads Runtime core GFLOPS
2048 / 8 SapphireRapids 828.0
4096 / 16 SapphireRapids 920.5

These results support keeping the new uname -m + OpenBLAS native/DYNAMIC_ARCH strategy. On the originally reviewed head they did not change the Request Changes verdict because the native and clean dynamic build/install flows were broken.

Follow-up on the pushed head f1aedb9: a clean current-head native run and a clean current-head generic/DYNAMIC_ARCH=1 run both completed build and install locally on AMD Zen2. The installed artifacts and install_successful were present, and the runtime cores were ZEN/Zen respectively. These runs are recorded in the newer current-head review.

@QuantumMisaka QuantumMisaka left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

STALE / SUPERSEDED: this review targeted the earlier head. The current active review is 5325119623, which approves the pushed head after its build/install fixes.

Summary: Request changes

Supersedes my earlier review. Submitted PR reviews cannot be edited or dismissed by their author, so the obsolete Chinese summary remains visible. Please treat this English review as the active review; the corresponding Chinese inline comments have already been deleted.

I am not opposed to the direction here. Replacing OpenBLAS-derived architecture probing with uname -m, letting OpenBLAS auto-detect the CPU for native builds, and using DYNAMIC_ARCH=1 for non-native builds is a reasonable simplification. After fixing the build/install ordering, my validation shows that the new strategy works on AMD Zen5 and Intel Sapphire Rapids and selects sensible runtime kernels.

However, the current implementation is not mergeable: the native path builds OpenBLAS but never installs it, and the clean non-native path combines the first build and install in one make invocation, which fails with OpenBLAS 0.3.33. This is a core toolchain deliverable issue, not a style preference.

Runtime validation of the current patch

Host Run Result
Local AMD Ryzen 9 3950X / Zen2 native OpenBLAS build and tests pass, but there is no make install; install/openblas-0.3.33 is absent and the toolchain fails at install_successful
evox3 AMD Ryzen AI MAX+ 395 / Zen5 native Same failure: build products remain in the source tree; libopenblas_cooperlakep-r0.3.33.so exists, but the install directory does not
SAI Intel Xeon w9-3575X / Sapphire Rapids native Same failure
SAI Intel Xeon w9-3575X / Sapphire Rapids generic Dynamic branch fails in about five seconds: Makefile.install:49: *** OpenBLAS: Please run "make" firstly.

Reviewer-side two-stage build/install validation

For validation only, I changed OpenBLAS to run make first and then run make ... install separately. This is not a request to copy that exact diff.

With that temporary change:

  • the full GNU toolchain succeeds locally;
  • native OpenBLAS reports core=ZEN;
  • ABACUS builds successfully;
  • the Si2 PW SCF smoke test converges at FINAL_ETOT_IS -215.5056984233572 eV;
  • ldd confirms ABACUS links to the toolchain-installed OpenBLAS;
  • corrected DYNAMIC_ARCH succeeds on evox3 and selects Cooperlake;
  • corrected DYNAMIC_ARCH succeeds on SAI and selects SapphireRapids.

So the strategy is worth preserving, but the implementation must be fixed first.

Blocking findings

  1. The native branch runs make but never runs make ... install.
  2. The non-native branch runs make ... install from a clean tree; OpenBLAS must be built first and installed separately.
  3. Before falling back from native to dynamic, the OpenBLAS source tree must be removed/re-extracted or otherwise reliably cleaned; native-generated metadata and objects can pollute the dynamic build.
  4. The PR description says the existing DYNAMIC_ARCH fallback is preserved. That is inaccurate: the old fallback used TARGET=NEHALEM, not DYNAMIC_ARCH. The non-native semantics are also changing from fixed targets to dynamic dispatch and must be stated explicitly.
  5. Installation success should not be inferred solely from a make return code. Check ${pkg_install_dir}/lib/libopenblas* and ${pkg_install_dir}/include/openblas_config.h before writing install_successful.

Minor / documentation

  • The --target-cpu help/docs need updating: every value other than native now uses DYNAMIC_ARCH; mappings such as broadwell/skylake -> HASWELL have been replaced.
  • If 32-bit MKL support remains intended, uname -m commonly reports i686 on 32-bit x86 Linux, not i386; normalize i?86 -> i386 or explicitly document dropping 32-bit support.
  • A small clean-room CI/local check would be valuable: fresh native, fresh generic, artifact checks, openblas_get_corename(), ABACUS build, and one minimal SCF.

Merge checklist

  • fresh native build + install succeeds;
  • fresh generic / DYNAMIC_ARCH build + install succeeds;
  • native-to-dynamic fallback rebuilds from clean sources;
  • installed tree contains shared library, headers, pkgconfig, and install_successful;
  • ScaLAPACK/ELPA link against the installed OpenBLAS;
  • ABACUS links the toolchain OpenBLAS and passes a minimal SCF;
  • PR description says that the old NEHALEM fallback and fixed target mapping are replaced;
  • --target-cpu documentation is updated.

@Growl1234
Growl1234 force-pushed the toolchain branch 2 times, most recently from 80edf6b to f1aedb9 Compare September 26, 2026 07:56

@QuantumMisaka QuantumMisaka left a comment •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Follow-up review of f1aedb9

This review supersedes my two earlier CHANGES_REQUESTED reviews on the previous head. I cannot dismiss my own submitted reviews, so those stale review bodies remain visible; this current-head review is the active review.

Thanks for the update. The two build/install blockers from my earlier review are fixed: OpenBLAS now builds before running make install in both the native and dynamic paths, and the native-to-dynamic fallback runs make clean before the dynamic build.

I re-ran the current OpenBLAS installer from a clean tree on local AMD Zen2:

Run Result
native Build + install succeeded in about 3 minutes; shared library, headers, and install_successful were present; openblas_get_corename() reported ZEN
generic / DYNAMIC_ARCH=1 Build + install succeeded in about 9 minutes; shared library, headers, and install_successful were present; runtime reported Zen

Together with the earlier multi-host benchmark results in my follow-up comment, this supports the new uname -m + OpenBLAS native/DYNAMIC_ARCH strategy.

Remaining items are non-blocking:

  • The PR description still says the existing DYNAMIC_ARCH fallback is preserved. That is inaccurate: the old fallback was TARGET=NEHALEM, not DYNAMIC_ARCH. Please state that this PR changes non-native behavior from fixed target mapping to dynamic dispatch.
  • --target-cpu help/docs should say that every value other than native now uses dynamic dispatch.
  • See the two inline non-blocking robustness suggestions: explicit OpenBLAS artifact checks and a non-empty CMake checksum guard.

Comment thread toolchain/scripts/stage2/install_openblas.sh
Comment thread toolchain/scripts/stage0/install_cmake.sh
@QuantumMisaka

QuantumMisaka commented Sep 26, 2026 •

Copy link
Copy Markdown
Collaborator

All checks are green now. LGTM

@ZhouXY-PKU ZhouXY-PKU left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice job!

@mohanchen
mohanchen merged commit 1dd2b80 into deepmodeling:develop Sep 27, 2026
21 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Compile & CICD & Docs & Dependencies Issues related to compiling ABACUS

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants