MTL5 -- Matrix Template Library C++ API
mtl:: -- C++20 header-only linear algebra for mixed-precision algorithm design
Loading...
Searching...
No Matches
mtl::memory_space::device< R > Struct Template Reference

Device memory of runtime R, which host code cannot touch. More...

#include <memory_space.hpp>

Public Types

using runtime = R
template<typename T>
using handle_type = typename detail::runtime_device_handle<R, T>::type
 R's device_handle<T>, or T* when R declares none.

Static Public Member Functions

template<typename T>
requires requires(std::size_t n) { { R::template allocate_device<T>(n) } -> std::same_as<handle_type<T>>; }
static handle_type< T > allocate (std::size_t n)
template<typename T>
requires std::is_same_v<handle_type<T>, T*> && requires(T* p, std::size_t n) { R::template deallocate_device<T>(p, n); }
static void deallocate (T *p, std::size_t n) noexcept
template<typename T>
requires (!std::is_same_v<handle_type<T>, T*>) && requires(handle_type<T> h, std::size_t n) { R::template deallocate_device<T>(h, n); }
static void deallocate (handle_type< T > h, std::size_t n) noexcept
template<typename H>
requires requires(H h, std::size_t i) { { R::offset(h, i) } -> std::same_as<H>; }
static H offset (H h, std::size_t i)
 The handle of element i, for a handle that is not an element pointer (handle_traits steps a T* itself).

Static Public Attributes

static constexpr bool host_accessible = false
static constexpr bool device_accessible = true
static constexpr const char * name = "device"

Detailed Description

template<typename R = runtime::preferred>
struct mtl::memory_space::device< R >

Device memory of runtime R, which host code cannot touch.

Member Typedef Documentation

◆ handle_type

template<typename R = runtime::preferred>
template<typename T>
using mtl::memory_space::device< R >::handle_type = typename detail::runtime_device_handle<R, T>::type

R's device_handle<T>, or T* when R declares none.

◆ runtime

template<typename R = runtime::preferred>
using mtl::memory_space::device< R >::runtime = R

Member Function Documentation

◆ allocate()

template<typename R = runtime::preferred>
template<typename T>
requires requires(std::size_t n) { { R::template allocate_device<T>(n) } -> std::same_as<handle_type<T>>; }
handle_type< T > mtl::memory_space::device< R >::allocate ( std::size_t n)
inlinestaticnodiscard

◆ deallocate() [1/2]

template<typename R = runtime::preferred>
template<typename T>
requires (!std::is_same_v<handle_type<T>, T*>) && requires(handle_type<T> h, std::size_t n) { R::template deallocate_device<T>(h, n); }
void mtl::memory_space::device< R >::deallocate ( handle_type< T > h,
std::size_t n )
inlinestaticnoexcept

◆ deallocate() [2/2]

template<typename R = runtime::preferred>
template<typename T>
requires std::is_same_v<handle_type<T>, T*> && requires(T* p, std::size_t n) { R::template deallocate_device<T>(p, n); }
void mtl::memory_space::device< R >::deallocate ( T * p,
std::size_t n )
inlinestaticnoexcept

◆ offset()

template<typename R = runtime::preferred>
template<typename H>
requires requires(H h, std::size_t i) { { R::offset(h, i) } -> std::same_as<H>; }
H mtl::memory_space::device< R >::offset ( H h,
std::size_t i )
inlinestaticnodiscard

The handle of element i, for a handle that is not an element pointer (handle_traits steps a T* itself).

A pointer to an opaque token is such a handle, so the constraint is only that R provides offset.

Member Data Documentation

◆ device_accessible

template<typename R = runtime::preferred>
bool mtl::memory_space::device< R >::device_accessible = true
staticconstexpr

◆ host_accessible

template<typename R = runtime::preferred>
bool mtl::memory_space::device< R >::host_accessible = false
staticconstexpr

◆ name

template<typename R = runtime::preferred>
const char* mtl::memory_space::device< R >::name = "device"
staticconstexpr

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