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::shared< R > Struct Template Reference

Memory the host and R's devices can both address (CUDA or HIP managed memory, SYCL USM shared, Metal shared storage, an integrated GPU's memory). More...

#include <memory_space.hpp>

Public Types

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

Static Public Member Functions

template<typename T>
requires requires(std::size_t n) { { R::template allocate_shared<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_shared<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_shared<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).
template<typename H>
requires requires(H h) { { R::address(h) } -> std::convertible_to<const volatile void*>; }
static auto address (H h)
 The host address of a handle's first element, for a handle that is not an element pointer: shared memory is host-accessible.

Static Public Attributes

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

Detailed Description

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

Memory the host and R's devices can both address (CUDA or HIP managed memory, SYCL USM shared, Metal shared storage, an integrated GPU's memory).

Both may address it, but not at the same instant: the host touches it only while no device work writing it is in flight.

Member Typedef Documentation

◆ handle_type

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

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

Shared Metal storage is a buffer with a host contents pointer, so its handle carries both.

◆ runtime

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

Member Function Documentation

◆ address()

template<typename R = runtime::preferred>
template<typename H>
requires requires(H h) { { R::address(h) } -> std::convertible_to<const volatile void*>; }
auto mtl::memory_space::shared< R >::address ( H h)
inlinestaticnodiscard

The host address of a handle's first element, for a handle that is not an element pointer: shared memory is host-accessible.

◆ allocate()

template<typename R = runtime::preferred>
template<typename T>
requires requires(std::size_t n) { { R::template allocate_shared<T>(n) } -> std::same_as<handle_type<T>>; }
handle_type< T > mtl::memory_space::shared< 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_shared<T>(h, n); }
void mtl::memory_space::shared< 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_shared<T>(p, n); }
void mtl::memory_space::shared< 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::shared< 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::shared< R >::device_accessible = true
staticconstexpr

◆ host_accessible

template<typename R = runtime::preferred>
bool mtl::memory_space::shared< R >::host_accessible = true
staticconstexpr

◆ name

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

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