ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaExamples
AthExXRT
src
VectorAddOCLExampleAlg.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_VECTORADDOCLEXAMPLEALG_H
5
#define ATHEXXRT_VECTORADDOCLEXAMPLEALG_H
6
7
// STL include(s).
8
#include <memory>
9
10
// AthXRT include(s).
11
#include "
AthXRTInterfaces/IDeviceMgmtSvc.h
"
12
#include "
AthXRTInterfaces/StateHandler.h
"
13
14
// Framework include(s).
15
#include "
AthenaBaseComps/AthReentrantAlgorithm.h
"
16
#include "
AthenaKernel/SlotSpecificObj.h
"
17
#include "GaudiKernel/ServiceHandle.h"
18
19
namespace
AthExXRT
{
20
29
class
VectorAddOCLExampleAlg
:
public
::AthReentrantAlgorithm
,
public
AthXRT::StateHandler
{
30
31
public
:
32
// Inherit the base class's constructor(s).
33
using
::AthReentrantAlgorithm::AthReentrantAlgorithm;
34
35
virtual
StatusCode
initialize
()
override
{
36
return
StateHandler::initialize();
37
}
38
39
virtual
StatusCode
initialize_global
()
override
;
40
virtual
StatusCode
initialize_worker
()
override
;
41
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
:
50
52
ServiceHandle<AthXRT::IDeviceMgmtSvc>
m_DeviceMgmtSvc
{
53
this
,
"DeviceMgmtSvc"
,
"AthXRT::DeviceMgmtSvc"
,
54
"The XRT device manager service to use"
};
55
56
// Kernel name string
57
static
constexpr
char
s_krnl_name
[] =
"krnl_VectorAdd"
;
58
59
// Kernel arguments indexes
60
// Must match the kernel arguments order.
61
static
constexpr
int
s_krnl_param_in1
= 0;
62
static
constexpr
int
s_krnl_param_in2
= 1;
63
static
constexpr
int
s_krnl_param_out
= 2;
64
static
constexpr
int
s_krnl_param_size
= 3;
65
66
// Number of uint32_t element in the vectors
67
static
constexpr
int
s_element_count
= 4096;
68
69
std::vector<AthXRT::IDeviceMgmtSvc::OpenCLHandle>
m_handles
;
70
72
struct
SlotData
{
74
std::shared_ptr<cl::Context>
m_context
=
nullptr
;
75
77
std::shared_ptr<cl::Program>
m_program
=
nullptr
;
78
80
std::unique_ptr<cl::Kernel>
m_kernel
=
nullptr
;
81
83
std::unique_ptr<cl::CommandQueue>
m_queue
=
nullptr
;
84
86
std::unique_ptr<cl::Buffer>
m_dev_buf_in1
=
nullptr
;
87
std::unique_ptr<cl::Buffer>
m_dev_buf_in2
=
nullptr
;
88
std::unique_ptr<cl::Buffer>
m_dev_buf_out
=
nullptr
;
89
90
uint32_t*
m_host_buf_in1
=
nullptr
;
91
uint32_t*
m_host_buf_in2
=
nullptr
;
92
uint32_t*
m_host_buf_out
=
nullptr
;
93
};
94
96
SG::SlotSpecificObj<SlotData>
m_slots
;
97
98
};
// class VectorAddOCLExampleAlg
99
100
}
// namespace AthExXRT
101
102
#endif
// ATHEXXRT_VECTORADDOCLEXAMPLEALG_H
AthReentrantAlgorithm.h
SlotSpecificObj.h
Maintain a set of objects, one per slot.
IDeviceMgmtSvc.h
StateHandler.h
AthExXRT::VectorAddOCLExampleAlg
Example algorithm exercising the AthXRT core services.
Definition
VectorAddOCLExampleAlg.h:29
AthExXRT::VectorAddOCLExampleAlg::s_element_count
static constexpr int s_element_count
Definition
VectorAddOCLExampleAlg.h:67
AthExXRT::VectorAddOCLExampleAlg::m_slots
SG::SlotSpecificObj< SlotData > m_slots
List of slot-specific data.
Definition
VectorAddOCLExampleAlg.h:96
AthExXRT::VectorAddOCLExampleAlg::initialize_worker
virtual StatusCode initialize_worker() override
Initialization per process.
Definition
VectorAddOCLExampleAlg.cxx:30
AthExXRT::VectorAddOCLExampleAlg::s_krnl_name
static constexpr char s_krnl_name[]
Definition
VectorAddOCLExampleAlg.h:57
AthExXRT::VectorAddOCLExampleAlg::m_DeviceMgmtSvc
ServiceHandle< AthXRT::IDeviceMgmtSvc > m_DeviceMgmtSvc
The XRT device manager to use.
Definition
VectorAddOCLExampleAlg.h:52
AthExXRT::VectorAddOCLExampleAlg::s_krnl_param_in2
static constexpr int s_krnl_param_in2
Definition
VectorAddOCLExampleAlg.h:62
AthExXRT::VectorAddOCLExampleAlg::stop
virtual StatusCode stop() override
Definition
VectorAddOCLExampleAlg.h:44
AthExXRT::VectorAddOCLExampleAlg::initialize
virtual StatusCode initialize() override
Definition
VectorAddOCLExampleAlg.h:35
AthExXRT::VectorAddOCLExampleAlg::initialize_global
virtual StatusCode initialize_global() override
Glocal XRT initialization.
Definition
VectorAddOCLExampleAlg.cxx:13
AthExXRT::VectorAddOCLExampleAlg::s_krnl_param_in1
static constexpr int s_krnl_param_in1
Definition
VectorAddOCLExampleAlg.h:61
AthExXRT::VectorAddOCLExampleAlg::s_krnl_param_size
static constexpr int s_krnl_param_size
Definition
VectorAddOCLExampleAlg.h:64
AthExXRT::VectorAddOCLExampleAlg::execute
virtual StatusCode execute(const EventContext &ctx) const override
Definition
VectorAddOCLExampleAlg.cxx:133
AthExXRT::VectorAddOCLExampleAlg::s_krnl_param_out
static constexpr int s_krnl_param_out
Definition
VectorAddOCLExampleAlg.h:63
AthExXRT::VectorAddOCLExampleAlg::stop_worker
virtual StatusCode stop_worker() override
clean up
Definition
VectorAddOCLExampleAlg.cxx:116
AthExXRT::VectorAddOCLExampleAlg::m_handles
std::vector< AthXRT::IDeviceMgmtSvc::OpenCLHandle > m_handles
Definition
VectorAddOCLExampleAlg.h:69
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
SG::SlotSpecificObj
Maintain a set of objects, one per slot.
Definition
AthenaKernel/AthenaKernel/SlotSpecificObj.h:84
ServiceHandle
Definition
ClusterMakerTool.h:36
AthExXRT
Definition
VectorAddOCLExampleAlg.cxx:11
AthExXRT::VectorAddOCLExampleAlg::SlotData
Slot-specific state.
Definition
VectorAddOCLExampleAlg.h:72
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_program
std::shared_ptr< cl::Program > m_program
OpenCL program pointer.
Definition
VectorAddOCLExampleAlg.h:77
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_kernel
std::unique_ptr< cl::Kernel > m_kernel
Kernel object.
Definition
VectorAddOCLExampleAlg.h:80
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_context
std::shared_ptr< cl::Context > m_context
OpenCL context pointer.
Definition
VectorAddOCLExampleAlg.h:74
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_queue
std::unique_ptr< cl::CommandQueue > m_queue
Kernel run object.
Definition
VectorAddOCLExampleAlg.h:83
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_dev_buf_in2
std::unique_ptr< cl::Buffer > m_dev_buf_in2
Definition
VectorAddOCLExampleAlg.h:87
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_dev_buf_out
std::unique_ptr< cl::Buffer > m_dev_buf_out
Definition
VectorAddOCLExampleAlg.h:88
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_dev_buf_in1
std::unique_ptr< cl::Buffer > m_dev_buf_in1
Buffer objects.
Definition
VectorAddOCLExampleAlg.h:86
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_host_buf_in2
uint32_t * m_host_buf_in2
Definition
VectorAddOCLExampleAlg.h:91
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_host_buf_out
uint32_t * m_host_buf_out
Definition
VectorAddOCLExampleAlg.h:92
AthExXRT::VectorAddOCLExampleAlg::SlotData::m_host_buf_in1
uint32_t * m_host_buf_in1
Definition
VectorAddOCLExampleAlg.h:90
Generated on
for ATLAS Offline Software by
1.17.0