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

[WIP] ABLASTR: IntervalsParser & SafeCast #5227

Draft
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

ax3l
Copy link
Member

@ax3l ax3l commented Sep 8, 2024

Refactor and move out the SafeCast and IntervalsParser from WarpX to ABLASTR.

Refactor and move out the `SafeCast` and `IntervalsParser` from
WarpX to ABLASTR.
@ax3l ax3l added the hackathon Let's address this topic during the GPU hackathon label Sep 8, 2024
{
WARPX_ALWAYS_ASSERT_WITH_MESSAGE(!m_isBTD || !insplit[1].empty(), "must specify interval stop for BTD");
if (!insplit[0].empty()){
m_start = parseStringtoInt(insplit[0], "interval start");}
Copy link
Member Author

Choose a reason for hiding this comment

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

parseStringtoInt: @WeiqunZhang can I use an AMReX intrinsic for this now?

Copy link
Member

Choose a reason for hiding this comment

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

I looked at the implementation of that function. It use amrex::Parser to parse it as double precision numbers and then check if it can be safely cast to int. There is amrex::IParser we can use. It parses the numbers as long long. So the chance of overflowing during parsing is tiny. The safety checking for casting to int would also be much simpler.


ablastr::utils::parser::SliceParser::SliceParser (
const std::string& instr,
const bool isBTD
Copy link
Member Author

@ax3l ax3l Sep 8, 2024

Choose a reason for hiding this comment

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

Urgh, such a hack: The isBTD should never have made it into this interface and needs to be removed. BTDIntervalsParser can handle this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
hackathon Let's address this topic during the GPU hackathon
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants