ATLAS Offline Software
VectorAddXRTExampleAlg.h
Go to the documentation of this file.
1 //
2 // Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3 //
4 #ifndef ATHEXXRT_VECTORADDXRTEXAMPLEALG_H
5 #define ATHEXXRT_VECTORADDXRTEXAMPLEALG_H
6 
7 // STL include(s).
8 #include <memory>
9 
10 // AthXRT include(s).
12 
13 // Framework include(s).
16 #include "GaudiKernel/ServiceHandle.h"
17 
18 namespace AthExXRT {
19 
29 
30  public:
31  // Inherit the base class's constructor(s).
33 
35  virtual StatusCode initialize() override;
36 
38  virtual StatusCode execute(const EventContext& ctx) const override;
39 
40  private:
43  this, "DeviceMgmtSvc", "AthXRT::DeviceMgmtSvc",
44  "The XRT device manager service to use"};
45 
46  // Kernel name string
47  static constexpr char s_krnl_name[] = "krnl_VectorAdd";
48 
49  // Kernel arguments indexes
50  // Must match the kernel arguments order.
51  static constexpr int s_krnl_param_in1 = 0;
52  static constexpr int s_krnl_param_in2 = 1;
53  static constexpr int s_krnl_param_out = 2;
54  static constexpr int s_krnl_param_size = 3;
55 
56  // Number of uint32_t element in the vectors
57  static constexpr int s_element_count = 4096;
58 
60  struct SlotData {
62  std::shared_ptr<xrt::device> m_device = nullptr;
63 
65  std::unique_ptr<xrt::kernel> m_kernel = nullptr;
66 
68  std::unique_ptr<xrt::run> m_run = nullptr;
69 
71  std::unique_ptr<xrt::bo> m_bo_in1 = nullptr;
72  std::unique_ptr<xrt::bo> m_bo_in2 = nullptr;
73  std::unique_ptr<xrt::bo> m_bo_out = nullptr;
74  };
75 
78 
79 }; // class VectorAddXRTExampleAlg
80 
81 } // namespace AthExXRT
82 
83 #endif // ATHEXXRT_VECTORADDXRTEXAMPLEALG_H
AthExXRT::VectorAddXRTExampleAlg::SlotData
Slot-specific state.
Definition: VectorAddXRTExampleAlg.h:60
AthExXRT::VectorAddXRTExampleAlg::s_krnl_param_in2
static constexpr int s_krnl_param_in2
Definition: VectorAddXRTExampleAlg.h:52
AthExXRT
Definition: VectorAddOCLExampleAlg.cxx:11
AthExXRT::VectorAddXRTExampleAlg::SlotData::m_run
std::unique_ptr< xrt::run > m_run
Kernel run object.
Definition: VectorAddXRTExampleAlg.h:68
AthReentrantAlgorithm
An algorithm that can be simultaneously executed in multiple threads.
Definition: AthReentrantAlgorithm.h:83
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition: AthenaKernel/AthenaKernel/SlotSpecificObj.h:70
AthReentrantAlgorithm::AthReentrantAlgorithm
AthReentrantAlgorithm()
Default constructor:
AthExXRT::VectorAddXRTExampleAlg::SlotData::m_device
std::shared_ptr< xrt::device > m_device
Device pointer.
Definition: VectorAddXRTExampleAlg.h:62
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
AthExXRT::VectorAddXRTExampleAlg::s_krnl_param_in1
static constexpr int s_krnl_param_in1
Definition: VectorAddXRTExampleAlg.h:51
AthExXRT::VectorAddXRTExampleAlg::s_krnl_param_size
static constexpr int s_krnl_param_size
Definition: VectorAddXRTExampleAlg.h:54
AthExXRT::VectorAddXRTExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
Definition: VectorAddXRTExampleAlg.cxx:82
AthExXRT::VectorAddXRTExampleAlg::m_DeviceMgmtSvc
ServiceHandle< AthXRT::IDeviceMgmtSvc > m_DeviceMgmtSvc
The XRT device manager to use.
Definition: VectorAddXRTExampleAlg.h:42
IDeviceMgmtSvc.h
AthReentrantAlgorithm.h
AthExXRT::VectorAddXRTExampleAlg::s_krnl_param_out
static constexpr int s_krnl_param_out
Definition: VectorAddXRTExampleAlg.h:53
AthExXRT::VectorAddXRTExampleAlg::SlotData::m_bo_in1
std::unique_ptr< xrt::bo > m_bo_in1
Buffer objects.
Definition: VectorAddXRTExampleAlg.h:71
AthExXRT::VectorAddXRTExampleAlg::SlotData::m_kernel
std::unique_ptr< xrt::kernel > m_kernel
Kernel object.
Definition: VectorAddXRTExampleAlg.h:65
AthExXRT::VectorAddXRTExampleAlg::SlotData::m_bo_out
std::unique_ptr< xrt::bo > m_bo_out
Definition: VectorAddXRTExampleAlg.h:73
AthExXRT::VectorAddXRTExampleAlg::s_krnl_name
static constexpr char s_krnl_name[]
Definition: VectorAddXRTExampleAlg.h:47
AthExXRT::VectorAddXRTExampleAlg::initialize
virtual StatusCode initialize() override
Function initialising the algorithm.
Definition: VectorAddXRTExampleAlg.cxx:13
SlotSpecificObj.h
Maintain a set of objects, one per slot.
AthExXRT::VectorAddXRTExampleAlg::s_element_count
static constexpr int s_element_count
Definition: VectorAddXRTExampleAlg.h:57
AthExXRT::VectorAddXRTExampleAlg
Example algorithm exercising the AthXRT core services.
Definition: VectorAddXRTExampleAlg.h:28
AthExXRT::VectorAddXRTExampleAlg::m_slots
SG::SlotSpecificObj< SlotData > m_slots
List of slot-specific data.
Definition: VectorAddXRTExampleAlg.h:77
AthExXRT::VectorAddXRTExampleAlg::SlotData::m_bo_in2
std::unique_ptr< xrt::bo > m_bo_in2
Definition: VectorAddXRTExampleAlg.h:72
ServiceHandle< AthXRT::IDeviceMgmtSvc >