ATLAS Offline Software
VectorMultOCLExampleAlg.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3 //
4 #ifndef ATHEXXRT_VECTORMULTOCLEXAMPLEALG_H
5 #define ATHEXXRT_VECTORMULTOCLEXAMPLEALG_H
6 
7 // STL include(s).
8 #include <memory>
9 
10 // AthXRT include(s).
13 
14 // Framework include(s).
17 #include "GaudiKernel/ServiceHandle.h"
18 
19 namespace AthExXRT {
20 
30 
31  public:
32  using ::AthReentrantAlgorithm::AthReentrantAlgorithm;
33 
34  virtual StatusCode initialize() override {
35  return StateHandler::initialize();
36  }
37 
38  virtual StatusCode initialize_global() override;
39  virtual StatusCode initialize_worker() override;
40 
42  virtual StatusCode execute(const EventContext& ctx) const override;
43 
44  virtual StatusCode stop() override {
45  return StateHandler::stop();
46  }
47  virtual StatusCode stop_worker() override;
48 
49  private:
52  this, "DeviceMgmtSvc", "AthXRT::DeviceMgmtSvc",
53  "The XRT device manager service to use"};
54 
55  // Kernel name string
56  static constexpr char s_krnl_name[] = "krnl_VectorMult";
57 
58  // Kernel arguments indexes
59  // Must match the kernel arguments order.
60  static constexpr int s_krnl_param_in1 = 0;
61  static constexpr int s_krnl_param_in2 = 1;
62  static constexpr int s_krnl_param_out = 2;
63  static constexpr int s_krnl_param_size = 3;
64 
65  // Number of uint32_t element in the vectors
66  static constexpr int s_element_count = 4096;
67 
68  std::vector<AthXRT::IDeviceMgmtSvc::OpenCLHandle> m_handles;
69 
71  struct SlotData {
73  std::shared_ptr<cl::Context> m_context = nullptr;
74 
76  std::shared_ptr<cl::Program> m_program = nullptr;
77 
79  std::unique_ptr<cl::Kernel> m_kernel = nullptr;
80 
82  std::unique_ptr<cl::CommandQueue> m_queue = nullptr;
83 
85  std::unique_ptr<cl::Buffer> m_dev_buf_in1 = nullptr;
86  std::unique_ptr<cl::Buffer> m_dev_buf_in2 = nullptr;
87  std::unique_ptr<cl::Buffer> m_dev_buf_out = nullptr;
88 
92  };
93 
96 
97 }; // class VectorMultOCLExampleAlg
98 
99 } // namespace AthExXRT
100 
101 #endif // ATHEXXRT_VECTORMULTOCLEXAMPLEALG_H
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_program
std::shared_ptr< cl::Program > m_program
OpenCL program pointer.
Definition: VectorMultOCLExampleAlg.h:76
AthExXRT::VectorMultOCLExampleAlg::initialize
virtual StatusCode initialize() override
Definition: VectorMultOCLExampleAlg.h:34
AthExXRT::VectorMultOCLExampleAlg::s_krnl_param_out
static constexpr int s_krnl_param_out
Definition: VectorMultOCLExampleAlg.h:62
xAOD::uint32_t
setEventNumber uint32_t
Definition: EventInfo_v1.cxx:127
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_dev_buf_out
std::unique_ptr< cl::Buffer > m_dev_buf_out
Definition: VectorMultOCLExampleAlg.h:87
initialize
void initialize()
Definition: run_EoverP.cxx:894
AthExXRT::VectorMultOCLExampleAlg::stop
virtual StatusCode stop() override
Definition: VectorMultOCLExampleAlg.h:44
AthExXRT
Definition: VectorAddOCLExampleAlg.cxx:11
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_dev_buf_in1
std::unique_ptr< cl::Buffer > m_dev_buf_in1
Buffer objects.
Definition: VectorMultOCLExampleAlg.h:85
PixelModuleFeMask_create_db.stop
int stop
Definition: PixelModuleFeMask_create_db.py:76
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_host_buf_in1
uint32_t * m_host_buf_in1
Definition: VectorMultOCLExampleAlg.h:89
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:74
AthXRT::StateHandler
Base class to provide common infrastructure for handling multiprocess state transitions for FPGA....
Definition: StateHandler.h:27
AthExXRT::VectorMultOCLExampleAlg::stop_worker
virtual StatusCode stop_worker() override
clean up
Definition: VectorMultOCLExampleAlg.cxx:113
AthExXRT::VectorMultOCLExampleAlg
Example algorithm exercising the AthXRT core services.
Definition: VectorMultOCLExampleAlg.h:29
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthExXRT::VectorMultOCLExampleAlg::SlotData
Slot-specific state.
Definition: VectorMultOCLExampleAlg.h:71
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_host_buf_out
uint32_t * m_host_buf_out
Definition: VectorMultOCLExampleAlg.h:91
AthExXRT::VectorMultOCLExampleAlg::s_element_count
static constexpr int s_element_count
Definition: VectorMultOCLExampleAlg.h:66
IDeviceMgmtSvc.h
AthReentrantAlgorithm.h
AthExXRT::VectorMultOCLExampleAlg::m_DeviceMgmtSvc
ServiceHandle< AthXRT::IDeviceMgmtSvc > m_DeviceMgmtSvc
The XRT device manager to use.
Definition: VectorMultOCLExampleAlg.h:51
AthExXRT::VectorMultOCLExampleAlg::m_slots
SG::SlotSpecificObj< SlotData > m_slots
List of slot-specific data.
Definition: VectorMultOCLExampleAlg.h:95
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_host_buf_in2
uint32_t * m_host_buf_in2
Definition: VectorMultOCLExampleAlg.h:90
AthExXRT::VectorMultOCLExampleAlg::s_krnl_param_in1
static constexpr int s_krnl_param_in1
Definition: VectorMultOCLExampleAlg.h:60
AthExXRT::VectorMultOCLExampleAlg::m_handles
std::vector< AthXRT::IDeviceMgmtSvc::OpenCLHandle > m_handles
Definition: VectorMultOCLExampleAlg.h:68
StateHandler.h
AthExXRT::VectorMultOCLExampleAlg::s_krnl_param_size
static constexpr int s_krnl_param_size
Definition: VectorMultOCLExampleAlg.h:63
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_kernel
std::unique_ptr< cl::Kernel > m_kernel
Kernel object.
Definition: VectorMultOCLExampleAlg.h:79
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_dev_buf_in2
std::unique_ptr< cl::Buffer > m_dev_buf_in2
Definition: VectorMultOCLExampleAlg.h:86
AthExXRT::VectorMultOCLExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition: VectorMultOCLExampleAlg.cxx:130
SlotSpecificObj.h
Maintain a set of objects, one per slot.
AthExXRT::VectorMultOCLExampleAlg::initialize_worker
virtual StatusCode initialize_worker() override
Initialization per process.
Definition: VectorMultOCLExampleAlg.cxx:27
AthExXRT::VectorMultOCLExampleAlg::s_krnl_param_in2
static constexpr int s_krnl_param_in2
Definition: VectorMultOCLExampleAlg.h:61
AthExXRT::VectorMultOCLExampleAlg::initialize_global
virtual StatusCode initialize_global() override
Glocal XRT initialization.
Definition: VectorMultOCLExampleAlg.cxx:10
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_context
std::shared_ptr< cl::Context > m_context
OpenCL context pointer.
Definition: VectorMultOCLExampleAlg.h:73
AthExXRT::VectorMultOCLExampleAlg::SlotData::m_queue
std::unique_ptr< cl::CommandQueue > m_queue
Kernel run object.
Definition: VectorMultOCLExampleAlg.h:82
AthExXRT::VectorMultOCLExampleAlg::s_krnl_name
static constexpr char s_krnl_name[]
Definition: VectorMultOCLExampleAlg.h:56
ServiceHandle< AthXRT::IDeviceMgmtSvc >