-
Notifications
You must be signed in to change notification settings - Fork 10
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 LVARRAY_ERROR_IF_PRINTF() macro to prinnt fancyer messages on errors #255
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.
Looks good to me, thanks! Before merging this you'll need to create a PR in the GEOSX repo updating the LvArray submodule. Once that is approved and has passed the checks you can merge this then update and merge the GEOSX PR.
src/SparsityPattern.hpp
Outdated
@@ -130,8 +130,8 @@ class SparsityPattern : protected SparsityPatternView< COL_TYPE, INDEX_TYPE, BUF | |||
void resizeFromRowCapacities( INDEX_TYPE const nRows, INDEX_TYPE const nCols, INDEX_TYPE const * const rowCapacities ) | |||
{ | |||
LVARRAY_ERROR_IF( !arrayManipulation::isPositive( nCols ), "nCols must be positive." ); | |||
LVARRAY_ERROR_IF( nCols - 1 > std::numeric_limits< COL_TYPE >::max(), | |||
"COL_TYPE must be able to hold the range of columns: [0, " << nCols - 1 << "]." ); | |||
LVARRAY_ERROR_IF_PRINTF( nCols - 1 > std::numeric_limits< COL_TYPE >::max(), |
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 not device code so I'm not sure it makes sense to change.
src/SparsityPatternView.hpp
Outdated
@@ -438,8 +439,8 @@ class SparsityPatternView : protected ArrayOfSetsView< COL_TYPE, INDEX_TYPE, BUF | |||
{ | |||
LVARRAY_ERROR_IF( !arrayManipulation::isPositive( nrows ), "nrows must be positive." ); | |||
LVARRAY_ERROR_IF( !arrayManipulation::isPositive( ncols ), "ncols must be positive." ); | |||
LVARRAY_ERROR_IF( ncols - 1 > std::numeric_limits< COL_TYPE >::max(), | |||
"COL_TYPE must be able to hold the range of columns: [0, " << ncols - 1 << "]." ); | |||
LVARRAY_ERROR_IF_PRINTF( ncols - 1 > std::numeric_limits< COL_TYPE >::max(), |
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.
Same here.
Ok thanks, I'll change the code. I was indeed wondering how we tested LVArray, thanks for the explanation i'll do so. |
LVARRAY_ERROR_IF( !arrayManipulation::isPositive( i ) || i >= this->size(), \ | ||
"Bounds Check Failed: i=" << i << " size()=" << this->size() ) | ||
LVARRAY_ERROR_IF_PRINTF( !arrayManipulation::isPositive( i ) || i >= this->size(), \ | ||
"Bounds Check Failed: i=%" PRId64 " size()=%" PRId64, (int64_t)i, (int64_t)this->size() ) |
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.
where is PRId64
defined, and what if the index is not 64 bit?
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.
PRId64 is in inttypes.h https://www.cplusplus.com/reference/cinttypes/,
Int are casted into int64 to be sure not to have overflow.
* Add execution policy parameter to ArrayOfSets::assimilate(). Add new method ArrayOfArrays::resizeFromOffsets(). * Add unit test for ArrayOfArrays::resizeFromOffsets. * Extract common code of ArrayOfArraysView::resizeFrom functions
…/LvArray into feature/deviceErrorMessage
Any reason you closed this, it seems quite nice. |
It raised errors in geosx that i failed to fix. And i have no time at the
moment to do it.
You can reopen if you want.
Regards,
XL
Le mar. 7 juin 2022, 18:59, Ben Corbett ***@***.***> a écrit :
… Any reason you closed this, it seems quite nice.
—
Reply to this email directly, view it on GitHub
<#255 (comment)>, or
unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAL44MTWSSLOKQSY6SLZJ23VN55X7ANCNFSM5RVPHDXQ>
.
You are receiving this because you modified the open/close state.Message
ID: ***@***.***>
|
Attempt to solve issue #254.
Added new macro to use printf on device with clearer message.
Still not perfect, we don't know were we are when the error is raised.
Now the dimensions are correctly printed:
***** ERROR
***** LOCATION: /work206/workrd/users/lacoste_x/remote_builds/GEOSX/src/coreComponents/LvArray/src/ArraySlice.hpp:295
***** Block: [3, 0, 0]
***** Thread: [16, 0, 0]
***** Controlling expression (should be false): index < 0 || index >= m_dims[ 0 ]
***** MSG: Array Bounds Check Failed: index=8 m_dims[0]=8