Call HYPRE_DeviceInitialize after HYPRE_Init if using GPUs#5336
Open
jrood-nrel wants to merge 1 commit intoAMReX-Codes:developmentfrom
Open
Call HYPRE_DeviceInitialize after HYPRE_Init if using GPUs#5336jrood-nrel wants to merge 1 commit intoAMReX-Codes:developmentfrom
jrood-nrel wants to merge 1 commit intoAMReX-Codes:developmentfrom
Conversation
WeiqunZhang
reviewed
Apr 15, 2026
| hypre_HandleDefaultExecPolicy(hypre_handle()) = HYPRE_EXEC_DEVICE; | ||
| hypre_HandleSpgemmUseCusparse(hypre_handle()) = 0; | ||
| #endif | ||
| HYPRE_DeviceInitialize(); |
Member
There was a problem hiding this comment.
Could we move this line right after HYPRE_init, in case it needs to be called before functions like HYPRE_SetGPUMemoryPoolSize?
Contributor
Author
There was a problem hiding this comment.
Copilot (Opus) claimed it should be at this location. I'm going to convert this to a draft anyway, because it seems like there is more to this I think I need to understand.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Without this, I was experiencing errors during init on a machine where MPI ranks can see multiple GPUs:
Setting
export CUDA_VISIBLE_DEVICES=0was able to avoid the error, but the actual fix seems to be to include the call toHYPRE_DeviceInitialize()afterHYPRE_Init()when using GPUs.I can verify this solves the error I was seeing when using hypre with AMReX in AMR-Wind.
Additional background
Checklist
The proposed changes: