batchlas::Span< T > Struct Template Reference

Overview

template<typename T>
struct batchlas::Span< T >

Non-owning view of size() contiguous elements of type T.

The 1-D argument type of the entry points: eigenvalues, singular values, pivots, tau vectors, info arrays and caller-supplied workspace. A Span does not own or free its memory, and copying one copies the pointer. The memory must be USM that the device of the Queue it is used with can access; the entry points check this at the call.

Element access asserts the bounds in a debug build only.

Template Parameters
Telement type

Definition at line 38 of file sycl-span.hh.

#include <batchlas/util/sycl-span.hh>

Types

◆ value_type

template<typename T>
using batchlas::Span< T >::value_type = T

Element type.

Definition at line 40 of file sycl-span.hh.

◆ pointer

template<typename T>
using batchlas::Span< T >::pointer = T*

Pointer to an element.

Definition at line 41 of file sycl-span.hh.

◆ size_t

template<typename T>
using batchlas::Span< T >::size_t = std::size_t

Size and index type.

Definition at line 42 of file sycl-span.hh.

Constructors

◆ Span() [1/8]

template<typename T>
batchlas::Span< T >::Span ( )
inlineconstexpr

An empty span (null data, size 0).

Definition at line 44 of file sycl-span.hh.

◆ Span() [2/8]

template<typename T>
batchlas::Span< T >::Span ( T * data,
size_t size )
inlineconstexpr

Views size elements starting at data.

Definition at line 46 of file sycl-span.hh.

◆ Span() [3/8]

template<typename T>
batchlas::Span< T >::Span ( T * begin,
T * end )
inlineconstexpr

Views the range [begin, end).

Definition at line 48 of file sycl-span.hh.

◆ Span() [4/8]

template<typename T>
batchlas::Span< T >::Span ( const Span< T > & other)
inlineconstexprdefault

Copies the pointer and size; the elements are not copied.

◆ Span() [5/8]

template<typename T>
batchlas::Span< T >::Span ( Span< T > && other)
inlineconstexprdefault

Same as the copy constructor.

◆ Span() [6/8]

template<typename T>
batchlas::Span< T >::Span ( const Span< T > & other,
size_t offset )
inlineconstexpr

Views other with its first offset elements dropped.

Precondition
offset <= other.size()

Definition at line 55 of file sycl-span.hh.

◆ Span() [7/8]

template<typename T>
batchlas::Span< T >::Span ( Span< T > && other,
size_t offset )
inlineconstexpr

Views other with its first offset elements dropped.

Precondition
offset <= other.size()

Definition at line 58 of file sycl-span.hh.

◆ Span() [8/8]

template<typename T>
batchlas::Span< T >::Span ( T & value)
inlineexplicitconstexpr

A one-element span over value.

Explicit on purpose: implicitly, a scalar lvalue became a length-1 buffer wherever a Span parameter's element type is not deduced from the argument, so syev(q, A, W[i * n], ...) (the LAPACK idiom minus the &) compiled and overran the caller's array. Write Span(x) when one element is meant.

See also
Matrix model: Span and UnifiedVector

Definition at line 66 of file sycl-span.hh.

Functions

◆ set_preferred_location()

template<typename T>
Event batchlas::Span< T >::set_preferred_location ( const Queue & ctx = Queue()) const

Prefer residence on the device of ctx.

◆ set_access_device()

template<typename T>
Event batchlas::Span< T >::set_access_device ( const Queue & ctx = Queue()) const

Map for access by the device of ctx.

◆ prefetch()

template<typename T>
Event batchlas::Span< T >::prefetch ( const Queue & ctx = Queue()) const

Migrate to the device of ctx.

◆ as_span()

template<typename T>
template<typename U>
Span< U > batchlas::Span< T >::as_span ( ) const
inlineconstexpr

Reinterprets the bytes as elements of type U; the size is size_bytes() / sizeof(U).

Definition at line 81 of file sycl-span.hh.

◆ subspan() [1/2]

template<typename T>
Span< T > batchlas::Span< T >::subspan ( size_t offset) const
inlineconstexpr

Elements [offset, size()).

Definition at line 86 of file sycl-span.hh.

◆ subspan() [2/2]

template<typename T>
Span< T > batchlas::Span< T >::subspan ( size_t offset,
size_t count ) const
inlineconstexpr

Elements [offset, offset + count).

Precondition
offset + count <= size()

Definition at line 88 of file sycl-span.hh.

◆ operator=() [1/2]

template<typename T>
Span< T > & batchlas::Span< T >::operator= ( const Span< T > & other)
inlineconstexpr

Rebinds this span to other's pointer and size; no elements are copied.

Definition at line 90 of file sycl-span.hh.

◆ operator=() [2/2]

template<typename T>
Span< T > & batchlas::Span< T >::operator= ( Span< T > && other)
inlineconstexpr

Same as the copy assignment.

Definition at line 92 of file sycl-span.hh.

◆ operator==()

template<typename T>
bool batchlas::Span< T >::operator== ( const Span< T > other) const

Element-wise comparison on the host.

Spans of different sizes compare unequal. Real floating-point elements compare with a relative tolerance of 20 epsilon; every other type, complex included, compares exactly. Two spans over the same pointer are equal without reading the data.

Precondition
the memory is host-readable and no kernel is writing it

◆ operator[]()

template<typename T>
T & batchlas::Span< T >::operator[] ( size_t index) const
inlineconstexpr

Element index.

Precondition
index < size()

Definition at line 102 of file sycl-span.hh.

◆ at()

template<typename T>
T & batchlas::Span< T >::at ( size_t index) const
inlineconstexpr

Element index.

Precondition
index < size() (asserted, not thrown)

Definition at line 104 of file sycl-span.hh.

◆ data()

template<typename T>
T * batchlas::Span< T >::data ( ) const
inlineconstexpr

Pointer to the first element (may be null).

Definition at line 105 of file sycl-span.hh.

◆ size()

template<typename T>
size_t batchlas::Span< T >::size ( ) const
inlineconstexpr

Number of elements.

Definition at line 106 of file sycl-span.hh.

◆ empty()

template<typename T>
bool batchlas::Span< T >::empty ( ) const
inlineconstexpr

True when size() == 0.

Definition at line 107 of file sycl-span.hh.

◆ size_bytes()

template<typename T>
size_t batchlas::Span< T >::size_bytes ( ) const
inlineconstexpr

size() * sizeof(T).

Definition at line 109 of file sycl-span.hh.

◆ begin()

template<typename T>
T * batchlas::Span< T >::begin ( ) const
inlineconstexpr

Iterator to the first element.

Definition at line 110 of file sycl-span.hh.

◆ end()

template<typename T>
T * batchlas::Span< T >::end ( ) const
inlineconstexpr

Iterator one past the last element.

Definition at line 111 of file sycl-span.hh.

◆ front()

template<typename T>
T & batchlas::Span< T >::front ( ) const
inlineconstexpr

First element.

Precondition
!empty()

Definition at line 112 of file sycl-span.hh.

◆ back()

template<typename T>
T & batchlas::Span< T >::back ( ) const
inlineconstexpr

Last element.

Precondition
!empty()

Definition at line 113 of file sycl-span.hh.