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

Fixing External Include of Build Directory #1532

Merged
merged 5 commits into from
Jan 22, 2024
Merged

Conversation

MarcelKoch
Copy link
Member

@MarcelKoch MarcelKoch commented Jan 17, 2024

This PR extracts the exporting of the binary dir from our install configuration. To properly allow external projects to import Ginkgo directly from the binary tree, it is necessary to create two separate sets of config files. Otherwise, the binary tree config would refer to directories that are part of the install tree, which might not exist.


Old Description:

The build directory is missing the GinkgoTargets.cmake file. This prevents external projects from using the Ginkgo build directory directly, instead they need to use the install directory.

The issue was introduced in 75777b4. Reverting a small part of it fixes the issue.

I also changed the test_exportbuild test to only search Ginkgo using the Ginkgo_ROOT path. TBH, I'm not sure if that was the intention of the test, but it can reproduce both the failing and succeeding behavior.

@MarcelKoch MarcelKoch self-assigned this Jan 17, 2024
@ginkgo-bot ginkgo-bot added the reg:build This is related to the build system. label Jan 17, 2024
@MarcelKoch MarcelKoch changed the title WIP Fixing External Include of Build Directory Fixing External Include of Build Directory Jan 17, 2024
@MarcelKoch MarcelKoch requested a review from a team January 18, 2024 07:54
INSTALL.md Outdated
For example, to build everything (in debug mode), use:

```cmake
cmake -G "Unix Makefiles" -H. -BDebug -DCMAKE_BUILD_TYPE=Debug -DGINKGO_DEVEL_TOOLS=ON \
cmake -S. -BDebug -DCMAKE_BUILD_TYPE=Debug -DGINKGO_DEVEL_TOOLS=ON \
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
cmake -S. -BDebug -DCMAKE_BUILD_TYPE=Debug -DGINKGO_DEVEL_TOOLS=ON \
cmake -S.. -BDebug -DCMAKE_BUILD_TYPE=Debug -DGINKGO_DEVEL_TOOLS=ON \

Maybe keep using the build (or any child folder) not the source directory as the build directory

if (GINKGO_EXPORT_BUILD_DIR)
export(PACKAGE Ginkgo)
endif()
export(PACKAGE Ginkgo)
Copy link
Member

Choose a reason for hiding this comment

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

could you explain more on this?
It does nothing without CMAKE_EXPORT_PACKAGE_REGISTRY=ON. Thus, it does not write anything to the user registry like ~/.cmake in the linux. (it does not affect us to use build directory as the external library)
never noticed cmake contains a user package registry before

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that already covers it. Without CMAKE_EXPORT_PACKAGE_REGISTRY=ON this is a no-op, so we don't need to guard it. Also setting GINKGO_EXPORT_BUILD_DIR had no effect on the other CMake option, so no need for that.
The CMake registry basically just stores the paths to the packages.

- ninja -j${NUM_CORES} -l${CI_LOAD_LIMIT} install
- awk '!/^#/ { print ($2 - $1)/1000 " " $4 }' .ninja_log | sort -nr
- |
(( $(ctest -N | tail -1 | sed 's/Total Tests: //') != 0 )) || exit 1
- ctest --output-on-failure --timeout 6000 ${CTEST_EXTRA_ARGS}
- ninja test_exportbuild
Copy link
Member

Choose a reason for hiding this comment

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

to ensure it still works after installation?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that should not be necessary. The export test is only allowed to use the *_ROOT to find ginkgo, so the previous install should have no effect.
I would still keep this test before to prevent the current situation.

Copy link
Member

Choose a reason for hiding this comment

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

Side-note: The reason we do ninja install directly in the beginning is that the HIP compilation doesn't create (or didn't used to create) the correct depfiles or something like that on the first pass, so calling ninja and then ninja install caused the HIP objects to be rebuilt. If we tackle #1334, that is no longer an issue and we can separate between ninja and ninja install again

Copy link
Member Author

Choose a reason for hiding this comment

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

TBH, I think we should push the CMake update for HIP, even if that would mean to drop support for rocm < 5.0.1. I don't think it's even possible to find the documentation for rocm 4.5 from visiting amd.com, so it seems to me that these versions are not really supported anymore.

Copy link
Member

Choose a reason for hiding this comment

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

for the issue that hip needs built twice, we can just run ninja && ninja if we do not want ninja install rebuilds the stuff.
I do not think the two build is a big issue.
Dropping the support rocm < 5.0.1 is not the main issue from updating cmake for HIP.
Updating cmake for hip means we drops the nvidia support of hip. In my mind, the new cmake is not completed yet because they claim they can do that on both architectures. Also, recovering the support after deleting is harder than keeping the current one.

Copy link
Member

Choose a reason for hiding this comment

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

This is an issue of build time, our HIP builds (especially debug) are extremely slow, we don't want to build the binaries twice. It seems to me like the old hip_add_* approach hasn't been mentioned in their documentation in a long time, on top of all its downsides I also do not want to keep relying on it. We have full CUDA support via our CUDA backend, to me there are no technical reasons to keep this around, as HIP is just a thin layer over CUDA anyways.

@MarcelKoch MarcelKoch marked this pull request as draft January 18, 2024 10:59
@MarcelKoch MarcelKoch marked this pull request as ready for review January 18, 2024 13:58
@MarcelKoch MarcelKoch added the 1:ST:ready-for-review This PR is ready for review label Jan 18, 2024
@MarcelKoch MarcelKoch requested review from a team and yhmtsai January 18, 2024 13:58
Copy link
Member

@upsj upsj 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 for fixing this

@MarcelKoch MarcelKoch requested a review from a team January 22, 2024 12:45
Copy link
Member

@pratikvn pratikvn left a comment

Choose a reason for hiding this comment

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

LGTM!

It only guards `export(PACKAGE Ginkgo)` which doesn't have any effects in CMake > v3.15, unless `CMAKE_EXPORT_PACKAGE_REGISTRY` is set.
fixup! spilt extract binary dir export from install
@MarcelKoch MarcelKoch merged commit 50dcd1b into develop Jan 22, 2024
9 of 15 checks passed
@MarcelKoch MarcelKoch deleted the fix-external-usage branch January 22, 2024 13:08
@ginkgo-bot
Copy link
Member

Error: PR already merged!

@yhmtsai
Copy link
Member

yhmtsai commented Jan 22, 2024

We have two version of cmakeConfig and implementation in the code. Is there any way to reduce the possibility of missing partial changes in the future?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1:ST:ready-for-review This PR is ready for review reg:build This is related to the build system.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants