Add CMake opt to get HWLOC sources from path instead of github - #1610
bratpiorka wants to merge 2 commits into
Conversation
|
|
||
| - name: Clone hwloc sources | ||
| if: matrix.local_hwloc == 'ON' | ||
| run: git clone --depth 1 -b hwloc-2.3.0 https://github.com/open-mpi/hwloc.git ${{env.HWLOC_SRC_DIR}} |
| -DUMF_BUILD_LIBUMF_POOL_JEMALLOC=ON | ||
| -DUMF_TESTS_FAIL_ON_SKIP=ON | ||
| -DUMF_LINK_HWLOC_STATICALLY=${{matrix.link_hwloc_statically}} | ||
| ${{ matrix.local_hwloc == 'ON' && format('-DUMF_HWLOC_SOURCE_DIR={0}', env.HWLOC_SRC_DIR) || '' }} |
26b779f to
fbd7fd6
Compare
There was a problem hiding this comment.
Copilot review overview
🟡 Changes recommended
The Windows companion Debug build does not receive the local hwloc path and can unexpectedly fetch a different source.
Review effort: Balanced
Findings: 1
Open (1)
What changed in this PR
Adds support for building statically linked hwloc from a local source directory.
Changes:
- Adds and documents
UMF_HWLOC_SOURCE_DIR. - Supports local sources on Windows and Unix builds.
- Adds CI coverage using hwloc 2.3.0 and fixes test compatibility.
| File | Description |
|---|---|
CMakeLists.txt |
Configures local hwloc source handling. |
README.md |
Documents the new option. |
.github/workflows/reusable_basic.yml |
Tests a local hwloc checkout. |
test/memspaces/memspace_highest_bandwidth.cpp |
Supports the older hwloc enum scope. |
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
fbd7fd6 to
77af354
Compare
77af354 to
274a17f
Compare
| - name: Clone hwloc sources | ||
| if: matrix.local_hwloc == 'ON' | ||
| # Note: We are using hwloc-2.11.0 because contrib/windows-cmake is not available in older hwloc releases | ||
| run: git clone --depth 1 -b hwloc-2.11.0 https://github.com/open-mpi/hwloc.git ${{env.HWLOC_SRC_DIR}} |
| -DUMF_BUILD_CUDA_PROVIDER=ON | ||
| -DUMF_TESTS_FAIL_ON_SKIP=ON | ||
| -DUMF_LINK_HWLOC_STATICALLY=ON | ||
| ${{ matrix.local_hwloc == 'ON' && format('-DUMF_HWLOC_SOURCE_DIR={0}', env.HWLOC_SRC_DIR) || '' }} |
| if(UMF_HWLOC_SOURCE_DIR) | ||
| # Drop build artifacts copied over from an already built local tree | ||
| set(UMF_HWLOC_PATCH_CMD | ||
| "(test ! -f Makefile || make distclean) && (${UMF_HWLOC_PATCH_CMD})" |
There was a problem hiding this comment.
just a question, why we have to run this patch cmd here and right in the next step (ExternalProject_Add)?
|
NOTE: This needs to be set as a draft, as I need to add a separate option to use a mirrored HWLOC repository path. |
| set(UMF_LINK_HWLOC_STATICALLY ON) | ||
| endif() | ||
| endif() | ||
|
|
There was a problem hiding this comment.
The UMF_HWLOC_SOURCE_DIR option is silently ignored if hwloc is linked dynamically. If someone sets UMF_HWLOC_SOURCE_DIR but leaves UMF_LINK_HWLOC_STATICALLY=OFF and system hwloc is found, nothing tells them the path wasn't used. A message(WARNING ...) would help, or the option could turn on static linking automatically. For example:
if(UMF_HWLOC_SOURCE_DIR AND NOT UMF_LINK_HWLOC_STATICALLY)
message(WARNING "UMF_HWLOC_SOURCE_DIR is ignored, because UMF_LINK_HWLOC_STATICALLY is OFF")
endif()| FATAL_ERROR | ||
| "UMF_HWLOC_SOURCE_DIR (${UMF_HWLOC_SOURCE_DIR}) is not a directory" | ||
| ) | ||
| endif() |
There was a problem hiding this comment.
The source tree is only checked to be a directory. A wrong path, or on Windows a hwloc release without contrib/windows-cmake/, fails later with an unclear error from FetchContent or autogen.sh. Cheap checks would catch this early, for example:
if(WINDOWS)
set(UMF_HWLOC_REQUIRED_FILE "contrib/windows-cmake/CMakeLists.txt")
else()
set(UMF_HWLOC_REQUIRED_FILE "configure.ac")
endif()
if(NOT EXISTS "${UMF_HWLOC_SOURCE_DIR}/${UMF_HWLOC_REQUIRED_FILE}")
message(FATAL_ERROR "UMF_HWLOC_SOURCE_DIR (${UMF_HWLOC_SOURCE_DIR}) does not contain ${UMF_HWLOC_REQUIRED_FILE}")
endif()The hwloc version isn't checked against the 2.3.0 minimum either.
| if(UMF_HWLOC_SOURCE_DIR) | ||
| # Drop build artifacts copied over from an already built local tree | ||
| set(UMF_HWLOC_PATCH_CMD | ||
| "(test ! -f Makefile || make distclean) && (${UMF_HWLOC_PATCH_CMD})" |
There was a problem hiding this comment.
make distclean on the copied tree is fragile. CMake's copy_directory probably
doesn't keep file timestamps. If so, running make on a copied, already-configured tree
may try to regenerate config.status or rerun automake before it gets to distclean,
which can fail if the autotools versions differ. Two alternatives:
- say in the README that the tree must be clean, or
- run
git clean -xfdwhen the copy has a.gitdirectory.
| # A directory URL is copied into the build tree, so the local clone is | ||
| # not patched or built in place. | ||
| set(UMF_HWLOC_SOURCE_ARGS URL ${UMF_HWLOC_SOURCE_DIR}) |
There was a problem hiding this comment.
Edits to the local tree aren't picked up after the first build. The copy only runs again when the download arguments change. This matters for anyone iterating on hwloc sources and is worth a comment in README and also here.
| | UMF_USE_VALGRIND | Enable Valgrind instrumentation | ON/OFF | OFF | | ||
| | UMF_USE_COVERAGE | Build with coverage enabled (Linux only) | ON/OFF | OFF | | ||
| | UMF_LINK_HWLOC_STATICALLY | Link UMF with HWLOC library statically (proxy library will be disabled on Windows+Debug build) | ON/OFF | OFF | | ||
| | UMF_HWLOC_SOURCE_DIR | Path to local hwloc sources used instead of fetching them (with UMF_LINK_HWLOC_STATICALLY) | path | "" | |
There was a problem hiding this comment.
Edits to the local tree aren't picked up after the first build. The copy only runs
again when the download arguments change. This matters for anyone iterating on hwloc
sources and is worth a comment in the README. The whole .git directory is also copied,
which is wasteful for a full clone (CI uses --depth 1, so it's fine there).

Add CMake option
UMF_HWLOC_SOURCE_DIRto get HWLOC sources from path instead of fetching hwloc github repo.