MU Library
mu::output_ptr< T > Class Template Reference

Pointer to a kernel output buffer. More...

#include <access.hpp>

Public Types

using element_type = T
 
using kernel_buffer_direction = detail::output_buffer_direction
 
using pointer = T *
 

Public Member Functions

constexpr output_ptr () noexcept=default
 
constexpr output_ptr (T *ptr) noexcept
 
constexpr operator pointer () const noexcept
 
constexpr T & operator* () const noexcept
 
constexpr pointer operator-> () const noexcept
 
constexpr T & operator[] (std::ptrdiff_t index) const noexcept
 

Detailed Description

template<typename T>
class mu::output_ptr< T >

Pointer to a kernel output buffer.

The typed Launcher treats the pointed-to contents as unnecessary when the kernel starts and synchronizes them back to the host after it finishes. Reading an element before the kernel has written it observes an unspecified value; reading a value after writing it is allowed, so this is not a strict write-only proxy.

Launcher calls still pass the original raw pointer (or an NDArray whose data pointer is adapted by the MU entry wrapper); this type belongs in the kernel signature only. Declare it by value, not by reference.

Definition at line 97 of file access.hpp.

Member Typedef Documentation

◆ element_type

template<typename T >
using mu::output_ptr< T >::element_type = T

Definition at line 104 of file access.hpp.

◆ kernel_buffer_direction

Definition at line 105 of file access.hpp.

◆ pointer

template<typename T >
using mu::output_ptr< T >::pointer = T*

Definition at line 106 of file access.hpp.

Constructor & Destructor Documentation

◆ output_ptr() [1/2]

template<typename T >
constexpr mu::output_ptr< T >::output_ptr ( )
constexprdefaultnoexcept

◆ output_ptr() [2/2]

template<typename T >
constexpr mu::output_ptr< T >::output_ptr ( T *  ptr)
inlineconstexprnoexcept

Definition at line 109 of file access.hpp.

110  : ptr_(ptr)
111  {
112  }

Member Function Documentation

◆ operator pointer()

template<typename T >
constexpr mu::output_ptr< T >::operator pointer ( ) const
inlineconstexprnoexcept

Definition at line 114 of file access.hpp.

115  {
116  return ptr_;
117  }

◆ operator*()

template<typename T >
constexpr T& mu::output_ptr< T >::operator* ( ) const
inlineconstexprnoexcept

Definition at line 119 of file access.hpp.

120  {
121  return *ptr_;
122  }

◆ operator->()

template<typename T >
constexpr pointer mu::output_ptr< T >::operator-> ( ) const
inlineconstexprnoexcept

Definition at line 124 of file access.hpp.

125  {
126  return ptr_;
127  }

◆ operator[]()

template<typename T >
constexpr T& mu::output_ptr< T >::operator[] ( std::ptrdiff_t  index) const
inlineconstexprnoexcept

Definition at line 129 of file access.hpp.

130  {
131  return ptr_[index];
132  }

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