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

thread safety statics work … #1294

Merged
merged 3 commits into from Nov 4, 2013
Merged

thread safety statics work … #1294

merged 3 commits into from Nov 4, 2013

Conversation

gartung
Copy link
Member

@gartung gartung commented Nov 1, 2013

changed static to static const where possible otherwise used std::atomic<> when value is changed once

changed static to static const where possible otherwise used std::atomic<> when value is set once then read.
@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 1, 2013

A new Pull Request was created by @gartung (Patrick Gartung) for CMSSW_7_0_X.

thread safety statics work

It involves the following packages:

L1Trigger/CSCTriggerPrimitives

@nclopezo, @mulhearn can you please review it and eventually sign? Thanks.
@valuev this is something you requested to watch as well.
You can sign-off by replying to this message having '+1' in the first line of your reply.
You can reject by replying to this message having '-1' in the first line of your reply.
@ktf you are the release manager for this.

@@ -243,7 +243,7 @@
const edm::ParameterSet& ctmb) :
theEndcap(endcap), theStation(station), theSector(sector),
theSubsector(subsector), theTrigChamber(chamber) {
static bool config_dumped = false;
static std::atomic<bool> config_dumped{false};
Copy link
Contributor

Choose a reason for hiding this comment

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

Looking further in the code, the use of std::atomic<bool> isn't proper since it still allows multiple threads to do the 'initail' work. To make it only one thread one changes

if(... !config_dumped) {
...
config_dumped = true;
}

to

bool expected = false;
if(... config_dumped.compare_exchange_strong(false,true, std::memory_order_acq_rel) ) {
...
}

There is no need for a later config_dumped=true since the compare_exchange_strong will set it to true for the first thread to hit that line.

NOTE: this only works if the body of work in the if(...) { } block doesn't do any work needed by the algorithm after that block. If it does, then we'd have to use std::call_once(...) instead.

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 1, 2013

Pull request #1294 was updated. @nclopezo, @mulhearn can you please check and sign again.

@nclopezo
Copy link
Contributor

nclopezo commented Nov 4, 2013

+1
https://cmssdt.cern.ch/SDT/jenkins-artifacts/pull-request-integration/1149/summary.html
The segmentation violation error in 1003.0 step 3 is unrelated

@mulhearn
Copy link
Contributor

mulhearn commented Nov 4, 2013

+1

@cmsbuild
Copy link
Contributor

cmsbuild commented Nov 4, 2013

This pull request is fully signed and it will be integrated in one of the next IBs unless changes or unless it breaks tests. @ktf can you please take care of it?

ktf added a commit that referenced this pull request Nov 4, 2013
…mitives

Multithreading fixes -- Remove statics in L1Trigger/CSCTriggerPrimitives
@ktf ktf merged commit dcaea60 into cms-sw:CMSSW_7_0_X Nov 4, 2013
@gartung gartung deleted the statics-L1Trigger-CSCTriggerPrimitives branch November 4, 2013 16:00
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

6 participants