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

Use vector of integer for per-thread bool indicators #1442

Merged
merged 6 commits into from
Mar 2, 2020

Conversation

suku248
Copy link
Contributor

@suku248 suku248 commented Feb 25, 2020

  • Resolve Spike loss in repeated simulations of exact same script #1394
  • Rename class CompletedChecker to class PerThreadBoolIndicator and adapt all instances accordingly
  • Support subscript read/write access to elements of PerThreadBoolIndicator
  • Use std::vector of BoolIndicatorUInt64 instead of array of bool in PerThreadBoolIndicator
    (BoolIndicatorUInt64 is a wrapper for uint_fast64_t status_ that restricts functionality to is_true/false(), set_true/false(), and logical_and())
  • SourceTable members is_cleared_ and saved_entry_point_ are now of type PerThreadBoolIndicator instead of std::vector<bool >

@suku248 suku248 requested review from heplesser and jakobj February 25, 2020 16:59
@heplesser heplesser added ZC: Kernel DO NOT USE THIS LABEL I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) ZP: PR Created DO NOT USE THIS LABEL S: Critical Needs to be addressed immediately T: Bug Wrong statements in the code or documentation labels Feb 26, 2020
Copy link
Contributor

@heplesser heplesser left a 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?

Copy link
Contributor

@jakobj jakobj left a 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 );
Copy link
Contributor

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?

Copy link
Contributor Author

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;
Copy link
Contributor

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?

Copy link
Contributor Author

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 );
Copy link
Contributor

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?

Copy link
Contributor Author

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.

Copy link
Contributor

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 )
use the const version? depends on what you mean by "need" ;)

Copy link
Contributor Author

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.

@suku248
Copy link
Contributor Author

suku248 commented Feb 28, 2020

@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 hpc_benchmark (adapted to use only a single synapses type for all outgoing connections of excitatory neurons, see #1394) using 32 MPI processes and 24 threads per process (at least 40 repetitions). With the code changes introduced in this PR I no longer observe any variations in spike counts across different runs.

Copy link
Contributor

@jakobj jakobj left a 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 🎉

Copy link
Contributor

@stinebuu stinebuu left a 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! 😄

@terhorstd terhorstd merged commit eab8304 into nest:master Mar 2, 2020
jasperalbers pushed a commit to jasperalbers/nest-simulator that referenced this pull request Mar 6, 2020
jasperalbers pushed a commit to jasperalbers/nest-simulator that referenced this pull request May 13, 2020
suku248 added a commit that referenced this pull request May 25, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) S: Critical Needs to be addressed immediately T: Bug Wrong statements in the code or documentation ZC: Kernel DO NOT USE THIS LABEL ZP: PR Created DO NOT USE THIS LABEL
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Spike loss in repeated simulations of exact same script
6 participants