-
Notifications
You must be signed in to change notification settings - Fork 7
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
Add Caffeine's own custom assert subroutine #76
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is a great improvement license-wise. I added a few minor requests for changes.
I'd also like to raise a bigger question, which is somewhat orthogonal to this PRs replacement:
This assertion library is currently implemented mostly in Fortran, but it relies upon the C preprocessor (at least when compiling the assertion module) for the critical control knob that enables or disables assertions. Given that dependency, what is the rationale for shunning additional dependence on the C preprocessor that would allow for a stronger assertion facility?
In particular, if we implement the assert()
invocation itself using a C preprocessor macro, then we can easily deploy the following improvements:
- We can automatically augment the diagnostic message to include the source text for the expression that failed, and the file name and line number of the failed assertion (analogous to POSIX/C assert). This notably provides alot of valuable information about the failure with zero additional effort by the caller.
- We can trivially ensure that when assertions are disabled at compile time, the assertion invocations are strongly guaranteed to compile away entirely with zero runtime impact. The current implementation can only achieve that with strong compiler analysis and optimization, and might still fall short (notably whenever it's difficult to prove the argument expressions are side-effect-free).
To be clear, I'm not arguing to adopt heavy use of C preprocessor macros in Caffeine. However assertions are a specific software engineering feature that macros are very well-suited to implement in a powerful way, so what's the rationale to neglect that?
As a motivating example, below is example diagnostic output from an assertion failure provided by the UPC++ assertion facility, with GASNet's auto-backtrace support enabled. The caller's invocation is simply the following line: (where the variable
The resulting diagnostic failure output:
|
@bonachea these are great suggestions and I'm supportive of the approach you're recommending. @ktras and I just discussed this PR and agreed that a live discussion will help with deciding a path forward so I'll respond in more detail during our next call. For now, here are a few things to consider:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
New changes look good, I think we're almost there!
Added a few final minor requests.
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
in the `caffeine_assert` dir after last change.
new assertion routine.
Co-authored-by: Dan Bonachea <dobonachea@lbl.gov>
No description provided.