The Gaudi Framework  v39r1 (adb068b2)
GPUCruncher.h
Go to the documentation of this file.
1 /***********************************************************************************\
2 * (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3 * *
4 * This software is distributed under the terms of the Apache version 2 licence, *
5 * copied verbatim in the file "LICENSE". *
6 * *
7 * In applying this licence, CERN does not waive the privileges and immunities *
8 * granted to it by virtue of its status as an Intergovernmental Organization *
9 * or submit itself to any jurisdiction. *
10 \***********************************************************************************/
11 
12 #include <Gaudi/AsynchronousAlgorithm.h>
17 #include <tbb/concurrent_hash_map.h>
18 
19 //------------------------------------------------------------------------------
20 
26 class GPUCruncher : public Gaudi::AsynchronousAlgorithm {
27 
28 public:
29  typedef tbb::concurrent_hash_map<std::string, unsigned int> CHM;
30 
31  bool isClonable() const override { return true; }
32 
34  StatusCode execute( const EventContext& ctx ) const override;
36  StatusCode initialize() override;
38  StatusCode finalize() override;
39 
40  double get_runtime() const { return m_avg_runtime; }
41 
42  GPUCruncher( const std::string& name, // the algorithm instance name
43  ISvcLocator* pSvc ); // the Service Locator
44 
46  virtual ~GPUCruncher(); // virtual & protected destructor
47 
48 private:
50  GPUCruncher(); // no default constructor
52  GPUCruncher( const GPUCruncher& ); // no copy constructor
54  GPUCruncher& operator=( const GPUCruncher& ); // no assignement
56  StatusCode gpuExecute( const std::pmr::vector<double>& in, std::vector<double>& out ) const;
57 
60 
61  Gaudi::Property<double> m_avg_runtime{ this, "avgRuntime", 1., "Average runtime of the module." };
62  Gaudi::Property<double> m_var_runtime{ this, "varRuntime", 0.01, "Variance of the runtime of the module." };
63  Gaudi::Property<bool> m_local_rndm_gen{ this, "localRndm", true,
64  "Decide if the local random generator is to be used" };
65 
66  // For allocating CUDA pinned memory
67  std::pmr::memory_resource* pinned;
68 
69  // For the concurrency
70  const uint MAX_INPUTS = 40;
71  const uint MAX_OUTPUTS = 10;
72 
75 
77 };
GPUCruncher::m_inpKeys
Gaudi::Property< std::vector< std::string > > m_inpKeys
Definition: GPUCruncher.h:58
std::string
STL class.
GPUCruncher::finalize
StatusCode finalize() override
the finalization of the algorithm
Definition: GPUCruncher.cpp:191
GPUCruncher::isClonable
bool isClonable() const override
Definition: GPUCruncher.h:31
RndmGenerators.h
GPUCruncher::m_outputHandles
std::vector< DataObjectHandle< DataObject > * > m_outputHandles
Definition: GPUCruncher.h:74
GPUCruncher::MAX_INPUTS
const uint MAX_INPUTS
Definition: GPUCruncher.h:70
std::vector< double >
GPUCruncher::m_var_runtime
Gaudi::Property< double > m_var_runtime
Definition: GPUCruncher.h:62
ISvcLocator
Definition: ISvcLocator.h:46
IRndmGenSvc.h
GPUCruncher::execute
StatusCode execute(const EventContext &ctx) const override
the execution of the algorithm
Definition: GPUCruncher.cpp:84
GPUCruncher::~GPUCruncher
virtual ~GPUCruncher()
virtual & protected desctrustor
Definition: GPUCruncher.cpp:45
GPUCruncher::MAX_OUTPUTS
const uint MAX_OUTPUTS
Definition: GPUCruncher.h:71
RegistryEntry.h
GPUCruncher::operator=
GPUCruncher & operator=(const GPUCruncher &)
the assignement operator is disabled
GPUCruncher::initialize
StatusCode initialize() override
Its initialization.
Definition: GPUCruncher.cpp:51
GPUCruncher::m_inputHandles
std::vector< DataObjectHandle< DataObject > * > m_inputHandles
Definition: GPUCruncher.h:73
GaudiPython.Pythonizations.ctx
ctx
Definition: Pythonizations.py:578
StatusCode
Definition: StatusCode.h:65
GPUCruncher::pinned
std::pmr::memory_resource * pinned
Definition: GPUCruncher.h:67
GPUCruncher::gpuExecute
StatusCode gpuExecute(const std::pmr::vector< double > &in, std::vector< double > &out) const
The GPU intensive function.
GPUCruncher::GPUCruncher
GPUCruncher()
the default constructor is disabled
GPUCruncher::GPUCruncher
GPUCruncher(const GPUCruncher &)
the copy constructor is disabled
ConditionsStallTest.name
name
Definition: ConditionsStallTest.py:77
EventContext
Definition: EventContext.h:34
GPUCruncher::m_outKeys
Gaudi::Property< std::vector< std::string > > m_outKeys
Definition: GPUCruncher.h:59
GPUCruncher::m_name_ncopies_map
static CHM m_name_ncopies_map
Definition: GPUCruncher.h:76
GPUCruncher::get_runtime
double get_runtime() const
Definition: GPUCruncher.h:40
GPUCruncher::CHM
tbb::concurrent_hash_map< std::string, unsigned int > CHM
Definition: GPUCruncher.h:29
GPUCruncher::m_avg_runtime
Gaudi::Property< double > m_avg_runtime
Definition: GPUCruncher.h:61
GPUCruncher
Definition: GPUCruncher.h:26
DataObjectHandle.h
GPUCruncher::m_local_rndm_gen
Gaudi::Property< bool > m_local_rndm_gen
Definition: GPUCruncher.h:63
Gaudi::Property
Implementation of property with value of concrete type.
Definition: Property.h:39
PrepareBase.out
out
Definition: PrepareBase.py:20