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

Allow using P4est for preferences not set correctly #93

Merged
merged 3 commits into from
Nov 6, 2023

Conversation

JoshuaLampert
Copy link
Member

@JoshuaLampert JoshuaLampert commented Nov 4, 2023

With this PR using P4est doesn't crash anymore if a system-provided MPI installation together with the P4est_jll p4est version is used, but gives the user a warning to set the preferences for p4est accordingly. This way, it is also possible to first set the MPIPreferences, restart the REPL and then set the preferences for P4est.jl.

Additionally, I have added three functions: path_p4est_library() and path_sc_library(), which returns the path to the libraries or P4est_jll if the default p4est installation is used. This way one can conveniently check if P4est.jl uses the correct libraries.

Lastly, I added the function preferences_set_correctly(), which returns false if P4est.jl is not usable due to missing preference for P4est.jl. This function can be used in Trixi.jl to determine if init_p4est() can be called or not. By adding if preferences_set_correctly() ... end together with my corresponding PR in T8code.jl (DLR-AMR/T8code.jl#40), I was able to run Trixi.jl with system-provided MPI installation on a TreeMesh-example without setting the preferences for P4est.jl and T8code.jl. Thus, with these two PRs and the corresponding PR in Trixi.jl (that I will prepare once this PR and the corresponding T8code.jl PR are merged) it is only necessary to set the preferences for P4est.jl and T8code.jl if you really need them.

Closes #91.

Copy link

codecov bot commented Nov 4, 2023

Codecov Report

Attention: 4 lines in your changes are missing coverage. Please review.

Comparison is base (e2a5e00) 16.18% compared to head (17d4a75) 16.25%.

Additional details and impacted files
@@            Coverage Diff             @@
##             main      #93      +/-   ##
==========================================
+ Coverage   16.18%   16.25%   +0.08%     
==========================================
  Files           3        3              
  Lines        1533     1538       +5     
==========================================
+ Hits          248      250       +2     
- Misses       1285     1288       +3     
Flag Coverage Δ
unittests 16.25% <50.00%> (+0.08%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Files Coverage Δ
src/LibP4est.jl 14.41% <ø> (ø)
src/P4est.jl 48.39% <50.00%> (-1.61%) ⬇️

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

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

I am wondering: Right now, the preferences check happens at the module level, i.e., during precompilation, if I am not mistaken. Wouldn't it be better if this warning were shown (also) at loading time, i.e., from __init__?

Also, this will lead to no variable libp4est/libsc being defined in the module - is this intentional?

@JoshuaLampert
Copy link
Member Author

Wouldn't it be better if this warning were shown (also) at loading time, i.e., from init?

Yes, definitely. I added that in 17d4a75.

Also, this will lead to no variable libp4est/libsc being defined in the module - is this intentional?

Yes, this is intentional. If MPIPreferences are set, but no P4est.jl preferences, we can neither set libp4est/libsc to the path from P4est_jll (this was done before and fails unless your system MPI is compatible with the P4est_jll MPI) nor to a local one (we have no preference, so we don't know of any local one). Thus, libp4est/libsc are undefined and P4est.jl is not usable, but you can still load it and set the preference (and therefore libp4est/libsc) to make it usable.

Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks a lot!

dev/prologue.jl Outdated Show resolved Hide resolved
dev/prologue.jl Outdated Show resolved Hide resolved
src/LibP4est.jl Outdated Show resolved Hide resolved
src/LibP4est.jl Outdated Show resolved Hide resolved
src/P4est.jl Outdated Show resolved Hide resolved
Copy link
Member

@ranocha ranocha left a comment

Choose a reason for hiding this comment

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

Thanks! @sloede Do you want to have a final look as well?

Copy link
Member

@sloede sloede left a comment

Choose a reason for hiding this comment

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

Thanks!

@sloede sloede merged commit e82286f into trixi-framework:main Nov 6, 2023
10 of 11 checks passed
@JoshuaLampert JoshuaLampert deleted the robust-loading branch November 6, 2023 15:32
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.

Make loading more robust
3 participants