Home

KokkosView

KokkosView refers to the core multi-dimensional array type provided by the Kokkos library, typically implemented as Kokkos::View. It serves as a portable, high-level container for data that participates in Kokkos parallel operations and memory management across diverse hardware backends, such as CPUs and GPUs. A Kokkos::View manages the allocation, access, and lifetime of data and is designed to work efficiently within Kokkos execution spaces and memory spaces.

A View is a templated object parameterized by the data type, the rank (dimension) of the array,

Views support deep and shallow copy semantics. Copying a View by default creates another View that references

Core features include element access via operator(), obtaining extents and sizes, and interoperability with Kokkos kernels

a
memory
layout
(for
example,
LayoutLeft
or
LayoutRight),
and
a
memory
space
(for
example,
HostSpace,
CudaSpace,
or
others).
The
rank
is
encoded
in
the
type
via
the
number
of
pointers
in
the
DataType
(for
example,
double*
for
1D,
double**
for
2D,
etc.).
A
typical
instantiation
might
be
Kokkos::View<double**,
Kokkos::LayoutLeft,
Kokkos::HostSpace>
for
a
2D
array
stored
in
host
memory
with
a
specific
layout.
Views
can
be
created
with
or
without
preallocated
memory
and
may
be
configured
as
owning
or
non-owning,
depending
on
how
they
are
constructed.
the
same
underlying
data
(shallow
copy),
while
a
separate
deep_copy
operation
can
copy
data
between
views,
potentially
across
memory
spaces.
Views
also
provide
subviews
to
obtain
smaller
views
of
portions
of
an
existing
array,
enabling
flexible
data
slicing
without
additional
allocations.
such
as
parallel_for
and
parallel_reduce.
Views
enable
portability
by
allowing
code
to
run
with
the
same
syntax
on
different
backends
and
memory
spaces,
making
KokkosView
a
central
building
block
for
performance-portable
numerical
software.