ATLAS Offline Software
KernelRunnerSvc.h
Go to the documentation of this file.
1 // Dear emacs, this is -*- c++ -*-
2 //
3 // Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
4 //
5 #ifndef ATHCUDASERVICES_KERNELRUNNERSVC_H
6 #define ATHCUDASERVICES_KERNELRUNNERSVC_H
7 
8 // Local include(s).
9 #include "KernelRunnerSvcImpl.h"
10 
11 // AthCUDA include(s).
14 
15 // Framework include(s).
16 #include "GaudiKernel/ServiceHandle.h"
17 #include "Gaudi/Property.h"
19 
20 // System include(s).
21 #include <atomic>
22 #include <memory>
23 
24 namespace AthCUDA {
25 
33  class KernelRunnerSvc : public extends< AthService, IKernelRunnerSvc > {
34 
35  public:
37  using extends::extends;
38 
41 
43  virtual StatusCode initialize() override;
44 
46  virtual StatusCode finalize() override;
47 
49 
52 
68  virtual StatusCode
69  execute( std::unique_ptr< IKernelTask > task ) override;
70 
72 
73  // Function telling the service that a task has finished its execution
74  void setTaskFinished();
75 
76  private:
79 
81  Gaudi::Property< int > m_nKernels{ this, "NParallelKernels", 2,
82  "The number of CUDA kernels to execute in parallel" };
83 
86  "AthCUDA::StreamPoolSvc",
87  "The AthCUDA::StreamPoolSvc instance to use" };
88 
90 
92  std::atomic_int m_kernelsInFlight;
93 
95  std::atomic_uint m_totalTasks;
97  std::atomic_uint m_gpuTasks;
98 
100  std::unique_ptr< KernelRunnerSvcImpl > m_impl;
101 
102  }; // class KernelRunnerSvc
103 
104 } // namespace AthCUDA
105 
106 #endif // ATHCUDASERVICES_KERNELRUNNERSVC_H
AthCUDA::KernelRunnerSvc::m_gpuTasks
std::atomic_uint m_gpuTasks
The number of tasks sent to the GPU during the job.
Definition: KernelRunnerSvc.h:97
AthCUDA::KernelRunnerSvc::initialize
virtual StatusCode initialize() override
Initialise the service.
Definition: KernelRunnerSvc.cxx:18
AthCUDA::KernelRunnerSvc
Service used for executing AthCUDA::IKernelTask tasks.
Definition: KernelRunnerSvc.h:33
AthCUDA::KernelRunnerSvc::setTaskFinished
void setTaskFinished()
Definition: KernelRunnerSvc.cxx:115
AthCUDA::KernelRunnerSvc::m_impl
std::unique_ptr< KernelRunnerSvcImpl > m_impl
Implementation helper object.
Definition: KernelRunnerSvc.h:100
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
KernelRunnerSvcImpl.h
AthCUDA
Definition: Info.h:14
IKernelRunnerSvc.h
AthCUDA::KernelRunnerSvc::m_nKernels
Gaudi::Property< int > m_nKernels
The number of streams to use.
Definition: KernelRunnerSvc.h:81
IStreamPoolSvc.h
AthCUDA::KernelRunnerSvc::m_streamPoolSvc
ServiceHandle< IStreamPoolSvc > m_streamPoolSvc
Service managing CUDA the streams.
Definition: KernelRunnerSvc.h:85
AthCUDA::KernelRunnerSvc::m_kernelsInFlight
std::atomic_int m_kernelsInFlight
The current number of kernels being executed.
Definition: KernelRunnerSvc.h:92
AthService.h
AthCUDA::KernelRunnerSvc::m_totalTasks
std::atomic_uint m_totalTasks
The number of tasks executed during the job in total.
Definition: KernelRunnerSvc.h:95
AthCUDA::KernelRunnerSvc::finalize
virtual StatusCode finalize() override
Finalise the service.
Definition: KernelRunnerSvc.cxx:51
AthCUDA::KernelRunnerSvc::execute
virtual StatusCode execute(std::unique_ptr< IKernelTask > task) override
Execute a user specified kernel task.
Definition: KernelRunnerSvc.cxx:72
ServiceHandle
Definition: ClusterMakerTool.h:37