ATLAS Offline Software
Loading...
Searching...
No Matches
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
19namespace 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
89 uint32_t* m_host_buf_in1 = nullptr;
90 uint32_t* m_host_buf_in2 = nullptr;
91 uint32_t* m_host_buf_out = nullptr;
92 };
93
96
97}; // class VectorMultOCLExampleAlg
98
99} // namespace AthExXRT
100
101#endif // ATHEXXRT_VECTORMULTOCLEXAMPLEALG_H
Maintain a set of objects, one per slot.
Example algorithm exercising the AthXRT core services.
virtual StatusCode stop_worker() override
clean up
virtual StatusCode stop() override
virtual StatusCode initialize_global() override
Glocal XRT initialization.
ServiceHandle< AthXRT::IDeviceMgmtSvc > m_DeviceMgmtSvc
The XRT device manager to use.
SG::SlotSpecificObj< SlotData > m_slots
List of slot-specific data.
std::vector< AthXRT::IDeviceMgmtSvc::OpenCLHandle > m_handles
virtual StatusCode initialize() override
virtual StatusCode initialize_worker() override
Initialization per process.
virtual StatusCode execute(const EventContext &ctx) const override
Function executing the algorithm.
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< cl::Buffer > m_dev_buf_in1
Buffer objects.
std::shared_ptr< cl::Context > m_context
OpenCL context pointer.
std::shared_ptr< cl::Program > m_program
OpenCL program pointer.
std::unique_ptr< cl::CommandQueue > m_queue
Kernel run object.
std::unique_ptr< cl::Kernel > m_kernel
Kernel object.