rexlib 0.1.0
Device-agnostic array computing library for CryoEM and CryoET image processing, with a pluggable backend architecture
Loading...
Searching...
No Matches
Public Member Functions | List of all members
rexlib::device_session Class Reference

Immutable aggregate of a device handle and its associated objects. More...

#include <rexlib/core/hardware/device_session.hpp>

Public Member Functions

 device_session (std::shared_ptr< device > dev, device_properties properties)
 Construct an session wrapping dev.
 
 device_session (const device_session &other)=delete
 
 device_session (device_session &&other)=delete
 
device_session & operator= (const device_session &other)=delete
 
device_session & operator= (device_session &&other)=delete
 
const std::shared_ptr< device > & get_device () const noexcept
 Retrieve the wrapped device handle.
 
const device_properties & get_properties () const noexcept
 Retrieve the static properties of the wrapped device.
 
const std::shared_ptr< memory_allocator > & get_allocator (memory_resource_affinity affinity) const noexcept
 Retrieve the allocator for the given affinity.
 
const std::shared_ptr< command_queue > & get_default_queue () const noexcept
 Retrieve the default command queue of this session.
 

Detailed Description

Immutable aggregate of a device handle and its associated objects.

A device_session bundles a device handle with the objects needed to make it usable: the static device_properties describing it, a memory_allocator selected for each memory_resource_affinity, and a default command_queue created from the device. All of these are resolved once at construction and remain fixed for the lifetime of the session.

Constructor & Destructor Documentation

◆ device_session()

rexlib::device_session::device_session ( std::shared_ptr< device >  dev,
device_properties  properties 
)

Construct an session wrapping dev.

Stores dev and properties and builds the allocator for each memory_resource_affinity by querying dev for the matching memory resource.

Parameters
devDevice to wrap. Must not be null.
propertiesStatic properties describing dev. Taken by value and moved into the session.
Exceptions
std::invalid_argumentif dev is null.
std::runtime_errorif a required memory_resource_affinity has no suitable resource on dev.

Member Function Documentation

◆ get_allocator()

const std::shared_ptr< memory_allocator > & rexlib::device_session::get_allocator ( memory_resource_affinity  affinity) const
noexcept

Retrieve the allocator for the given affinity.

The returned allocator is the one selected at construction for affinity and lives as long as this device_session.

Parameters
affinityThe desired memory_resource_affinity (host or device).
Returns
A reference to the non-null allocator for affinity.

◆ get_default_queue()

const std::shared_ptr< command_queue > & rexlib::device_session::get_default_queue ( ) const
noexcept

Retrieve the default command queue of this session.

Returns
A reference to the non-null default command queue.
See also
command_queue

◆ get_device()

const std::shared_ptr< device > & rexlib::device_session::get_device ( ) const
noexcept

Retrieve the wrapped device handle.

Returns
A reference to the non-null device handle.

◆ get_properties()

const device_properties & rexlib::device_session::get_properties ( ) const
noexcept

Retrieve the static properties of the wrapped device.

Returns
A reference to the device's device_properties.

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