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::cpu::cpu_device Class Referencefinal

Implementation of the device interface to represent the CPU. More...

#include <rexlib/backends/cpu/cpu_device.hpp>

Inheritance diagram for rexlib::cpu::cpu_device:
rexlib::device

Public Member Functions

 cpu_device (std::shared_ptr< thread_pool > pool=nullptr)
 Construct a device over its own threads.
 
const memory_resource & get_memory_resource (memory_resource_affinity affinity) const override
 Retrieve a memory resource by its affinity.
 
std::shared_ptr< command_queue > create_command_queue () const override
 Create a new command queue on this device.
 
const std::shared_ptr< thread_pool > & get_thread_pool () const noexcept
 Get the threads this device runs its programs over.
 
- Public Member Functions inherited from rexlib::device
 device (const device &other)=delete
 
 device (device &&other)=delete
 
device & operator= (const device &other)=delete
 
device & operator= (device &&other)=delete
 

Detailed Description

Implementation of the device interface to represent the CPU.

Owns the threads every queue it hands out runs its programs over. The device is the longest lived thing this backend has that is not static, so owning them here is what keeps the workers joined while the program is still running: a pool held by a static instead would be torn down during static destruction, which on Windows means joining threads the loader has already stopped.

Constructor & Destructor Documentation

◆ cpu_device()

rexlib::cpu::cpu_device::cpu_device ( std::shared_ptr< thread_pool >  pool = nullptr)
explicit

Construct a device over its own threads.

Parameters
poolThe threads to run programs over. Built with thread_pool::get_default_worker_count workers when null, which is what every caller but a test wants.

Member Function Documentation

◆ create_command_queue()

std::shared_ptr< command_queue > rexlib::cpu::cpu_device::create_command_queue ( ) const
overridevirtual

Create a new command queue on this device.

The returned queue is independent from any previously created queue on the same device, including the default queue and may execute its commands concurrently with them. A command of one queue is ordered after a command of another by depending on it.

Returns
Newly created queue. Never null.

Implements rexlib::device.

◆ get_memory_resource()

const memory_resource & rexlib::cpu::cpu_device::get_memory_resource ( memory_resource_affinity  affinity) const
overridevirtual

Retrieve a memory resource by its affinity.

Returns the memory_resource that is best suited for the access pattern described by affinity. The returned reference is valid for the lifetime of this device.

Note
Depending on the backend, two distinct affinity values may resolve to the same underlying memory_resource (i.e. the references may alias).
Parameters
affinityThe intended access pattern for which a resource is requested.
Returns
A reference to the matching memory_resource.
See also
memory_resource_affinity
memory_resource

Implements rexlib::device.

◆ get_thread_pool()

const std::shared_ptr< thread_pool > & rexlib::cpu::cpu_device::get_thread_pool ( ) const
noexcept

Get the threads this device runs its programs over.

Returns
const std::shared_ptr<thread_pool>& The pool.

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