Skip to content

refactor: modularize CMake discovery - #81

Merged
Ziminli merged 3 commits into
masterfrom
refactor/modularize-cmake-discovery
Oct 22, 2026
Merged

Ziminli merged 3 commits into
masterfrom
refactor/modularize-cmake-discovery

Conversation

@Ziminli

@Ziminli Ziminli commented Oct 22, 2026

Copy link
Copy Markdown
Collaborator

This PR keeps the high-level build flow visible in the root CMakeLists.txt while moving platform- and backend-specific detection and dependency setup into focused modules under cmake/devices and cmake/backends.

This PR also standardizes device auto-detection so a device explicitly enabled with WITH_*=ON remains enabled while auto-detection adds other detected devices.

No runtime API, collective algorithm, or intended platform behavior changes.

Changes

  • Central CMake Orchestration

    • Keep the option declarations, device/backend detection order, cross-device policy, and dependency configuration sequence in the root CMakeLists.txt.
    • Replace platform-specific implementation blocks with named detection, probe, and configuration calls.
  • Device-specific Modules

    • Add modules for NVIDIA, Iluvatar, MetaX, Moore Threads, Cambricon, HYGON, and T-Head detection and SDK configuration.
    • Move vendor-specific path hints, compiler selection, runtime library lookup, and T-Head CUDA-compatible toolkit resolution into their owning modules.
    • Add infiniccl_resolve_device_detection to preserve explicit WITH_*=ON selections and probe only devices that were not explicitly requested.
  • Backend-specific Modules

    • Add modules for MPI, NCCL/RCCL, MCCL, and CNCL detection and required dependency resolution.
    • Keep vendor-specific NCCL/RCCL and MCCL hints local to the relevant backend/device paths.
  • Behavior Preservation and Documentation

    • Add an explicit return to the HYGON-compiled PrintResult helper in examples/ccl/reduce_scatter.cc to avoid the compiler's missing-return warning.
    • Document that auto-detection is additive to explicit device/backend selections and that users can disable auto-detection for a strictly manual configuration.

Platform and Backend Affected

Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU
  • T-Head PPU

Backend

  • OpenMPI
  • MPICH
  • NCCL/RCCL
  • MCCL
  • CNCL

Performance Impact

  • No performance impact
  • Performance improved
  • Performance regression possible

N/A. This PR reorganizes configure-time discovery and preserves existing build behavior; it does not change runtime communication paths or collective algorithms.

Known Issues & Future Work

  • N/A.

Test Results

Test Involved Platform

  • CPU
  • NVIDIA GPU
  • Iluvatar GPU
  • MetaX GPU
  • Moore Threads GPU
  • Cambricon MLU
  • HYGON DCU
  • T-Head PPU

Test Involved Backend

  • OpenMPI
  • MPICH
  • NCCL/RCCL
  • MCCL
  • CNCL

NVIDIA+MetaX+Moore with OMPI:
mpi_all_gather.log
mpi_all_reduce.log
mpi_all_to_all.log
mpi_broadcast.log
mpi_gather.log
mpi_reduce.log
mpi_reduce_scatter.log
mpi_scatter.log
mpi_send_recv.log

Iluvatar with NCCL:
ccl_all_gather.log
ccl_all_reduce.log
ccl_reduce_scatter.log
ccl_send_recv.log

HYGON with RCCL+OMPI:
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_send_recv.log

T-Head with NCCL:
ccl_all_gather.log
ccl_all_reduce.log
ccl_reduce_scatter.log
ccl_send_recv.log

Cambricon with CNCL:
ccl_mpi_hybrid_all_gather.log
ccl_mpi_hybrid_all_reduce.log
ccl_mpi_hybrid_send_recv.log


Checklist

Every contributor must verify every item below before requesting
review. Tick each box only after the check has actually been performed —
do not tick speculatively. If an item truly does not apply, replace the
checkbox with N/A and briefly explain why in an inline comment.

Title, Branch, and Commits

  • PR title follows Conventional Commits (e.g. feat: …, fix(nccl): …).
  • Branch name follows <type>/xxx-yyyy-zzzz where <type> matches the PR title's Conventional Commits type and words are joined with hyphens (see CONTRIBUTING.md §Branches).
  • Each commit message follows Conventional Commits.
  • Small PR is a single squashable commit; or, for a large PR, every commit is meaningful, well-formed, and independently reviewable (see CONTRIBUTING.md §Pull Requests).
  • No stray merge commits from master — the branch is rebased cleanly on top of the current master.
  • No fixup! / squash! / wip commits remain.

Scope and Design

  • Changes are minimal — no unrelated modifications were introduced (CONTRIBUTING.md §Code/General).
  • No dead code, commented-out blocks, debug prints, printf/std::cout/print(...) left behind, or TODO without an owner and issue link.
  • No unrelated formatting churn that would obscure the diff.
  • N/A- Public API changes (if any) are intentional, documented, and reflected in affected callers/tests.

General Code Hygiene

  • The code is self-explanatory; comments were added only where the intent or rationale is non-obvious (CONTRIBUTING.md §Code/General).
  • Every modified or added file ends with a single trailing newline (CONTRIBUTING.md §Code/General).
  • No trailing whitespace, inconsistent indentation, or mixed formatting styles remain.
  • Identifiers referenced in comments or error messages are wrapped in Markdown backticks (e.g. the `AllReduce` implementation) (CONTRIBUTING.md §Code/General).
  • All comments and error messages are in English (CONTRIBUTING.md §Code/General).
  • Comments and error messages are complete sentences — capitalized first letter, terminal punctuation — unless the language/framework convention says otherwise (CONTRIBUTING.md §Code/General; §Python).

C++ Specific (if C++ files changed)

  • Code follows the Google C++ Style Guide strictly.
  • clang-format (version 16, per .github/workflows/clang-format.yml) has been run against all modified applicable files; the diff is clean.
  • N/A- No exceptions are thrown. Error paths use assert with messages that include at least __FILE__, __LINE__, and __func__ (CONTRIBUTING.md §C++).
  • N/A- Error and warning message wording follows the LLVM Coding Standards (CONTRIBUTING.md §C++).
  • N/A- Constructor initializer list order matches member declaration order (CONTRIBUTING.md §C++).
  • N/A- Exactly one blank line between classes, between classes and functions, and between functions (CONTRIBUTING.md §C++).
  • N/A- Exactly one blank line between members (functions and variables) within a class (CONTRIBUTING.md §C++).
  • N/A- Exactly one blank line before and after the contents of a namespace (CONTRIBUTING.md §C++).

Python Specific (if Python files changed)

  • N/A. No Python files were changed.

Testing

  • All applicable example programs have been built and tested successfully on at least one supported heterogeneous cluster setup.

Build, CI, and Tooling

  • New backends or devices have been added to auto-detection in CMakeLists.txt under if(AUTO_DETECT_DEVICES) or to if(AUTO_DETECT_BACKENDS) if applicable.
  • Both CI workflows (clang-format.yml, ruff.yml) are green locally (or expected to be green on CI).

Documentation

  • README.md, CONTRIBUTING.md, or inline docs updated when behavior, build flags, or developer workflow changed.
  • N/A- Any user-visible breaking change is called out explicitly under "Summary" and in the commit/PR title with a ! or BREAKING CHANGE: footer.

Security and Safety

  • No secrets, access tokens, internal URLs, customer data, or personal hardware identifiers have been committed.
  • N/A- Third-party code is license-compatible and attributed.
  • N/A- No unsafe pointer arithmetic, uninitialized reads, or missing bounds checks were introduced.

@Ziminli
Ziminli merged commit fb41513 into master Oct 22, 2026
2 checks passed
@Ziminli
Ziminli deleted the refactor/modularize-cmake-discovery branch October 22, 2026 08:48
@Ziminli Ziminli self-assigned this Oct 22, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant