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

Relax atomic operations on performance counter values #3094

Merged
merged 1 commit into from Jan 17, 2018

Conversation

hkaiser
Copy link
Member

@hkaiser hkaiser commented Jan 8, 2018

This relaxes the atomic operations on performance counter values

if (reset)
value.store(0);
value.store(0, std::memory_order_release);
Copy link
Member

Choose a reason for hiding this comment

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

would it make sense to replace the code with something like this:

if (reset)
    return value.exchange(0, std:.memory_order_acq_rel);
else
    return value.load(std::memory_order_relaxed);

?

Copy link
Member Author

Choose a reason for hiding this comment

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

I'm not sure, if using value.load(std::memory_order_relaxed); would be sufficient, but otherwise this could be done, yes.

Copy link
Member

Choose a reason for hiding this comment

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

I'm not sure about using relaxed either. The idea was: when reading the value, we don't require any ordering since it shouldn't matter if we read an old value.

Copy link
Member Author

Choose a reason for hiding this comment

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

Makes sense. Will fix.

Copy link
Member

@sithhell sithhell left a comment

Choose a reason for hiding this comment

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

LGTM.

@hkaiser hkaiser merged commit 3507be4 into master Jan 17, 2018
@hkaiser hkaiser deleted the relaxed_atomic_operations branch January 17, 2018 15:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants