ATLAS Offline Software
IDeviceMgmtSvc.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 ATHXRTINTERFACES_IDEVICEMGMTSVC_H
5 #define ATHXRTINTERFACES_IDEVICEMGMTSVC_H
6 
7 // Gaudi include(s).
8 #include "GaudiKernel/IService.h"
9 #include "GaudiKernel/StatusCode.h"
10 
11 // XRT includes
12 #include <experimental/xrt_system.h>
13 #include <xrt/xrt_bo.h>
14 #include <xrt/xrt_device.h>
15 #include <xrt/xrt_kernel.h>
16 #include <xrt/xrt_uuid.h>
17 
18 // AMD XRT OpenCL implementation requires these macros to be defined
19 // before including the OpenCL headers to enable OpenCL 1.2 API.
20 #define CL_HPP_CL_1_2_DEFAULT_BUILD
21 #define CL_HPP_TARGET_OPENCL_VERSION 120
22 #define CL_HPP_MINIMUM_OPENCL_VERSION 120
23 #define CL_HPP_ENABLE_PROGRAM_CONSTRUCTION_FROM_ARRAY_COMPATIBILITY 1
24 #define CL_USE_DEPRECATED_OPENCL_1_2_APIS
25 
26 // AMD OpenCL implementation includes.
27 #include <CL/cl2.hpp>
28 #include <CL/cl2xrt.hpp>
29 
30 namespace AthXRT {
31 
41 class IDeviceMgmtSvc : public virtual IService {
42 
43  public:
46 
48  struct OpenCLHandle {
49  std::shared_ptr<cl::Context> context{nullptr};
50  std::shared_ptr<cl::Program> program{nullptr};
51  };
52 
54  virtual const std::vector<IDeviceMgmtSvc::OpenCLHandle>
55  get_opencl_handles_by_kernel_name(const std::string &name) const = 0;
56 
58  virtual const std::vector<std::shared_ptr<xrt::device>>
59  get_xrt_devices_by_kernel_name(const std::string &name) const = 0;
60 
61 }; // class IDeviceMgmtSvc
62 
63 } // namespace AthXRT
64 
65 #endif // ATHXRTINTERFACES_IDEVICEMGMTSVC_H
AthXRT::IDeviceMgmtSvc::OpenCLHandle::context
std::shared_ptr< cl::Context > context
Definition: IDeviceMgmtSvc.h:49
AthXRT::IDeviceMgmtSvc::DeclareInterfaceID
DeclareInterfaceID(AthXRT::IDeviceMgmtSvc, 1, 0)
Declare the interface ID.
AthXRT::IDeviceMgmtSvc::OpenCLHandle::program
std::shared_ptr< cl::Program > program
Definition: IDeviceMgmtSvc.h:50
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
AthXRT::IDeviceMgmtSvc
Interface for AthXRT::DeviceMgmtSvc service.
Definition: IDeviceMgmtSvc.h:41
AthXRT::IDeviceMgmtSvc::OpenCLHandle
Struct holding OpenCL handles for a kernel.
Definition: IDeviceMgmtSvc.h:48
AthXRT::IDeviceMgmtSvc::get_opencl_handles_by_kernel_name
virtual const std::vector< IDeviceMgmtSvc::OpenCLHandle > get_opencl_handles_by_kernel_name(const std::string &name) const =0
Get a list of OpenCL handles providing the specified kernel.
AthXRT
Definition: IDeviceMgmtSvc.h:30
AthXRT::IDeviceMgmtSvc::get_xrt_devices_by_kernel_name
virtual const std::vector< std::shared_ptr< xrt::device > > get_xrt_devices_by_kernel_name(const std::string &name) const =0
Get a list of XRT devices providing the specified kernel.