ATLAS Offline Software
Loading...
Searching...
No Matches
AthXRT::DeviceMgmtSvc Class Reference

Service used for programming XRT compatible accelerators. More...

#include <DeviceMgmtSvc.h>

Inheritance diagram for AthXRT::DeviceMgmtSvc:
Collaboration diagram for AthXRT::DeviceMgmtSvc:

Classes

struct  AthClContext
 Struct to hold information about a context, as well as the devices, the program and XCLBIN file associated with the context. More...
struct  SystemInfo
struct  XclbinInfo
 Struct to hold information about an XCLBIN file, as well as the kernels it contains. More...

Public Member Functions

Interface inherited from @c IService
virtual StatusCode initialize () override
 Initialise the service.
virtual StatusCode finalize () override
 Finalise the service.
Interface inherited from @c AthXRT::IDeviceMgmtSvc
virtual const std::vector< IDeviceMgmtSvc::OpenCLHandleget_opencl_handles_by_kernel_name (const std::string &name) const override
 Get a list of OpenCL handles providing the specified kernel.
virtual const std::vector< std::shared_ptr< xrt::device > > get_xrt_devices_by_kernel_name (const std::string &name) const override
 Get a list of XRT devices providing the specified kernel.

Private Member Functions

std::string get_device_name (const cl::Device &device) const
 Get the name of a cl::device.
std::string get_device_bdf (const cl::Device &device) const
 Get the BDF (bus:device:function) string of a cl::device.
StatusCode inspect_devices (SystemInfo &si)
 Inspect the available devices and fill the SystemInfo structure.
StatusCode inspect_xclbins (SystemInfo &si)
 Inspect the provided XCLBIN files and fill the SystemInfo structure.
StatusCode pair_devices_and_xclbins (const SystemInfo &si)
 Pair devices and XCLBINs and create contexts.
StatusCode program_devices ()
 Program the devices with the XCLBIN files and create contexts.
bool is_xclbin_compatible_with_device (const DeviceMgmtSvc::XclbinInfo &xclbin_info, const cl::Device &device) const
 Helper function to check if an XCLBIN file is compatible with a device.

Private Attributes

std::vector< XclbinInfom_xclbin_infos
 List of XCLBIN files info configured for the service.
std::vector< AthClContextm_ath_cl_contexts
 List of contexts configured for the service.
Service properties
Gaudi::Property< std::vector< std::string > > m_xclbin_path_list
 The list of xclbin files to use.

Detailed Description

Service used for programming XRT compatible accelerators.

This service aims to be a central point for managing XRT compatible accelerators. It will enumerate the available devices, program them with the specified XCLBIN files and provide a way for client algorithms to request lists of devices by kernel name, either using native XRT API or OpenCL API.

Author
Quentin Berthet quent.nosp@m.in.b.nosp@m.erthe.nosp@m.t@ce.nosp@m.rn.ch

Definition at line 31 of file DeviceMgmtSvc.h.

Member Function Documentation

◆ finalize()

StatusCode AthXRT::DeviceMgmtSvc::finalize ( )
overridevirtual

Finalise the service.

Definition at line 485 of file DeviceMgmtSvc.cxx.

◆ get_device_bdf()

std::string AthXRT::DeviceMgmtSvc::get_device_bdf ( const cl::Device & device) const
private

Get the BDF (bus:device:function) string of a cl::device.

Parameters
deviceThe device to get the BDF from.
Returns
The BDF of the device as a string, or "error" in case of failure.

Definition at line 194 of file DeviceMgmtSvc.cxx.

◆ get_device_name()

std::string AthXRT::DeviceMgmtSvc::get_device_name ( const cl::Device & device) const
private

Get the name of a cl::device.

Parameters
deviceThe device to get the name from.
Returns
The name of the device as a string, or "error" in case of failure.

Definition at line 179 of file DeviceMgmtSvc.cxx.

◆ get_opencl_handles_by_kernel_name()

const std::vector< IDeviceMgmtSvc::OpenCLHandle > AthXRT::DeviceMgmtSvc::get_opencl_handles_by_kernel_name ( const std::string & name) const
overridevirtual

Get a list of OpenCL handles providing the specified kernel.

Parameters
nameThe name of the kernel to search for.
Returns
A vector of OpenCL handles structs providing the specified kernel.

Definition at line 524 of file DeviceMgmtSvc.cxx.

◆ get_xrt_devices_by_kernel_name()

const std::vector< std::shared_ptr< xrt::device > > AthXRT::DeviceMgmtSvc::get_xrt_devices_by_kernel_name ( const std::string & name) const
overridevirtual

Get a list of XRT devices providing the specified kernel.

Parameters
nameThe name of the kernel to search for.
Returns
A vector of XRT device handles providing the specified kernel.

Definition at line 495 of file DeviceMgmtSvc.cxx.

◆ initialize()

StatusCode AthXRT::DeviceMgmtSvc::initialize ( )
overridevirtual

Initialise the service.

Initialize the service.

This function will inspect the available devices and XCLBIN files, pair them and create contexts based on the information gathered. It will then program the devices with the XCLBIN files and create contexts.

Returns
StatusCode::SUCCESS if the initialization was successful, or StatusCode::FAILURE otherwise.

Definition at line 461 of file DeviceMgmtSvc.cxx.

◆ inspect_devices()

StatusCode AthXRT::DeviceMgmtSvc::inspect_devices ( SystemInfo & si)
private

Inspect the available devices and fill the SystemInfo structure.

Find all available XRT compatible accelerator devices and group them by type.

Parameters
siThe SystemInfo structure to fill

Definition at line 19 of file DeviceMgmtSvc.cxx.

◆ inspect_xclbins()

StatusCode AthXRT::DeviceMgmtSvc::inspect_xclbins ( SystemInfo & si)
private

Inspect the provided XCLBIN files and fill the SystemInfo structure.

Gather information using XRT native API about the XCLBIN files and the kernel(s) they contain and perform some basic sanity checks.

Parameters
siThe SystemInfo structure to fill

Definition at line 91 of file DeviceMgmtSvc.cxx.

◆ is_xclbin_compatible_with_device()

bool AthXRT::DeviceMgmtSvc::is_xclbin_compatible_with_device ( const DeviceMgmtSvc::XclbinInfo & xclbin_info,
const cl::Device & device ) const
private

Helper function to check if an XCLBIN file is compatible with a device.

Check if an XCLBIN is compatible with a device.

This is done by comparing the device name and the XSA name used in the XCLBIN file up to the second occurrence of the underscore character. This check is not a guarantee that the XCLBIN will work on the device, but mismatching XSA names are a strong indicator of incompatibility.

Parameters
xclbin_infoThe XCLBIN to check compatibility with.
deviceThe device to check compatibility with.
Returns
True if the XCLBIN is compatible with the device, false otherwise.

Definition at line 241 of file DeviceMgmtSvc.cxx.

◆ pair_devices_and_xclbins()

StatusCode AthXRT::DeviceMgmtSvc::pair_devices_and_xclbins ( const SystemInfo & si)
private

Pair devices and XCLBINs and create contexts.

This function will pair devices and XCLBINsd epending on the number of devices and XCLBINs, will attempt to program all provided XCLBINs according to the following rules:

  • If we have only one FPGA type and one XCLBIN: Program all devices with the same XCLBIN and create one context.
  • If we have only one FPGA type and multiple identical XCLBIN: Program the same number of devices that we have XCLBIN files, but put them in only one context as the XCLBIN will be identical for all programmed devices.
  • If we have multiple type and multiple different XCLBIN, but all targeting the same device: Program all devices with a different XCLBIN and create one context per device/XCLBIN.
  • If we have multiple type and multiple different XCLBIN, and the XCLBIN files target multiple device types: Program each device with a matching XCLBIN and create one context per device/XCLBIN. Some devices might be left un-programmed if no matching XCLBIN is found.
    Parameters
    siThe SystemInfo structure containing information about the devices and XCLBINs available on the system.
    Returns
    StatusCode::SUCCESS if the pairing was successful, or StatusCode::FAILURE otherwise.

Definition at line 276 of file DeviceMgmtSvc.cxx.

◆ program_devices()

StatusCode AthXRT::DeviceMgmtSvc::program_devices ( )
private

Program the devices with the XCLBIN files and create contexts.

This function will program the devices with the XCLBIN files and create contexts based on the information in m_ath_cl_contexts. If an incompatible XCLBIN is found for a device, the initialization will fail.

Returns
StatusCode::SUCCESS if the programming was successful, or StatusCode::FAILURE otherwise.

Definition at line 396 of file DeviceMgmtSvc.cxx.

Member Data Documentation

◆ m_ath_cl_contexts

std::vector<AthClContext> AthXRT::DeviceMgmtSvc::m_ath_cl_contexts
private

List of contexts configured for the service.

Definition at line 138 of file DeviceMgmtSvc.h.

◆ m_xclbin_infos

std::vector<XclbinInfo> AthXRT::DeviceMgmtSvc::m_xclbin_infos
private

List of XCLBIN files info configured for the service.

Definition at line 126 of file DeviceMgmtSvc.h.

◆ m_xclbin_path_list

Gaudi::Property<std::vector<std::string> > AthXRT::DeviceMgmtSvc::m_xclbin_path_list
private
Initial value:

The list of xclbin files to use.

This is a list of paths to XCLBIN files to load on accelerator devices.

Definition at line 72 of file DeviceMgmtSvc.h.


The documentation for this class was generated from the following files: