-
Notifications
You must be signed in to change notification settings - Fork 373
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
Use vector of integer for per-thread bool indicators #1442
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.
@suku248 Thank you very much, this is very nice! I particularly like your idea to introduce the BoolIndicatorUint64
type to restrict operations. I have some minor questions and suggestions in the code.
Since the issue addressed by this PR is not detected by the test suite and a normal regression test is not feasible, could you add some information to the PR about how you have checked that this PR solves #1394?
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.
Thanks @suku248 for this awesome implementation! :) looks already good and makes also other code easier to read (e.g., in source_table.h
). as @heplesser i was also wondering about the omp barriers
, maybe you could clarify that. just a few additional comments.
void | ||
BoolIndicatorUInt64::logical_and( const bool status ) | ||
{ | ||
status_ = ( static_cast< bool >( status_ ) and status ); |
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.
doesn't this set status_ to and actual bool instead of using the true_uint64
/false_uint64
values?
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.
The right hand side results in a bool
, which is then converted to either integer 0
or 1
when assigned to status_
. This is consistent with the initial assignment of true
and false
to the constants true_uint64
and false_uint64
, respectively. We could use an if/else
here to assign true_uint64/false_uint64
but this might be a bit over the top.
static const uint_fast64_t false_uint64 = false; | ||
uint_fast64_t status_; | ||
|
||
friend class PerThreadBoolIndicator; |
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.
why declare friend
here? aren't you only using public functions in PerThreadBoolIndicator
?
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.
Good point! Thanks! This was required in an earlier version of the code. I have removed this now.
public: | ||
PerThreadBoolIndicator(){}; | ||
|
||
BoolIndicatorUInt64& operator[]( const thread tid ); |
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.
maybe also provide an operator[]
that returns const references in case one is only interested in reading the value?
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.
I would say: To be added as the need arises.
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.
if they'd be provided, wouldn't such calls as in
if ( check_primary_connections_[ tid ].is_false() and is_primary ) |
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.
I think check_primary_connections_
would have to be const
in order to result in a call to the additional constant operator[]
function you are suggesting. But please feel free to try this out and, of course, adapt the code in case you are right. I just don't want to add a function that is currently not used.
@jakobj @heplesser Thank you for your suggestions! I think I have addressed all of your comments. Please take another look. I have repeatedly run the |
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.
thanks for the update @suku248. two more "soft" comments, but i'd also be fine with merging as is. can't believe this is finally fixed 🎉
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.
I haven't looked at this, but I am pressing approved so there is no confusion over the comment part of the review. I am very happy it is fixed, good job! 😄
class CompletedChecker
toclass PerThreadBoolIndicator
and adapt all instances accordinglyPerThreadBoolIndicator
std::vector
ofBoolIndicatorUInt64
instead of array ofbool
inPerThreadBoolIndicator
(
BoolIndicatorUInt64
is a wrapper foruint_fast64_t status_
that restricts functionality tois_true/false()
,set_true/false()
, andlogical_and()
)SourceTable
membersis_cleared_
andsaved_entry_point_
are now of typePerThreadBoolIndicator
instead ofstd::vector<bool >