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

Fixed a bug in the SecondaryEvent delivery #963

Merged
merged 1 commit into from
Jun 5, 2018
Merged

Conversation

janhahne
Copy link
Contributor

@janhahne janhahne commented Jun 4, 2018

This PR fixes #955. The origin of the error is explained in the corresponding issue.

All SecondaryEvents which exist at the moment use double as data type. In this cases the sizes in question are the same (this is actually the case for most data types that I checked), which is why this error remained undetected until now (and cannot be tested with the current master).

I have created a branch (based on 5g) where I created an additional SecondaryEvent with bool data (see https://github.com/janhahne/nest-simulator/tree/5g_bool_sec_event). After merging the fix everything works fine there now.

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.

Looks fine in principle, but see my inline comment.

for ( typename std::vector< DataType >::iterator i = coeffarray_as_d_begin_;
i != coeffarray_as_d_end_;
i++ )
{
write_to_comm_buffer( *i, pos );
elem = *i;
write_to_comm_buffer( elem, pos );
Copy link
Contributor

Choose a reason for hiding this comment

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

I would make this even more compact as

const DataType elem = *i;

And one should probably be able to do it as a one-liner:

write_to_comm_buffer( static_cast< DataType >(*i), pos );

I would prefer that, keeping things as tight as possible.

I would also strongly suggest adding a comment here why this extra effort is necessary.

@janhahne
Copy link
Contributor Author

janhahne commented Jun 5, 2018

@heplesser You are right, a static_cast is more compact. Please have another look.

@heplesser heplesser requested a review from hakonsbm June 5, 2018 12:19
Copy link
Contributor

@hakonsbm hakonsbm left a 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.

@heplesser heplesser merged commit 5a841f0 into nest:master Jun 5, 2018
@janhahne janhahne deleted the fix955 branch June 5, 2018 21:34
@terhorstd terhorstd added T: Bug Wrong statements in the code or documentation ZC: Kernel DO NOT USE THIS LABEL ZP: PR Created DO NOT USE THIS LABEL S: High Should be handled next I: No breaking change Previously written code will work as before, no one should note anything changing (aside the fix) labels Aug 20, 2018
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: High Should be handled next 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.

SecondaryEvent data type smaller than unsigned int
4 participants