Skip to content

Commit

Permalink
Merge pull request #3550 from Dr15Jones/changeStaticInEgammaTowerIsol…
Browse files Browse the repository at this point in the history
…ationToThreadLocal

Multithreading -- Changed statics to thread_local in EgammaTowerIsolation
  • Loading branch information
ktf committed Apr 30, 2014
2 parents b06e2f6 + 64fb651 commit 1cd6338
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 12 deletions.
24 changes: 16 additions & 8 deletions RecoEgamma/EgammaIsolationAlgos/interface/EgammaTowerIsolation.h
Expand Up @@ -25,6 +25,7 @@
#include <cmath>
#include <algorithm>
#include <cstdint>
#include <atomic>

#include "DataFormats/Math/interface/deltaR.h"

Expand Down Expand Up @@ -99,18 +100,20 @@ class EgammaTowerIsolationNew {

};

/*#define ETISTATDEBUG*/
#ifdef ETISTATDEBUG
namespace etiStat {

struct Count {
uint32_t create=0;
uint32_t comp=0;
uint32_t span=0;
std::atomic<uint32_t> create=0;
std::atomic<uint32_t> comp=0;
std::atomic<uint32_t> span=0;
static Count count;
~Count();
};

}

#endif

template<unsigned int NC>
inline
Expand All @@ -122,8 +125,9 @@ EgammaTowerIsolationNew<NC>::EgammaTowerIsolationNew(float extRadius[NC],
if (nt==0) return;
initSoa();

#ifdef ETISTATDEBUG
etiStat::Count::count.create++;

#endif

for (std::size_t i=0; i!=NCuts; ++i) {
extRadius2_[i]=extRadius[i]*extRadius[i];
Expand Down Expand Up @@ -159,7 +163,9 @@ void
EgammaTowerIsolationNew<NC>::compute(bool et, Sum &sum, reco::SuperCluster const & sc, CaloTowerDetId const * first, CaloTowerDetId const * last) const {
if (nt==0) return;

#ifdef ETISTATDEBUG
etiStat::Count::count.comp++;
#endif

float candEta = sc.eta();
float candPhi = sc.phi();
Expand All @@ -170,7 +176,9 @@ EgammaTowerIsolationNew<NC>::compute(bool et, Sum &sum, reco::SuperCluster const
uint32_t il = lb-eta;
uint32_t iu = std::min(nt,uint32_t(ub-eta+1));

#ifdef ETISTATDEBUG
etiStat::Count::count.span += (iu-il);
#endif

bool ok[iu-il];
for (std::size_t i=il;i!=iu; ++i)
Expand Down Expand Up @@ -228,9 +236,9 @@ class EgammaTowerIsolation {


private:
static EgammaTowerIsolationNew<1> * newAlgo;
static const CaloTowerCollection* oldTowers;
static uint32_t id15;
thread_local static EgammaTowerIsolationNew<1> * newAlgo;
thread_local static const CaloTowerCollection* oldTowers;
thread_local static uint32_t id15;
signed int depth_;
float extRadius;
float intRadius;
Expand Down
9 changes: 5 additions & 4 deletions RecoEgamma/EgammaIsolationAlgos/src/EgammaTowerIsolation.cc
Expand Up @@ -11,6 +11,7 @@
#include<cassert>


#ifdef ETISTATDEBUG
// #include<iostream>
namespace etiStat {
Count::~Count() {
Expand All @@ -20,12 +21,12 @@ namespace etiStat {

Count Count::count;
}
#endif



EgammaTowerIsolationNew<1> *EgammaTowerIsolation::newAlgo=nullptr;
const CaloTowerCollection* EgammaTowerIsolation::oldTowers=nullptr;
uint32_t EgammaTowerIsolation::id15=0;
thread_local EgammaTowerIsolationNew<1> *EgammaTowerIsolation::newAlgo=nullptr;
thread_local const CaloTowerCollection* EgammaTowerIsolation::oldTowers=nullptr;
thread_local uint32_t EgammaTowerIsolation::id15=0;

EgammaTowerIsolation::EgammaTowerIsolation (float extRadiusI,
float intRadiusI,
Expand Down

0 comments on commit 1cd6338

Please sign in to comment.