Skip to content
Snippets Groups Projects
Commit 3e7a4a54 authored by Adam Edward Barton's avatar Adam Edward Barton
Browse files

Merge branch 'control_thrchk' into 'master'

Control: enable thread-checker for several packages

See merge request atlas/athena!49967
parents 35bdc1f7 8a57e508
No related branches found
No related tags found
No related merge requests found
Showing
with 52 additions and 86 deletions
Control/AthCUDA/AthCUDACore
# Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Set the name of the package. # Set the name of the package.
atlas_subdir( AthCUDACore ) atlas_subdir( AthCUDACore )
...@@ -14,7 +14,7 @@ atlas_add_library( AthCUDACoreLib ...@@ -14,7 +14,7 @@ atlas_add_library( AthCUDACoreLib
PUBLIC_HEADERS AthCUDACore PUBLIC_HEADERS AthCUDACore
INCLUDE_DIRS ${TBB_INCLUDE_DIRS} INCLUDE_DIRS ${TBB_INCLUDE_DIRS}
LINK_LIBRARIES ${TBB_LIBRARIES} GaudiKernel LINK_LIBRARIES ${TBB_LIBRARIES} GaudiKernel
PRIVATE_LINK_LIBRARIES Threads::Threads AthCUDAInterfacesLib ) PRIVATE_LINK_LIBRARIES Threads::Threads AthCUDAInterfacesLib CxxUtils )
# Unit test(s) in the package. # Unit test(s) in the package.
atlas_add_test( Memory atlas_add_test( Memory
......
// //
// Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration // Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
// //
#include "CxxUtils/checker_macros.h"
// Local include(s). // Local include(s).
#include "AthCUDACore/TaskArena.h" #include "AthCUDACore/TaskArena.h"
...@@ -9,7 +11,7 @@ namespace AthCUDA { ...@@ -9,7 +11,7 @@ namespace AthCUDA {
tbb::task_arena& taskArena() { tbb::task_arena& taskArena() {
static tbb::task_arena arena( 1, 0 ); static tbb::task_arena arena ATLAS_THREAD_SAFE ( 1, 0 );
return arena; return arena;
} }
......
Control/AthCUDA/AthCUDAInterfaces
Control/AthCUDA/AthCUDAKernel
Control/AthCUDA/AthCUDAServices
Control/AthenaExamples/AthAsgExUnittest
Control/AthenaExamples/AthExCUDA
Control/AthenaExamples/AthExFortranAlgorithm
Control/AthenaExamples/AthExHIP
Control/AthenaExamples/AthExHistNtup
Control/AthenaExamples/AthExHive
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration # Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
# Declare the package name: # Declare the package name:
atlas_subdir( AthExHive ) atlas_subdir( AthExHive )
# External dependencies: # External dependencies:
find_package( Boost ) find_package( Boost )
find_package( CLHEP )
# Component(s) in the package: # Component(s) in the package:
atlas_add_library( AthExHiveLib atlas_add_library( AthExHiveLib
...@@ -18,7 +19,8 @@ atlas_add_component( AthExHive ...@@ -18,7 +19,8 @@ atlas_add_component( AthExHive
src/condEx/*.cxx src/condEx/*.cxx
src/loopTest/*.cxx src/loopTest/*.cxx
src/components/*.cxx src/components/*.cxx
LINK_LIBRARIES AthenaKernel AthenaBaseComps StoreGateLib xAODEventInfo AthExHiveLib ) INCLUDE_DIRS ${Boost_INCLUDE_DIRS} ${CLHEP_INCLUDE_DIRS}
LINK_LIBRARIES ${Boost_LIBRARIES} ${CLHEP_LIBRARIES} AthenaKernel AthenaBaseComps GaudiKernel StoreGateLib xAODEventInfo AthExHiveLib )
# Install files from the package: # Install files from the package:
atlas_install_joboptions( share/*.py ) atlas_install_joboptions( share/*.py )
......
/* /*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "HiveAlgBase.h" #include "HiveAlgBase.h"
#include <thread> #include <thread>
#include "AthenaKernel/RNGWrapper.h"
#include "CLHEP/Random/RandomEngine.h"
#include "CLHEP/Random/RandFlat.h"
HiveAlgBase::HiveAlgBase( const std::string& name, HiveAlgBase::HiveAlgBase( const std::string& name,
ISvcLocator* pSvcLocator ) : ISvcLocator* pSvcLocator ) :
::AthAlgorithm( name, pSvcLocator ), ::AthAlgorithm( name, pSvcLocator ),
m_hes("HiveExSvc",name), m_hes("HiveExSvc",name),
m_ccs("CPUCrunchSvc",name) {} m_ccs("CPUCrunchSvc",name),
m_rngSvc("AthRNGSvc", name) {}
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
...@@ -22,16 +27,11 @@ StatusCode HiveAlgBase::initialize() { ...@@ -22,16 +27,11 @@ StatusCode HiveAlgBase::initialize() {
// retrieve the CPUCrunchSvc if Alg chooses to Crunch instead of Sleep // retrieve the CPUCrunchSvc if Alg chooses to Crunch instead of Sleep
if (m_doCrunch) { if (m_doCrunch) {
if (m_ccs.retrieve().isFailure()) { ATH_CHECK( m_ccs.retrieve() );
ATH_MSG_ERROR("unable to retrieve the CPUCrunchSvc");
return StatusCode::FAILURE;
}
} }
if (m_hes.retrieve().isFailure()) { ATH_CHECK( m_hes.retrieve() );
ATH_MSG_ERROR("unable to retrieve the HiveExSvc"); ATH_CHECK( m_rngSvc.retrieve() );
return StatusCode::FAILURE;
}
return StatusCode::SUCCESS; return StatusCode::SUCCESS;
} }
...@@ -41,8 +41,12 @@ StatusCode HiveAlgBase::initialize() { ...@@ -41,8 +41,12 @@ StatusCode HiveAlgBase::initialize() {
unsigned int unsigned int
HiveAlgBase::sleep() { HiveAlgBase::sleep() {
auto ctx = Gaudi::Hive::currentContext();
ATHRNG::RNGWrapper* rngWrapper = m_rngSvc->getEngine(this);
rngWrapper->setSeed( name(), ctx );
// add a bit of variability to the sleep/crunch time // add a bit of variability to the sleep/crunch time
unsigned int sleep = igen( m_time ); const unsigned int sleep = CLHEP::RandFlat::shoot(rngWrapper->getEngine(ctx), 0, m_time);
if (m_doCrunch) { if (m_doCrunch) {
ATH_MSG_INFO(" crunch for: " << sleep << " ms"); ATH_MSG_INFO(" crunch for: " << sleep << " ms");
......
/* /*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
/** /**
...@@ -16,14 +16,14 @@ ...@@ -16,14 +16,14 @@
#define ATHEXHIVE_BASEALG_H 1 #define ATHEXHIVE_BASEALG_H 1
#include "AthenaBaseComps/AthAlgorithm.h" #include "AthenaBaseComps/AthAlgorithm.h"
#include "AthenaKernel/IAthRNGSvc.h"
#include "GaudiKernel/ServiceHandle.h" #include "GaudiKernel/ServiceHandle.h"
#include "GaudiKernel/ICPUCrunchSvc.h" #include "GaudiKernel/ICPUCrunchSvc.h"
#include "AthExHive/IHiveExSvc.h" #include "AthExHive/IHiveExSvc.h"
#include "rGen.h"
#include <string> #include <string>
class HiveAlgBase : public AthAlgorithm, public rGen { class HiveAlgBase : public AthAlgorithm {
public: public:
...@@ -45,7 +45,10 @@ protected: ...@@ -45,7 +45,10 @@ protected:
// Handle to CPUCrunchSvc, which burns CPU time // Handle to CPUCrunchSvc, which burns CPU time
ServiceHandle<ICPUCrunchSvc> m_ccs; ServiceHandle<ICPUCrunchSvc> m_ccs;
// Handle to random number service
ServiceHandle<IAthRNGSvc> m_rngSvc;
private: private:
Gaudi::Property<unsigned int> m_time{this, "Time", 0, "default alg sleep time in ms"}; Gaudi::Property<unsigned int> m_time{this, "Time", 0, "default alg sleep time in ms"};
......
/* /*
Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
*/ */
#include "ASCIICondDbSvc.h" #include "ASCIICondDbSvc.h"
...@@ -11,13 +11,13 @@ ...@@ -11,13 +11,13 @@
#include <fstream> #include <fstream>
std::string r_t("\\[([0-9]+),([0-9]+)\\]"); const std::string r_t("\\[([0-9]+),([0-9]+)\\]");
std::string r_r = "\\s*\\{" + r_t + "-" + r_t + "\\}\\s*"; const std::string r_r = "\\s*\\{" + r_t + "-" + r_t + "\\}\\s*";
std::string r_e = "\\s*\\{" + r_t + "-" + r_t + "\\}=([0-9]+)\\s*"; const std::string r_e = "\\s*\\{" + r_t + "-" + r_t + "\\}=([0-9]+)\\s*";
std::string r_ef = "\\s*\\{" + r_t + "-" + r_t + "\\}=(-*[0-9]*\\.*[0-9]*)\\s*"; const std::string r_ef = "\\s*\\{" + r_t + "-" + r_t + "\\}=(-*[0-9]*\\.*[0-9]*)\\s*";
boost::regex rr(r_r); const boost::regex rr(r_r);
boost::regex re(r_e); const boost::regex re(r_e);
boost::regex ref(r_ef); const boost::regex ref(r_ef);
//--------------------------------------------------------------------------- //---------------------------------------------------------------------------
......
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
#include "rGen.h"
#include <thread>
std::once_flag rGen::m_f;
std::default_random_engine rGen::m_gen;
std::uniform_real_distribution<float> rGen::m_dst(0.5,2.0);
void rGen::init() {
unsigned long seed = std::hash<std::thread::id>()(std::this_thread::get_id());
m_gen.seed(seed);
}
/*
Copyright (C) 2002-2019 CERN for the benefit of the ATLAS collaboration
*/
/**
* @file rGen.h
* @brief interface to a random number generator, used to make sleep time
* of Algorithms slightly variable
*/
#ifndef RGEN_H
#define RGEN_H 1
#include <random>
#include <mutex>
class rGen {
public:
rGen() {
std::call_once( m_f, &rGen::init, this );
}
float gen() {
return m_dst(m_gen);
}
unsigned int igen(int t) {
return (unsigned int)( m_dst(m_gen) * float(t) );
}
private:
void init();
static std::once_flag m_f;
static std::default_random_engine m_gen;
static std::uniform_real_distribution<float> m_dst;
};
#endif
Control/AthenaExamples/AthExJobOptions
Control/AthenaExamples/AthExMonitored
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment