This is an archive of the discontinued LLVM Phabricator instance.

[OpenMP] Add HWLOC compatibility check
AbandonedPublic

Authored by tianshilei1992 on Jan 18 2023, 9:33 AM.

Details

Summary

Starting from LLVM 14 we are using HWLOC APIs from newer version, per
https://github.com/llvm/llvm-project/issues/54951, but our CMake check doesn't
include that part. Unfortunately HWLOC doesn't provide a proper CMake module for
find_package. We have to check if specific struct member exists before we use
that.

Fix #54951.

Diff Detail

Event Timeline

tianshilei1992 created this revision.Jan 18 2023, 9:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 9:33 AM
tianshilei1992 requested review of this revision.Jan 18 2023, 9:33 AM
Herald added a project: Restricted Project. · View Herald TranscriptJan 18 2023, 9:33 AM
tianshilei1992 edited the summary of this revision. (Show Details)Jan 18 2023, 9:34 AM
jlpeyton added inline comments.Jan 18 2023, 12:16 PM
openmp/runtime/cmake/config-ix.cmake
346–356

Move this below the check_struct_has_member call so the same hwloc.h header is used as the one in the check_include_file() call.

365

I think the name has to be different than LIBOMP_HAVE_LIBHWLOC or CMake will skip the check thinking it has already done it. Something like LIBOMP_HAVE_ATLEAST_LIBHWLOC2. Then just add the LIBOMP_HAVE_ATLEAST_LIBHWLOC2 to line 357 which checks all the necessary HWLOC requirements to determine if HWLOC is really available.

fix comment and refine the logic

tianshilei1992 marked 2 inline comments as done.Jan 18 2023, 3:34 PM
tianshilei1992 added inline comments.
openmp/runtime/cmake/config-ix.cmake
346–356

I think the logic here is, we first check if the header can be included, and then see if it is a valid one. Of course we could do it in another way. Either should work.

Sorry! I just realized there's another patch that solves this problem by inserting the proper HWLOC version checks in the code mentioned here: https://reviews.llvm.org/D112270. I'd rather go with that approach since it allows older HWLOC versions.

tianshilei1992 marked an inline comment as done.EditedJan 19 2023, 9:54 AM

Sorry! I just realized there's another patch that solves this problem by inserting the proper HWLOC version checks in the code mentioned here: https://reviews.llvm.org/D112270. I'd rather go with that approach since it allows older HWLOC versions.

Sure. Can you please land it? Also, please add Fix #54951. at the end of the commit message such that the issue can be closed automatically. It'd be best if you can do it before the release branching. Thanks!

However, I didn't see where the version check is inserted. The comment mentioned 2.4. So that patch has to be rebased and the refined.

If that patch cannot make it before the release, I think it makes more sense to land this in case breaking more users.

Ok I've made https://reviews.llvm.org/D142152 which combines @ggouaillardet 's patch with the other needed guard around line 1611 as you noted.

tianshilei1992 abandoned this revision.Jan 19 2023, 12:33 PM