Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Adding option for installing Hwloc using CMake FetchContent #6394

Merged
merged 17 commits into from
Jan 18, 2024

Conversation

vrnimje
Copy link
Contributor

@vrnimje vrnimje commented Dec 3, 2023

References #6392

Proposed Changes

  • Added HPX_WITH_FETCH_HWLOC option for fetching Hwloc using CMake FetchContent
  • Added CI tests for the same, on Linux, macOS and Windows platforms

Any background context you want to provide?

Checklist

Not all points below apply to all pull requests.

  • I have added a new feature and have added tests to go along with it.
  • I have fixed a bug and have added a regression test.
  • I have added a test using random numbers; I have made sure it uses a seed, and that random numbers generated are valid inputs for the tests.

@vrnimje vrnimje requested a review from hkaiser as a code owner December 3, 2023 07:24
@StellarBot
Copy link

Can one of the admins verify this patch?

@hkaiser
Copy link
Member

hkaiser commented Dec 4, 2023

@vrnimje the ci/circleci: install step fails (https://app.circleci.com/pipelines/github/STEllAR-GROUP/hpx/16294/workflows/33c0c1ec-9c58-4ec5-b900-4892d700503c/jobs/371220). Would you be able to have a look, please?

include(FetchContent)
fetchcontent_declare(
HWLoc
URL https://download.open-mpi.org/release/hwloc/v2.9/hwloc-2.9.3.tar.gz
Copy link
Contributor

Choose a reason for hiding this comment

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

We may need to keep a separate variable for HWLOC version.

Copy link
Contributor Author

@vrnimje vrnimje Dec 5, 2023

Choose a reason for hiding this comment

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

Like this?

+  set(HPX_WITH_HWLOC_VERSION "2.9")
+  set(HPX_WITH_HWLOC_RELEASE "2.9.3")
   hpx_info(
-    "HPX_WITH_FETCH_HWLOC=${HPX_WITH_FETCH_HWLOC}, Hwloc will be fetched using CMake's FetchContent"
+    "HPX_WITH_FETCH_HWLOC=${HPX_WITH_FETCH_HWLOC}, Hwloc v${HPX_WITH_HWLOC_RELEASE} will be fetched using CMake's FetchContent"
   )
   if(UNIX)
     include(FetchContent)
     fetchcontent_declare(
       HWLoc
-      URL https://download.open-mpi.org/release/hwloc/v2.9/hwloc-2.9.3.tar.gz
+      URL https://download.open-mpi.org/release/hwloc/v${HPX_WITH_HWLOC_VERSION}/hwloc-${HPX_WITH_HWLOC_RELEASE}.tar.gz
       TLS_VERIFY true
     )

Copy link
Contributor Author

@vrnimje vrnimje Dec 11, 2023

Choose a reason for hiding this comment

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

I have added them in e67885b

elseif("${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win64")
fetchcontent_declare(
HWLoc
URL https://download.open-mpi.org/release/hwloc/v2.9/hwloc-win64-build-2.9.3.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

Same as above, we may have to keep a separate variable for HWLOC version.

else()
fetchcontent_declare(
HWLoc
URL https://download.open-mpi.org/release/hwloc/v2.9/hwloc-win64-build-2.9.3.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

  1. It should be win32.
  2. Same as above, we may have to keep a separate variable for HWLOC version.

Copy link
Contributor

@SAtacker SAtacker Dec 4, 2023

Choose a reason for hiding this comment

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

Could you make this change and see if it doesn't fail? I am not sure how it's related to free(): invalid pointer, but it should be win32 It's unrelated.

cmake/HPX_SetupHwloc.cmake Outdated Show resolved Hide resolved
Copy link

codacy-production bot commented Dec 11, 2023

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 3253ee11
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3253ee1) Report Missing Report Missing Report Missing
Head commit (d9f03d7) 190065 161880 85.17%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6394) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

@SAtacker
Copy link
Contributor

@hkaiser PTAL

@vrnimje
Copy link
Contributor Author

vrnimje commented Jan 10, 2024

I have encountered an issue with the Windows build...
The Windows workflow, with the option enabled, is unable to pass any of the tests, due to the following error:

Process 0 failed with an unexpected error code of 3221225781 (expected 0) <_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp1252'>

So I tried recreating the build on my local system (using VS 2022), and I was able to reproduce the error with the tests
And after executing some examples in the repository, I encountered another error...

image

I am currently trying to find a solution, but any pointers are welcome..

Comment on lines +61 to +89
elseif("${CMAKE_SYSTEM_NAME}" STREQUAL "Windows" AND CMAKE_SIZEOF_VOID_P
EQUAL 8
)
fetchcontent_declare(
HWLoc
URL https://download.open-mpi.org/release/hwloc/v${HPX_WITH_HWLOC_VERSION}/hwloc-win64-build-${HPX_WITH_HWLOC_RELEASE}.zip
TLS_VERIFY true
)
if(NOT HWLoc_POPULATED)
fetchcontent_populate(HWLoc)
endif()
set(HWLOC_ROOT
"${CMAKE_BINARY_DIR}/_deps/hwloc-src"
CACHE INTERNAL ""
)
include_directories(${HWLOC_ROOT}/include)
link_directories(${HWLOC_ROOT}/lib)
set(Hwloc_INCLUDE_DIR
${HWLOC_ROOT}/include
CACHE INTERNAL ""
)
set(Hwloc_LIBRARY
${HWLOC_ROOT}/lib/libhwloc.dll.a
CACHE INTERNAL ""
)
else()
fetchcontent_declare(
HWLoc
URL https://download.open-mpi.org/release/hwloc/v${HPX_WITH_HWLOC_VERSION}/hwloc-win32-build-${HPX_WITH_HWLOC_RELEASE}.zip
Copy link
Contributor

Choose a reason for hiding this comment

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

Copy link
Contributor

Choose a reason for hiding this comment

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

@vrnimje I am pretty sure you need

if(WIN32 OR "${CMAKE_GENERATOR_PLATFORM}" STREQUAL "Win64" AND NOT WITH_CUSTOM_HPX)
  add_custom_command(TARGET opt_bench POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory
        "${hpx_BINARY_DIR}/${CMAKE_BUILD_TYPE}/bin"
        $<TARGET_FILE_DIR:opt_bench>
  )
  add_custom_command(TARGET opt_bench POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_if_different
        "${HWLOC_ROOT}/bin/libhwloc-15.dll"
        $<TARGET_FILE_DIR:opt_bench>
  )

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added this command in 7ac5b33

Copy link
Member

Choose a reason for hiding this comment

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

What about 32Bit Windows? Do we support that here as well?

Copy link
Contributor Author

@vrnimje vrnimje Jan 13, 2024

Choose a reason for hiding this comment

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

Yes, 32-bit Windows is also supported here:

else()
fetchcontent_declare(
HWLoc
URL https://download.open-mpi.org/release/hwloc/v${HPX_WITH_HWLOC_VERSION}/hwloc-win32-build-${HPX_WITH_HWLOC_RELEASE}.zip
TLS_VERIFY true
)
if(NOT HWLoc_POPULATED)
fetchcontent_populate(HWLoc)
endif()
set(HWLOC_ROOT
"${CMAKE_BINARY_DIR}/_deps/hwloc-src"
CACHE INTERNAL ""
)
include_directories(${HWLOC_ROOT}/include)
link_directories(${HWLOC_ROOT}/lib)
set(Hwloc_INCLUDE_DIR
${HWLOC_ROOT}/include
CACHE INTERNAL ""
)
set(Hwloc_LIBRARY
${HWLOC_ROOT}/lib/libhwloc.dll.a
CACHE INTERNAL ""
)

I have also tested it locally using cmake -A Win32 ....

@SAtacker
Copy link
Contributor

I have encountered an issue with the Windows build... The Windows workflow, with the option enabled, is unable to pass any of the tests, due to the following error:

Process 0 failed with an unexpected error code of 3221225781 (expected 0) <_io.TextIOWrapper name='<stderr>' mode='w' encoding='cp1252'>

So I tried recreating the build on my local system (using VS 2022), and I was able to reproduce the error with the tests And after executing some examples in the repository, I encountered another error...

image

I am currently trying to find a solution, but any pointers are welcome..

Please see https://github.com/SAtacker/hpx-template/blob/ba47fba9bda7833fdbd9698ee5863ddd959e6513/CMakeLists.txt#L108-L119

@SAtacker
Copy link
Contributor

@hkaiser please approve the remaining workflows

@SAtacker
Copy link
Contributor

@hkaiser PTAL

.github/workflows/linux_debug_fetch_hwloc.yml Outdated Show resolved Hide resolved
CMakeLists.txt Show resolved Hide resolved
Copy link

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
Report missing for 3253ee11
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (3253ee1) Report Missing Report Missing Report Missing
Head commit (209a03b) 190065 161900 85.18%

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#6394) 0 0 ∅ (not applicable)

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences

You may notice some variations in coverage metrics with the latest Coverage engine update. For more details, visit the documentation

Footnotes

  1. Codacy didn't receive coverage data for the commit, or there was an error processing the received data. Check your integration for errors and validate that your coverage setup is correct.

Copy link
Member

@hkaiser hkaiser left a comment

Choose a reason for hiding this comment

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

LGTM, thanks!

@hkaiser hkaiser added this to the 1.10.0 milestone Jan 17, 2024
@SAtacker
Copy link
Contributor

@hkaiser can we please merge this?

@hkaiser hkaiser merged commit b99b590 into STEllAR-GROUP:master Jan 18, 2024
46 of 48 checks passed
Comment on lines 2323 to 2337
if(HPX_WITH_EXAMPLES)
add_hpx_pseudo_target(examples)
if(HPX_WITH_FETCH_HWLOC AND "${CMAKE_SYSTEM_NAME}" STREQUAL "Windows")
add_custom_target(
HwlocDLL ALL
COMMAND ${CMAKE_COMMAND} -E make_directory
"${CMAKE_BINARY_DIR}/$<CONFIG>/bin/"
COMMAND
${CMAKE_COMMAND} -E copy_if_different
"${HWLOC_ROOT}/bin/libhwloc-15.dll"
"${CMAKE_BINARY_DIR}/$<CONFIG>/bin/"
)
add_hpx_pseudo_dependencies(examples HwlocDLL)
endif()
endif()
Copy link
Contributor

Choose a reason for hiding this comment

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

@vrnimje what happens when HPX_WITH_EXAMPLES is not set? Please make a new PR if this is incorrect

Copy link
Contributor Author

@vrnimje vrnimje Jan 25, 2024

Choose a reason for hiding this comment

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

I was only able to find examples as a psuedo-target, to which I could add the dependency I have defined (HwlocDLL)
Since the libhwloc-15.dll needs to be copied exactly to "${CMAKE_BINARY_DIR}/$<CONFIG>/bin/", and the Configuration type $<CONFIG> is defined during the build stage, I used the above method. As far as I understand, $<CONFIG> can only be obtained using add_custom_command or add_custom_target.

Is there any other mechanism to achieve this?

Copy link
Contributor Author

@vrnimje vrnimje Jan 25, 2024

Choose a reason for hiding this comment

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

I now realise that I could directly add HwlocDLL as a pseudo target using add_hpx_pseudo_target. I will test it out. It works, will open another PR to correct it
Thanks for pointing this out

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants