Skip to content

Improvements to AMREX_ASSERT#4581

Merged
WeiqunZhang merged 10 commits intoAMReX-Codes:developmentfrom
AlexanderSinn:improvements_to_AMREX_ASSERT
Aug 8, 2025
Merged

Improvements to AMREX_ASSERT#4581
WeiqunZhang merged 10 commits intoAMReX-Codes:developmentfrom
AlexanderSinn:improvements_to_AMREX_ASSERT

Conversation

@AlexanderSinn
Copy link
Copy Markdown
Member

@AlexanderSinn AlexanderSinn commented Jul 25, 2025

Summary

Previously the AMREX_ASSERT_WITH_MESSAGE and AMREX_ALWAYS_ASSERT_WITH_MESSAGE macros converted the messege to a string using # MSG which resulted in strange formatting and the printing of runtime values to not work.

Additionally, ALWAYS_ASSERT and ASSERT did not work in device code even when compiling with AMREX_USE_ASSERTION due to the #if defined(NDEBUG) in Assert (...).

Now ALWAYS_ASSERT and ASSERT will work in device code with AMREX_USE_ASSERTION, but not without so the behaviour doesn't change of the few places that use ALWAYS_ASSERT on the GPU (meaning ALWAYS_ASSERT still does not always assert).

Test of the assert:

AMREX_ALWAYS_ASSERT_WITH_MESSAGE(pos != m_rdata_names->end(), "Soa Real name='" + name + "' was not found components");

Dev:

0::Assertion `pos != m_rdata_names->end()' failed, file "/users/sinnalex/hipace/build/_deps/fetchedamrex-src/Src/Particle/AMReX_StructOfArrays.H", line 122,
Msg: "Soa Real name='" + name + "' was not found components" !!!
SIGABRT
See Backtrace.0 file for details

PR:

0::Assertion `pos != m_rdata_names->end()' failed, file "/users/sinnalex/amrex/Src/Particle/AMReX_StructOfArrays.H", line 122, 
Msg: Soa Real name='wrong name' was not found components !!!
SIGABRT
See Backtrace.0 file for details

Additional background

Checklist

The proposed changes:

  • fix a bug or incorrect behavior in AMReX
  • add new capabilities to AMReX
  • changes answers in the test suite to more than roundoff level
  • are likely to significantly affect the results of downstream AMReX users
  • include documentation in the code and/or rst files, if appropriate

@WeiqunZhang WeiqunZhang merged commit 9d63d59 into AMReX-Codes:development Aug 8, 2025
75 checks passed
mirenradia added a commit to GRTLCollaboration/GRTeclyn that referenced this pull request Aug 8, 2025
The changes in AMReX-Codes/amrex#4581 mean this message is required to
be a string as the macro no longer converts it for us.
mirenradia added a commit to GRTLCollaboration/GRTeclyn that referenced this pull request Aug 8, 2025
The changes in AMReX-Codes/amrex#4581 mean this message is required to
be a string as the macro no longer converts it for us.

This fixes #133.
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.

2 participants