ATLAS Offline Software
Loading...
Searching...
No Matches
VectorAddXRTExampleAlg.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_VECTORADDXRTEXAMPLEALG_H
5#define ATHEXXRT_VECTORADDXRTEXAMPLEALG_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
20namespace AthExXRT {
21
31
32 public:
33 // Inherit the base class's constructor(s).
34 using AthReentrantAlgorithm::AthReentrantAlgorithm;
35
36 virtual StatusCode initialize() override {
37 return StateHandler::initialize();
38 }
39
40 virtual StatusCode initialize_global() override;
41 virtual StatusCode initialize_worker() override;
42
43 virtual StatusCode execute(const EventContext& ctx) const override;
44
45 private:
46
49 this, "DeviceMgmtSvc", "AthXRT::DeviceMgmtSvc",
50 "The XRT device manager service to use"};
51
52 // Kernel name string
53 static constexpr char s_krnl_name[] = "krnl_VectorAdd";
54
55 // list of found accelerator devices
56 std::vector<std::shared_ptr<xrt::device>> m_devices;
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
69 struct SlotData {
71 std::shared_ptr<xrt::device> m_device = nullptr;
72
74 std::unique_ptr<xrt::kernel> m_kernel = nullptr;
75
77 std::unique_ptr<xrt::run> m_run = nullptr;
78
80 std::unique_ptr<xrt::bo> m_bo_in1 = nullptr;
81 std::unique_ptr<xrt::bo> m_bo_in2 = nullptr;
82 std::unique_ptr<xrt::bo> m_bo_out = nullptr;
83 };
84
87
88}; // class VectorAddXRTExampleAlg
89
90} // namespace AthExXRT
91
92#endif // ATHEXXRT_VECTORADDXRTEXAMPLEALG_H
Maintain a set of objects, one per slot.
Example algorithm exercising the AthXRT core services.
std::vector< std::shared_ptr< xrt::device > > m_devices
virtual StatusCode initialize_worker() override
Initialization per process.
virtual StatusCode initialize() override
ServiceHandle< AthXRT::IDeviceMgmtSvc > m_DeviceMgmtSvc
The XRT device manager to use.
virtual StatusCode initialize_global() override
Glocal XRT initialization.
virtual StatusCode execute(const EventContext &ctx) const override
SG::SlotSpecificObj< SlotData > m_slots
List of slot-specific data.
An algorithm that can be simultaneously executed in multiple threads.
Base class to provide common infrastructure for handling multiprocess state transitions for FPGA.
Maintain a set of objects, one per slot.
std::unique_ptr< xrt::kernel > m_kernel
Kernel object.
std::unique_ptr< xrt::run > m_run
Kernel run object.
std::unique_ptr< xrt::bo > m_bo_in1
Buffer objects.
std::shared_ptr< xrt::device > m_device
Device pointer.