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

HYPRE_Initialize() after errors? #1215

Open
jczhang07 opened this issue Jan 24, 2025 · 5 comments
Open

HYPRE_Initialize() after errors? #1215

jczhang07 opened this issue Jan 24, 2025 · 5 comments

Comments

@jczhang07
Copy link

Hello, I met an error (call HYPRE_SetMemoryLocation() without calling HYPRE_Initialize() before) and then I found the code at https://github.com/hypre-space/hypre/blob/master/src/utilities/general.c#L18-L28,

It is weird to see you trigger an error complaining HYPRE_Initialize() is not called in hypre_error_w_msg(), then still do HYPRE_Initialize() yourself.

Then what is the purpose of this error/complaint :)?.

@victorapm
Copy link
Contributor

victorapm commented Jan 25, 2025

Hi Junchao,

In general, this is not a fatal error but a safeguard mechanism. The error message serves as a debugging aid, reminding users to explicitly call HYPRE_Initialize() before any other HYPRE function. However, to ensure robustness, the library automatically calls HYPRE_Initialize() as a fallback to try to recover and maintain functionality.

While this recovery mechanism tries to avoid fatal errors, it's not always successful and our recommended approach is to always call HYPRE_Initialize() explicitly before any other hypre call to ensure predictable behavior and eliminate unnecessary warnings.

@jczhang07
Copy link
Author

The problem is in that case,HYPRE_SetMemoryLocation() returns a non-zero error code (even not fatal as you said), causing petsc to error out.

@victorapm
Copy link
Contributor

Could you move your call to HYPRE_SetMemoryLocation after the initialize call?

@jczhang07
Copy link
Author

Yes, we can. It is not a problem for petsc. I just feel in hypre if you think it is a warning, you should not set the error code.

@victorapm
Copy link
Contributor

Hi Junchao, currently, hypre doesn’t distinguish between warnings and errors, leaving it to applications to handle our error codes. However, that’s a fair point, and I’ll bring it up with the team to consider improving this in the future. Also feel free to propose any pull requests if you are interested!

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

No branches or pull requests

2 participants