Skip to content

ncarray

Name Description
host A simple allocator for STL containers which upholds alignment specifications.
device
Name Description
ArrayImpl The ArrayImpl provides the mean entry point for all array types. It is a templated class inheriting from Layout and Storage classes, allowing it to be customized to different kinds of array setups. E.g. suboffsets and NCArray style classes are both accessed via the ArrayImpl.
index_error
Stencil A Stencil for defining expressions over an array with determined offsets.
type_error
AllTraits Traits to find minima along axes.
AnyTraits Traits to find minima along axes.
ArgmaxTraits Traits to find the indices of maxima along axes.
ArgminTraits Traits to find the indices of minima along axes.
ArrayElementProxy The element proxy can be returned by arrays during indexing to provide reference based access to the underlying data.
AxisDescr A description of an axis of an array. This struct can be used for creation of new views.
BaseOpTraits Numeric traits for specifying types during arithmetic as well as providing operations for types that don’t have them, or overriding their default behaviour.
concat A struct for concatenating type_lists together.
concat< List >
concat< type_list< Ts... >, type_list< Us... >, Rest... >
DevDeleter
DevOwnerPolicy
DevRefPolicy
DevTag
DevViewPolicy
Double2 A 2-double (double precision) vector data type.
Double3 A 3-double (double precision) vector data type.
Double4 A 4-double (double precision) vector data type.
dtype_traits A small struct that maps a type to the DType enumerator via the value member.
DynamicExprMVNode
Ellipsis An empty struct indicating skipped axes when indexing an array.
ExpressionTag
ExprMVNode A multi-view array expression builder.
ExprOpInterface
FixedMetadata For simplifying CPU/GPU compatibility, STL containers are replaced with a fixed struct for expressing metadata surrounding arrays. E.g. shape and strides information. Currently, ncarray supports up to 10 dimensions in an array.
Float2 A 2-float (single precision) vector data type.
Float3 A 3-float (single precision) vector data type.
Float4 A 4-float (single precision) vector data type.
HostDeleter
HostEngine The HostEngine is ultimately responsible for dispatching all operations involving arrays on the host/CPU. This includes binary operations, reductions, unary operations, copies, assignments, fills and so on.
HostTag
IndexItem A generic indexing argument with a tag indicating the type to be used.
is_exprmv_node
is_exprmv_node< ExprMVNode< MemTag > >
is_in_list Struct for testing presence of a type in a type_list.
is_in_list< T, type_list< Ts... > >
is_layout_policy Type-trait style struct for the IsLayoutPolicy concept default falsey specialization.
is_layout_policy< LayoutPolicy< D > > Type-trait style struct for the IsLayoutPolicy concept true specialization.
is_ncoffsets_policy Type-trait style struct for whether NCOffsetsPolicy default false specialization.
is_ncoffsets_policy< NCOffsetsPolicy > Type-trait style struct for whether NCOffsetsPolicy true specialization.
is_soarray_policy Type-trait style struct for whether SOArrayPolicy default false specialization.
is_soarray_policy< SOArrayPolicy > Type-trait style struct for whether SOArrayPolicy true specialization.
KeyValPair A small struct for holding a key and value.
LayoutPolicy The LayoutPolicy dictates the overall organization of an array object. E.g. if it has offsets or suboffsets.
list_dispatcher A dispatch engine for matching a DType to the underlying type and running a function.
list_dispatcher< type_list< T, Ts... > >
list_dispatcher< type_list<> >
MaxTraits Traits to find maxima along axes.
MeanTraits
MemTag
MinTraits Traits to find minima along axes.
NCOffsetsPolicy The NCOffsetsPolicy provides an additional offsets attribute and allows for a single pointer axis.
op_traits
op_traits< bool >
op_traits< Double2 >
op_traits< Double3 >
op_traits< Double4 >
op_traits< Float2 >
op_traits< Float3 >
op_traits< Float4 >
complex< T > >
int16_t >
int8_t >
uint16_t >
uint8_t >
OwnerPolicy The OwnerPolicy dictates an array that manages its own buffer for the memory that backs the array.
OwnerTag
Reducer A wrapping class for reduction traits.
ReductionParams A struct to define mapping requirements when performing axis-aware reductions.
RefPolicy The RefPolicy dictates arrays which hold pointers to the individual components of the array.
RefTag
Slice A struct representing a slice for indexing by a step between a start and stop index.
SOArrayPolicy The SOArrayPolicy implements PEP3118 compliance with the addition of a suboffsets field.
StaticCoords A small struct with compile-time constant size for indexing arrays.
StaticExprMVNode
StdTraits Traits to find the standard deviation along axes.
StoragePolicy The StoragePolicy specifies the storage class for the array in question. E.g., a view type array holds no memory, while an owning type does.
StoragePolicyTraits
StoragePolicyTraits< DevTag >
StoragePolicyTraits< HostTag >
SumTraits Traits for a summation along axes.
type_list Basic type list.
VarAccumulator An accumulator used for the calculation of variance and standard deviation.
VarTraits Traits to find the variance along axes.
ViewPolicy The ViewPolicy dictates arrays that have only a view of the data.
ViewTag
wrap_list A helper struct to wrap a templated class.
wrap_list< Wrapper, type_list< Ts... > >
Name Description
DType The main identifier for the ncarray type system. The DType determines array element type.
IndexType A tag identifier for the type of indexing argument when constructing lists of args.
OpCode OpCodes indicate types of operations or expressions.

enum DType

Defined in src/lib/ncarray/dtype.hh:56

The main identifier for the ncarray type system. The DType determines array element type.

Value Description
bool_ Boolean type.
char_ char type (signed 8-bit)
uint8 8-bit unsigned integer
uint16 16-bit unsigned integer
uint32 32-bit unsigned integer
uint64 64-bit unsigned integer
int8 8-bit signed integer
int16 16-bit signed integer
int32 32-bit signed integer
int64 64-bit signed integer
float32 single precision float
float64 double precision float
float128 equivalent to long double
complex64 complex
complex128 complex
complex256 complex
vfloat2 2-float vector type (Float2)
vfloat3 3-float vector type (Float3)
vfloat4 4-float vector type (Float4)
vdouble2 2-double vector type (Double2)
vdouble3 3-double vector tyep (Double3)
vdouble4 4-double vector type (Double4)

enum IndexType

Defined in src/lib/ncarray/indexing.hh:86

A tag identifier for the type of indexing argument when constructing lists of args.

Value Description
Integer
Slice
Ellipsis

enum OpCode

Defined in src/lib/ncarray/op_code.hh:47

OpCodes indicate types of operations or expressions.

When interfacing with Python these are used for the virtual machine. In normal C++ usage, they are used by the various BinaryExpr/UnaryExpr and so on.

All supported operations (add, subtract, etc.) are included here, in addition to the necessary codes to indicate loading/retrieval of the operands (arrays, or constant scalars)

Value Description
NOOP Null op.
IDX Index generator (Like APL)
LOAD_NCARR Load an NCArray (VM only)
LOAD_SOARR Load an SOArray (VM only)
LOAD_CONST Load a constant (VM only)
NEG Negative.
INC Increment.
DEC Decrement.
SZOF Size of.
ADDR Address of.
INDR Indirection/dereference.
CAST Cast.
LNOT Logical not.
BNOT Bitwise not.
ADD Addition.
SUB Subtraction.
MUL Multiplication.
DIV True division.
MOD Modulo.
FDIV Floor (integer) division.
EQ Equal to.
NE Not equal.
LT Less than.
LE Less than or equal.
GT Greater than.
GE Greater than or equal.
LAND Logical and.
LOR Logical or.
BAND Bitwise and (&)
BOR Bitwise or (
XOR Bitwise XOR (^)
LSHFT Left shift (<<)
RSHFT Right shift (>>)
Return Name Description
ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::View > NCViewFor
ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Ref > NCRefFor
ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Owner > NCOwnerFor
ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::View > SOViewFor
ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Ref > SORefFor
ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Owner > SOOwnerFor
std::variant< bool, char, hd_std::uint8_t, hd_std::uint16_t, hd_std::uint32_t, hd_std::uint64_t, hd_std::int8_t, hd_std::int16_t, hd_std::int32_t, hd_std::int64_t, float, double, long double, hd_std::complex< float >, hd_std::complex< double >, hd_std::complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 > Scalar The set of scalar types used by ncarray - one for each DType.
type_list< bool, char, hd_std::uint8_t, hd_std::uint16_t, hd_std::uint32_t, hd_std::uint64_t, hd_std::int8_t, hd_std::int16_t, hd_std::int32_t, hd_std::int64_t, float, double, long double, hd_std::complex< float >, hd_std::complex< double >, hd_std::complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 > base_types All supported base datatypes in ncarray.
typename concat< Lists… >::type concat_t The full type of a set of type_lists concatenated with concat.
typename wrap_list< VarAccumulator, base_types >::type accumulator_types
KeyValPair< ssize_t, T > IndexedKVP The KeyValPair type used for reductions in ncarray.
typename wrap_list< IndexedKVP, base_types >::type keyval_types
type_list< long, unsigned long, long long, unsigned long long > device_int_compat_types Provide supporting types for the ArrayElementProxy restricted conversion operators.
concat_t< base_types, accumulator_types, keyval_types, device_int_compat_types > all_supported_types The set of all types in ncarray, including accumulators and the base dtypes.
FixedMetadata< ssize_t > Metadata By default, Metadata will use ssize_t which is compatible with the conventions used in many places for a signed integer to describe shapes, strides, suboffsets and so on.
ArrayImpl< NCOffsetsPolicy, ViewPolicy > NCArrayView
ArrayImpl< NCOffsetsPolicy, RefPolicy > NCArrayRef
ArrayImpl< NCOffsetsPolicy, OwnerPolicy > NCArray
hd_std::uint32_t Instruction Instructions for the virutal machine are stored in a packed format in 32 bit ints.
ArrayImpl< SOArrayPolicy, ViewPolicy > SOArrayView
ArrayImpl< SOArrayPolicy, RefPolicy > SOArrayRef
ArrayImpl< SOArrayPolicy, OwnerPolicy > SOArray

using NCViewFor = ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::View >

Type: ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::View >

Defined in src/lib/ncarray/array_impl.hh:2063


using NCRefFor = ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Ref >

Type: ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Ref >

Defined in src/lib/ncarray/array_impl.hh:2066


using NCOwnerFor = ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Owner >

Type: ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemType >::Owner >

Defined in src/lib/ncarray/array_impl.hh:2069


using SOViewFor = ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::View >

Type: ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::View >

Defined in src/lib/ncarray/array_impl.hh:2072


using SORefFor = ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Ref >

Type: ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Ref >

Defined in src/lib/ncarray/array_impl.hh:2075


using SOOwnerFor = ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Owner >

Type: ArrayImpl< SOArrayPolicy, typename StoragePolicyTraits< MemType >::Owner >

Defined in src/lib/ncarray/array_impl.hh:2078


using Scalar = std::variant< bool, char, hd_std::uint8_t, hd_std::uint16_t, hd_std::uint32_t, hd_std::uint64_t, hd_std::int8_t, hd_std::int16_t, hd_std::int32_t, hd_std::int64_t, float, double, long double, hd_std::complex< float >, hd_std::complex< double >, hd_std::complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 >

Type: std::variant< bool, char, hd_std::uint8_t, hd_std::uint16_t, hd_std::uint32_t, hd_std::uint64_t, hd_std::int8_t, hd_std::int16_t, hd_std::int32_t, hd_std::int64_t, float, double, long double, hd_std::complex< float >, hd_std::complex< double >, hd_std::complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 >

Defined in src/lib/ncarray/dtype.hh:265

The set of scalar types used by ncarray - one for each DType.


using base_types = type_list< bool, char, hd_std::uint8_t, hd_std::uint16_t, hd_std::uint32_t, hd_std::uint64_t, hd_std::int8_t, hd_std::int16_t, hd_std::int32_t, hd_std::int64_t, float, double, long double, hd_std::complex< float >, hd_std::complex< double >, hd_std::complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 >

Type: type_list< bool, char, hd_std::uint8_t, hd_std::uint16_t, hd_std::uint32_t, hd_std::uint64_t, hd_std::int8_t, hd_std::int16_t, hd_std::int32_t, hd_std::int64_t, float, double, long double, hd_std::complex< float >, hd_std::complex< double >, hd_std::complex< long double >, Float2, Float3, Float4, Double2, Double3, Double4 >

Defined in src/lib/ncarray/dtype.hh:367

All supported base datatypes in ncarray.

This includes basic C++ types, complex numbers and vector types.


using concat_t = typename concat< Lists... >::type

Type: typename concat< Lists… >::type

Defined in src/lib/ncarray/dtype.hh:398

The full type of a set of type_lists concatenated with concat.


using accumulator_types = typename wrap_list< VarAccumulator, base_types >::type

Type: typename wrap_list< VarAccumulator, base_types >::type

Defined in src/lib/ncarray/dtype.hh:414


using IndexedKVP = KeyValPair< ssize_t, T >

Type: KeyValPair< ssize_t, T >

Defined in src/lib/ncarray/dtype.hh:420

The KeyValPair type used for reductions in ncarray.


using keyval_types = typename wrap_list< IndexedKVP, base_types >::type

Type: typename wrap_list< IndexedKVP, base_types >::type

Defined in src/lib/ncarray/dtype.hh:422


using device_int_compat_types = type_list< long, unsigned long, long long, unsigned long long >

Type: type_list< long, unsigned long, long long, unsigned long long >

Defined in src/lib/ncarray/dtype.hh:431

Provide supporting types for the ArrayElementProxy restricted conversion operators.

Due to differences in definitions of fixed-width ints on host and device (std, vs cuda::std), the ArrayElementProxy concept on the operator T& may delete needed operators inside kernels. This type_list adds back the requisite types.


using all_supported_types = concat_t< base_types, accumulator_types, keyval_types, device_int_compat_types >

Type: concat_t< base_types, accumulator_types, keyval_types, device_int_compat_types >

Defined in src/lib/ncarray/dtype.hh:437

The set of all types in ncarray, including accumulators and the base dtypes.


using Metadata = FixedMetadata< ssize_t >

Type: FixedMetadata< ssize_t >

Defined in src/lib/ncarray/layout.hh:100

By default, Metadata will use ssize_t which is compatible with the conventions used in many places for a signed integer to describe shapes, strides, suboffsets and so on.


using NCArrayView = ArrayImpl< NCOffsetsPolicy, ViewPolicy >

Type: ArrayImpl< NCOffsetsPolicy, ViewPolicy >

Defined in src/lib/ncarray/ncarrays.hh:16


using NCArrayRef = ArrayImpl< NCOffsetsPolicy, RefPolicy >

Type: ArrayImpl< NCOffsetsPolicy, RefPolicy >

Defined in src/lib/ncarray/ncarrays.hh:17


using NCArray = ArrayImpl< NCOffsetsPolicy, OwnerPolicy >

Type: ArrayImpl< NCOffsetsPolicy, OwnerPolicy >

Defined in src/lib/ncarray/ncarrays.hh:18


using Instruction = hd_std::uint32_t

Defined in src/lib/ncarray/op_code.hh:169

Instructions for the virutal machine are stored in a packed format in 32 bit ints.

The op code (e.g. ADD, LOAD_ARRAY etc) is stored in the lower 8 bits. The index of the operand in the VM’s stack is in the remaining bits.


using SOArrayView = ArrayImpl< SOArrayPolicy, ViewPolicy >

Type: ArrayImpl< SOArrayPolicy, ViewPolicy >

Defined in src/lib/ncarray/soarrays.hh:16


using SOArrayRef = ArrayImpl< SOArrayPolicy, RefPolicy >

Type: ArrayImpl< SOArrayPolicy, RefPolicy >

Defined in src/lib/ncarray/soarrays.hh:17


using SOArray = ArrayImpl< SOArrayPolicy, OwnerPolicy >

Type: ArrayImpl< SOArrayPolicy, OwnerPolicy >

Defined in src/lib/ncarray/soarrays.hh:18

Return Name Description
std::vector< ssize_t > calculate_c_order_strides inline Calculate the strides for a standard C-order (row-major) contiguous array of given shape.
std::vector< ssize_t > calculate_c_order_strides inline Calculate the strides for a standard C-order (row-major) contiguous array of given shape.
NCA_HD void calculate_c_order_strides inline Calculate the strides for a standard C-order (row-major) contiguous array of given shape.
auto promote_to_so Convert an NCOffsets array to an SOArray.
NCA_HDArrayElementProxy static_index inline Given a linearized index and array, construct a StaticCoords object to index.
ReductionParams build_reduction_params inline Setup a small struct with strides, offsets and masks for reducing axes.
std::ostream & operator<< A formatting helper for printing vector datatypes.
NCA_HD T nca_sqrt inline A helper for setting up square roots on various types.
NCA_HD size_t itemsize inline Returns the size in bytes of the provided DType.
std::string to_string inline Returns the string representation of the DType for printing.
Scalar to_scalar Convert a pointer to an array element to a Scalar.
NCA_HD auto dispatch_integers inline A restricted dispatcher for integer types. This is useful when using arrays to hold indices for other arrays.
NCA_HD auto dispatch inline Dispatch a visitor/lambda based on DType.
size_t bytes_for_dynamic_vm inline
DynamicExprMVNode< MemTag > get_dynamic_mv_node inline
DType promote_expr_types inline The enum DTypes are already ordered. For expressions’ working dtype, promote to the numerically larger. The final value is determined using op_traits.
bool can_linearize
std::string hash_to_hex
std::string get_arch_opt
fs::path get_cache_dir Get the cache directory for the system.
std::string get_install_library_path Return the path to the currently loaded JIT shared library.
std::string get_install_include_path Return the path to the include headers for ncarray relative to the shared library.
std::string read_file Read a file at the provided path. The entire contents are returned in a string.
void * read_bin_file_to_exec_mem Read a binary file at the provided path into executable memory.
void write_file Write a file to the provided path.
void write_file Write a binary object to the provided path.
NCA_HDDType determine_dtype_for_op inline For a specific operation and input datatype determine the correct result dtype.
NCA_HD hd_std::uint32_t pack_instruction inline Pack an op code and an operand index into a single VM instruction.
NCA_HDOpCode get_op inline From a packed instruction retrieve the op code.
NCA_HD int get_index inline From a packed instruction retrieve the operand stack index.
str get_pkg_config
None nca_pkg_config
str get_include
str get_lib_dir
lazy_mode Context manager to delay immediate evaluation of results.

inline

inline std::vector< ssize_t > calculate_c_order_strides(const std::vector< ssize_t > & shape, const ssize_t itemsize)

Defined in src/lib/ncarray/array_impl.hh:84

Calculate the strides for a standard C-order (row-major) contiguous array of given shape.

The C-order calculated strides.

Parameter Type Description
shape const std::vector< ssize_t > & The shape to calculate strides for.
itemsize const ssize_t The size in bytes of a single element of the array.

inline

inline std::vector< ssize_t > calculate_c_order_strides(const ssize_t ndim, const ssize_t * shape, const ssize_t itemsize)

Defined in src/lib/ncarray/array_impl.hh:104

Calculate the strides for a standard C-order (row-major) contiguous array of given shape.

The C-order calculated strides.

Parameter Type Description
shape const ssize_t * The shape to calculate strides for (pointer to first element).
itemsize const ssize_t The size in bytes of a single element of the array.

inline

inline NCA_HD void calculate_c_order_strides(const ssize_t ndim, const ssize_t * shape, const ssize_t itemsize, ssize_t * new_strides)

Defined in src/lib/ncarray/array_impl.hh:124

Calculate the strides for a standard C-order (row-major) contiguous array of given shape.

Parameter Type Description
shape const ssize_t * The shape to calculate strides for (pointer to first element).
itemsize const ssize_t The size in bytes of a single element of the array.

template<typename MemTag> auto promote_to_so(const ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemTag >::View > & nc)

Defined in src/lib/ncarray/array_impl.hh:2018

Convert an NCOffsets array to an SOArray.

For convenience the function will consume all offsets in the NCOffsetsArray. All suboffsets should then be -1 or 0.

The SOArray* equivalent to the input nc array.

Parameter Type Description
nc const ArrayImpl< NCOffsetsPolicy, typename StoragePolicyTraits< MemTag >::View > & The NCArray* to be converted to SOArray*.

inline

template<class Array> inline NCA_HDArrayElementProxy static_index(Array arr, unsigned idx)

Defined in src/lib/ncarray/array_impl.hh:2102

Given a linearized index and array, construct a StaticCoords object to index.

Because the StaticCoords object has a constexpr size, using it for indexing as opposed to linearized indices can have major performance benefits, particularly for device code applications. E.g., the constexpr size generally allows loops to be fully unrolled, and stack spilling to be avoided in compiled kernels.

This routine simply converts the linearized ravel index to a StaticCoords object of the correct dimensionality of the array, using a switch dispatch.

The ArrayElementProxy to the requested data element.

Parameter Type Description
arr Array The input array.
idx unsigned The linearized ravel index.

inline

inline ReductionParams build_reduction_params(const std::vector< ssize_t > & axes, ssize_t arr_ndim, const ssize_t * in_shape, const ssize_t * in_strides, ssize_t(&) new_shape, ssize_t & new_ndim, ssize_t itemsize, double ddof = 0.0)

Defined in src/lib/ncarray/custom_types.hh:132

Setup a small struct with strides, offsets and masks for reducing axes.

params The reduction parameter table.

Parameter Type Description
axes const std::vector< ssize_t > & The user-requested axes that willbe reduced.
arr_ndim ssize_t The number of dimensions (axes) in the array currently.
in_shape const ssize_t * The shape of the axes in the array.
in_strides const ssize_t * The strides of the axes in the array in ELEMENTS (not bytes).
new_shape ssize_t(&) The new shape for the array following reduction.
new_ndim ssize_t & The number of dimensions after reduction.
itemsize ssize_t The size in bytes of the array elements data type.
ddof double The delta degrees of freedom – only passed through to var/std reductions.

template<Vector2DType T> std::ostream & operator<<(std::ostream & oss, const T & vec)

Defined in src/lib/ncarray/custom_types.hh:826

A formatting helper for printing vector datatypes.

Parameter Type Description
oss std::ostream & The stream to write the contents to.
vec const T & The vector data type to print to the stream.

inline

template<typename T> inline NCA_HD T nca_sqrt(const T & val)

Defined in src/lib/ncarray/custom_types.hh:851

A helper for setting up square roots on various types.

The square root overload for handling the elementwise square-root of vector types.

Parameter Type Description
val const T & The vector value to take the elementwise square root of.

inline

inline NCA_HD size_t itemsize(DType type)

Defined in src/lib/ncarray/dtype.hh:141

Returns the size in bytes of the provided DType.

Todo: Formally enforce these guarantees. This should be correct in all currently supported use cases – but its not guaranteed. The fixed sizes listed here need to be handled (via whatever types required) in the event they are not satisfied in a particular case/on a particular platform.

The size in bytes.

Parameter Type Description
type DType The input DType.

inline

inline std::string to_string(DType type)

Defined in src/lib/ncarray/dtype.hh:209

Returns the string representation of the DType for printing.

The string representation of the data type.

Parameter Type Description
type DType The input DType.

template<typename T> Scalar to_scalar(const void * ptr)

Defined in src/lib/ncarray/dtype.hh:286

Convert a pointer to an array element to a Scalar.

The Scalar wrapper.

Parameter Type Description
ptr const void * The pointer to the array element.

inline

template<typename Visitor> inline NCA_HD auto dispatch_integers(DType type, Visitor && visitor)

Defined in src/lib/ncarray/dtype.hh:296

A restricted dispatcher for integer types. This is useful when using arrays to hold indices for other arrays.


inline

template<typename Visitor> inline NCA_HD auto dispatch(DType type, Visitor && visitor)

Defined in src/lib/ncarray/dtype.hh:498

Dispatch a visitor/lambda based on DType.

This function dispatches only on the base_types (this controls combinatorial explosion to some degree). In certain places, broader dispatching may be desired. In that case, using list_dispatcher directly with specialized type lists can be done instead.

Whatever is returned by the visitor.

Parameter Type Description
type DType The DType to use for dispatching.
visitor Visitor && The lambda visitor.

inline

template<typename MemTag> inline size_t bytes_for_dynamic_vm(const ExprMVNode< MemTag > & node, size_t alignment = 16)

Defined in src/lib/ncarray/expression/dynamicmvnode.hh:257


inline

template<typename MemTag> inline DynamicExprMVNode< MemTag > get_dynamic_mv_node(const ExprMVNode< MemTag > & node, hd_std::uint8_t * h_ptr, hd_std::uint8_t * d_ptr = nullptr, size_t alignment = 16)

Defined in src/lib/ncarray/expression/dynamicmvnode.hh:277


inline

inline DType promote_expr_types(DType a, DType b)

Defined in src/lib/ncarray/expression/interface.hh:91

The enum DTypes are already ordered. For expressions’ working dtype, promote to the numerically larger. The final value is determined using op_traits.


template<class MemTag> bool can_linearize(const ExprMVNode< MemTag > & node)

Defined in src/lib/ncarray/expression/staticmvnode.hh:189


std::string hash_to_hex(const std::string & input)

Defined in src/lib/ncarray/jit/jit_utils.cc:20


std::string get_arch_opt()

Defined in src/lib/ncarray/jit/jit_utils.cc:28


fs::path get_cache_dir()

Defined in src/lib/ncarray/jit/path_utils.cc:31

Get the cache directory for the system.

Uses XDG_CACHE_HOME on Linux if set, or LOCALPPDATA on Windows.


std::string get_install_library_path()

Defined in src/lib/ncarray/jit/path_utils.cc:54

Return the path to the currently loaded JIT shared library.


std::string get_install_include_path()

Defined in src/lib/ncarray/jit/path_utils.cc:84

Return the path to the include headers for ncarray relative to the shared library.


std::string read_file(fs::path file_path)

Defined in src/lib/ncarray/jit/path_utils.cc:118

Read a file at the provided path. The entire contents are returned in a string.

contents The file contents as a string. Empty if there was an error.

Parameter Type Description
file_path fs::path The path to read.

void * read_bin_file_to_exec_mem(fs::path file_path)

Defined in src/lib/ncarray/jit/path_utils.cc:131

Read a binary file at the provided path into executable memory.

contents The data loaded into executable memory.

Parameter Type Description
file_path fs::path The path to read.

void write_file(fs::path file_path, const std::string & contents)

Defined in src/lib/ncarray/jit/path_utils.cc:152

Write a file to the provided path.

Parameter Type Description
file_path fs::path The path to write to.
contents const std::string & The file contents to write out.

void write_file(fs::path file_path, std::size_t k_size, const std::uint8_t * k_data)

Defined in src/lib/ncarray/jit/path_utils.cc:164

Write a binary object to the provided path.

Parameter Type Description
file_path fs::path The path to write to.
k_size std::size_t Number of bytes to write.
k_data const std::uint8_t * Pointer to the start of the data to write.

inline

inline NCA_HDDType determine_dtype_for_op(OpCode code, DType left)

Defined in src/lib/ncarray/op_code.hh:101

For a specific operation and input datatype determine the correct result dtype.

op_traits define certain semantics for type promotion or conversion depending on the operation being performed. E.g. to avoid frequent overflows very small integers (uint8, uint16) will be promoted to larger ones. The output datatype for an ADD operation for uint8 will then be uint64 (int8 -> int64).

Parameter Type Description
code OpCode The op code for this operation.
left DType The datatype of the leftmost operand.

inline

inline NCA_HD hd_std::uint32_t pack_instruction(OpCode op, int idx)

Defined in src/lib/ncarray/op_code.hh:174

Pack an op code and an operand index into a single VM instruction.


inline

inline NCA_HDOpCode get_op(Instruction instr)

Defined in src/lib/ncarray/op_code.hh:183

From a packed instruction retrieve the op code.


inline

inline NCA_HD int get_index(Instruction instr)

Defined in src/lib/ncarray/op_code.hh:190

From a packed instruction retrieve the operand stack index.


str get_pkg_config()

Defined in src/ncarray/init.py:15


None nca_pkg_config()

Defined in src/ncarray/init.py:51


str get_include()

Defined in src/ncarray/init.py:98


str get_lib_dir()

Defined in src/ncarray/init.py:113


lazy_mode()

Defined in src/ncarray/init.py:195

Context manager to delay immediate evaluation of results.

Return Name Description
constexpr bool is_in_type_list_v constexpr Whether a requested type is in the specified type_list.
constexpr bool is_exprmv_node_v constexpr
constexpr bool is_layout_policy_v constexpr Underlying trait to check for layout policy descendence.
constexpr bool is_ncoffsets_policy_v constexpr Underlying trait to check for if NCOffsetsPolicy.
constexpr bool is_soarray_policy_v constexpr Underlying trait to check for if SOArrayPolicy.
str lib_dir
str core_dir
bool has_driver
str stub_path
mode

constexpr

constexpr bool is_in_type_list_v = is_in_list<T, List>::value

Defined in src/lib/ncarray/dtype.hh:342

Whether a requested type is in the specified type_list.


constexpr

constexpr bool is_exprmv_node_v = is_exprmv_node<Expr>::value

Defined in src/lib/ncarray/expression/mvnode.hh:468


constexpr

constexpr bool is_layout_policy_v = is_layout_policy<L>::value

Defined in src/lib/ncarray/layout.hh:874

Underlying trait to check for layout policy descendence.


constexpr

constexpr bool is_ncoffsets_policy_v = is_ncoffsets_policy<L>::value

Defined in src/lib/ncarray/layout.hh:904

Underlying trait to check for if NCOffsetsPolicy.


constexpr

constexpr bool is_soarray_policy_v = is_soarray_policy<L>::value

Defined in src/lib/ncarray/layout.hh:910

Underlying trait to check for if SOArrayPolicy.


str lib_dir = get_lib_dir()

Defined in src/ncarray/init.py:163


str core_dir = os.path.join(os.path.dirname(__file__), "core")

Defined in src/ncarray/init.py:170


bool has_driver = ctypes.util.find_library("cuda") is not None

Defined in src/ncarray/init.py:175


str stub_path = os.path.join(
os.path.dirname(__file__), "core", "stubs", "libcuda.so"
)

Defined in src/ncarray/init.py:177


mode

Defined in src/ncarray/init.py:182