Uni20
Asynchronous tensor and runtime library.
Loading...
Searching...
No Matches
Files | Classes | Macros | Typedefs | Functions
Backend implementation details

Internal macros and helpers that support backend integrations without being part of the public API surface. More...

Collaboration diagram for Backend implementation details:

Files

file  blasproto.hpp
 Templated BLAS interface declarations and wrappers.
 
file  reference_blas_mkl_direct.hpp
 Enables MKL direct-call support for Uni20 reference BLAS wrappers.
 
file  strided_transform.hpp
 CPU executor for compact strided elementwise iteration plans.
 

Classes

struct  uni20::extent_stride< ExtentT, StrideT >
 Represents a single dimension's extent and stride for iteration planning. More...
 
struct  uni20::iteration_offset_range
 Inclusive range of handle-relative offsets visited by an iteration plan. More...
 
struct  uni20::multi_iteration_plan< OperandCount, MaximumRank >
 Compact affine iteration plan shared by host and device backends. More...
 

Macros

#define BLASCHAR   s
 Internal macro specifying the BLAS routine prefix for single-precision instantiations.
 
#define BLASCHAR   d
 Internal macro specifying the BLAS routine prefix for single-precision instantiations.
 
#define BLASCHAR   c
 Internal macro specifying the BLAS routine prefix for single-precision instantiations.
 
#define BLASCHAR   z
 Internal macro specifying the BLAS routine prefix for single-precision instantiations.
 
#define BLASCOMPLEX   0
 Internal flag indicating that the single-precision instantiation is real-valued.
 
#define BLASCOMPLEX   0
 Internal flag indicating that the single-precision instantiation is real-valued.
 
#define BLASCOMPLEX   1
 Internal flag indicating that the single-precision instantiation is real-valued.
 
#define BLASCOMPLEX   1
 Internal flag indicating that the single-precision instantiation is real-valued.
 
#define BLASREALTYPE   float32
 Internal macro naming the real-valued companion type for complex single-precision instantiations.
 
#define BLASREALTYPE   float64
 Internal macro naming the real-valued companion type for complex single-precision instantiations.
 
#define BLASTYPE   float32
 Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.
 
#define BLASTYPE   float64
 Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.
 
#define BLASTYPE   complex64
 Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.
 
#define BLASTYPE   complex128
 Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.
 
#define MKL_DIRECT_CALL
 Marks that MKL direct-call entry points should be used instead of dispatcher stubs.
 
#define MKL_DIRECT_CALL_SEQ
 Ensures the sequential (non-threaded) MKL direct-call path is selected.
 
#define UNI20_INTERNAL_API_CALL_STRINGIZE(func)   UNI20_INTERNAL_STRINGIFY_TOKEN(func)
 Produces the log-friendly spelling of an external backend API symbol.
 
#define UNI20_INTERNAL_BLAS_FN(NAME)   UNI20_INTERNAL_CONCAT(UNI20_INTERNAL_CONCAT(BLASCHAR, NAME), _)
 Builds the mangled Fortran symbol name for the current BLAS instantiation.
 
#define UNI20_INTERNAL_CONCAT(x, y)   UNI20_INTERNAL_CONCAT2(x, y)
 Internal macro that concatenates two tokens after expanding both arguments.
 
#define UNI20_INTERNAL_CONCAT2(x, y)   x##y
 Internal macro that concatenates two tokens without macro expansion on x.
 
#define UNI20_INTERNAL_STRINGIFY_TOKEN(x)   #x
 Converts the supplied token into a string literal without macro expansion.
 

Typedefs

template<typename... Spans>
using uni20::common_extents_t = typename detail::common_extents< Spans... >::type
 Convenience alias that represents the common extents of a set of mdspans.
 
template<typename T , std::size_t N>
using uni20::tuple_n = decltype(detail::make_tuple_n_impl< T >(std::make_index_sequence< N >{}))
 Alias: tuple_n<T,N> is std::tuple<T,T,…> with N repetitions of T.
 

Functions

constexpr bool uni20::extent_stride< ExtentT, StrideT >::can_merge_with_inner (extent_stride inner) const noexcept
 Returns true when two adjacent dimensions can be merged.
 
template<typename T , std::size_t N>
UNI20_HOST_DEVICE constexpr std::array< T, N+1 > uni20::concat (const std::array< T, N > &a, const T &x)
 Append a single element to the end of an array.
 
template<typename T , std::size_t N1, std::size_t N2>
UNI20_HOST_DEVICE constexpr std::array< T, N1+N2 > uni20::concat (const std::array< T, N1 > &a1, const std::array< T, N2 > &a2)
 Concatenate two std::array instances into one (constexpr helper).
 
template<typename T , std::size_t N>
UNI20_HOST_DEVICE constexpr std::array< T, N+1 > uni20::concat (const T &x, const std::array< T, N > &a)
 Prepend a single element in front of an array.
 
template<typename... Spans>
auto uni20::make_common_extents (Spans... spans)
 Build an extents object representing the common shape of the given spans.
 
template<typename Mapping >
auto uni20::make_iteration_plan_with_offset (Mapping const &mapping)
 Construct a merged iteration plan and offset for a single mapping.
 
template<typename... Mappings>
auto uni20::make_multi_iteration_plan (std::tuple< Mappings... > const &mappings)
 Build a merged iteration plan for multiple tensors sharing the same extents.
 
constexpr void uni20::extent_stride< ExtentT, StrideT >::merge_with_inner (extent_stride inner) noexcept
 Merge an inner dimension into this one.
 

Detailed Description

Internal macros and helpers that support backend integrations without being part of the public API surface.

Macro Definition Documentation

◆ BLASCHAR [1/4]

#define BLASCHAR   s

Internal macro specifying the BLAS routine prefix for single-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex double-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex single-precision instantiations.

Internal macro specifying the BLAS routine prefix for double-precision instantiations.

◆ BLASCHAR [2/4]

#define BLASCHAR   d

Internal macro specifying the BLAS routine prefix for single-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex double-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex single-precision instantiations.

Internal macro specifying the BLAS routine prefix for double-precision instantiations.

◆ BLASCHAR [3/4]

#define BLASCHAR   c

Internal macro specifying the BLAS routine prefix for single-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex double-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex single-precision instantiations.

Internal macro specifying the BLAS routine prefix for double-precision instantiations.

◆ BLASCHAR [4/4]

#define BLASCHAR   z

Internal macro specifying the BLAS routine prefix for single-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex double-precision instantiations.

Internal macro specifying the BLAS routine prefix for complex single-precision instantiations.

Internal macro specifying the BLAS routine prefix for double-precision instantiations.

◆ BLASCOMPLEX [1/4]

#define BLASCOMPLEX   0

Internal flag indicating that the single-precision instantiation is real-valued.

Internal flag indicating that the complex double-precision instantiation uses complex arithmetic.

Internal flag indicating that the complex single-precision instantiation uses complex arithmetic.

Internal flag indicating that the double-precision instantiation is real-valued.

◆ BLASCOMPLEX [2/4]

#define BLASCOMPLEX   0

Internal flag indicating that the single-precision instantiation is real-valued.

Internal flag indicating that the complex double-precision instantiation uses complex arithmetic.

Internal flag indicating that the complex single-precision instantiation uses complex arithmetic.

Internal flag indicating that the double-precision instantiation is real-valued.

◆ BLASCOMPLEX [3/4]

#define BLASCOMPLEX   1

Internal flag indicating that the single-precision instantiation is real-valued.

Internal flag indicating that the complex double-precision instantiation uses complex arithmetic.

Internal flag indicating that the complex single-precision instantiation uses complex arithmetic.

Internal flag indicating that the double-precision instantiation is real-valued.

◆ BLASCOMPLEX [4/4]

#define BLASCOMPLEX   1

Internal flag indicating that the single-precision instantiation is real-valued.

Internal flag indicating that the complex double-precision instantiation uses complex arithmetic.

Internal flag indicating that the complex single-precision instantiation uses complex arithmetic.

Internal flag indicating that the double-precision instantiation is real-valued.

◆ BLASREALTYPE [1/2]

#define BLASREALTYPE   float32

Internal macro naming the real-valued companion type for complex single-precision instantiations.

Internal macro naming the real-valued companion type for complex double-precision instantiations.

◆ BLASREALTYPE [2/2]

#define BLASREALTYPE   float64

Internal macro naming the real-valued companion type for complex single-precision instantiations.

Internal macro naming the real-valued companion type for complex double-precision instantiations.

◆ BLASTYPE [1/4]

#define BLASTYPE   float32

Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex double-precision BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex BLAS prefix to the associated Uni20 scalar type.

◆ BLASTYPE [2/4]

#define BLASTYPE   float64

Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex double-precision BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex BLAS prefix to the associated Uni20 scalar type.

◆ BLASTYPE [3/4]

#define BLASTYPE   complex64

Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex double-precision BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex BLAS prefix to the associated Uni20 scalar type.

◆ BLASTYPE [4/4]

#define BLASTYPE   complex128

Internal macro mapping the BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex double-precision BLAS prefix to the associated Uni20 scalar type.

Internal macro mapping the complex BLAS prefix to the associated Uni20 scalar type.

◆ MKL_DIRECT_CALL

#define MKL_DIRECT_CALL

Marks that MKL direct-call entry points should be used instead of dispatcher stubs.

◆ MKL_DIRECT_CALL_SEQ

#define MKL_DIRECT_CALL_SEQ

Ensures the sequential (non-threaded) MKL direct-call path is selected.

◆ UNI20_INTERNAL_API_CALL_STRINGIZE

#define UNI20_INTERNAL_API_CALL_STRINGIZE (   func)    UNI20_INTERNAL_STRINGIFY_TOKEN(func)

Produces the log-friendly spelling of an external backend API symbol.

Parameters
funcMacro argument that names the symbol being traced.
Returns
String literal suitable for concatenating into trace output.

◆ UNI20_INTERNAL_BLAS_FN

#define UNI20_INTERNAL_BLAS_FN (   NAME)    UNI20_INTERNAL_CONCAT(UNI20_INTERNAL_CONCAT(BLASCHAR, NAME), _)

Builds the mangled Fortran symbol name for the current BLAS instantiation.

◆ UNI20_INTERNAL_CONCAT

#define UNI20_INTERNAL_CONCAT (   x,
  y 
)    UNI20_INTERNAL_CONCAT2(x, y)

Internal macro that concatenates two tokens after expanding both arguments.

◆ UNI20_INTERNAL_CONCAT2

#define UNI20_INTERNAL_CONCAT2 (   x,
  y 
)    x##y

Internal macro that concatenates two tokens without macro expansion on x.

◆ UNI20_INTERNAL_STRINGIFY_TOKEN

#define UNI20_INTERNAL_STRINGIFY_TOKEN (   x)    #x

Converts the supplied token into a string literal without macro expansion.

Parameters
xToken to stringify.
Returns
A string literal containing the textual representation of x.

Typedef Documentation

◆ common_extents_t

template<typename... Spans>
using uni20::common_extents_t = typedef typename detail::common_extents<Spans...>::type

Convenience alias that represents the common extents of a set of mdspans.

Template Parameters
SpansMdspan types whose extents are merged.

◆ tuple_n

template<typename T , std::size_t N>
using uni20::tuple_n = typedef decltype(detail::make_tuple_n_impl<T>(std::make_index_sequence<N>{}))

Alias: tuple_n<T,N> is std::tuple<T,T,…> with N repetitions of T.

Template Parameters
TType to repeat.
NNumber of repetitions.

Function Documentation

◆ can_merge_with_inner()

template<typename ExtentT = std::size_t, typename StrideT = std::ptrdiff_t>
constexpr bool uni20::extent_stride< ExtentT, StrideT >::can_merge_with_inner ( extent_stride< ExtentT, StrideT >  inner) const
inlineconstexprnoexcept

Returns true when two adjacent dimensions can be merged.

An extent-one dimension is always mergeable because its stride is not observed by any logical index.

Parameters
innerMetadata describing the inner dimension.

◆ concat() [1/3]

template<typename T , std::size_t N>
UNI20_HOST_DEVICE constexpr std::array< T, N+1 > uni20::concat ( const std::array< T, N > &  a,
const T &  x 
)
constexpr

Append a single element to the end of an array.

Template Parameters
TElement type stored in the arrays.
NLength of the original array.
Parameters
aOriginal array.
xElement appended at the end.
Returns
Array with x appended.

◆ concat() [2/3]

template<typename T , std::size_t N1, std::size_t N2>
UNI20_HOST_DEVICE constexpr std::array< T, N1+N2 > uni20::concat ( const std::array< T, N1 > &  a1,
const std::array< T, N2 > &  a2 
)
constexpr

Concatenate two std::array instances into one (constexpr helper).

Template Parameters
TElement type stored in the arrays.
N1Length of the first array.
N2Length of the second array.
Parameters
a1First array.
a2Second array.
Returns
Array containing the elements of a1 followed by a2.

◆ concat() [3/3]

template<typename T , std::size_t N>
UNI20_HOST_DEVICE constexpr std::array< T, N+1 > uni20::concat ( const T &  x,
const std::array< T, N > &  a 
)
constexpr

Prepend a single element in front of an array.

Template Parameters
TElement type stored in the arrays.
NLength of the original array.
Parameters
xElement inserted at the beginning.
aArray whose contents follow x.
Returns
Array with x prepended.

◆ make_common_extents()

template<typename... Spans>
auto uni20::make_common_extents ( Spans...  spans)

Build an extents object representing the common shape of the given spans.

Template Parameters
SpansMdspan types participating in the merge.
Parameters
spansMdspan instances with compatible extents.
Returns
Extents describing the common shape.

◆ make_iteration_plan_with_offset()

template<typename Mapping >
auto uni20::make_iteration_plan_with_offset ( Mapping const &  mapping)

Construct a merged iteration plan and offset for a single mapping.

Template Parameters
MappingLayout mapping type modelling the mdspan mapping interface.
Parameters
mappingMapping used to compute strides and extents.
Returns
Pair consisting of the merged plan and the starting offset adjustment.

◆ make_multi_iteration_plan()

template<typename... Mappings>
auto uni20::make_multi_iteration_plan ( std::tuple< Mappings... > const &  mappings)

Build a merged iteration plan for multiple tensors sharing the same extents.

The first mapping determines iteration order and negative-stride normalization. Remaining mappings may have different layout and extents types, but must have the same rank and runtime extents.

Template Parameters
MappingsLayout mapping types modelling the mdspan mapping interface.
Parameters
mappingsTuple of mappings, with the writable output mapping first.
Returns
Compact plan with per-operand offsets, ranges, and element count.

◆ merge_with_inner()

template<typename ExtentT = std::size_t, typename StrideT = std::ptrdiff_t>
constexpr void uni20::extent_stride< ExtentT, StrideT >::merge_with_inner ( extent_stride< ExtentT, StrideT >  inner)
inlineconstexprnoexcept

Merge an inner dimension into this one.

The merged descriptor retains the non-singleton dimension's stride. Two singleton dimensions use the canonical unit stride.

Parameters
innerThe dimension that satisfies can_merge_with_inner.