diff --git a/docs/images/mapping.svg b/docs/images/mapping.svg index 2b4fd63b80..e3c5919c6d 100644 --- a/docs/images/mapping.svg +++ b/docs/images/mapping.svg @@ -1,3 +1,3 @@ -
View 3
View 3
View 2
View 2
View 1
View 1
Index space
Index space
Array
Array
Domain
Domain
0
0
1
1
...
...
0
0
1
1
...
...
alpha
alpha
color
color
g
g
r
r
b
b
RecordCoord<0, 0>
RecordCoord<0, 0>
RecordCoord<0, 1>
RecordCoord<0, 1>
RecordCoord<0, 2>
RecordCoord<0, 2>
RecordCoord<1>
RecordCoord<1>
Record dimension
Record dimension
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
0
0
1
1
2
2
3
3
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
0
0
 
 
(0, 1)
(0, 1)
(0, 2)
(0, 2)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
0
0
1
1
(0, 3)
(0, 3)
(0, 4)
(0, 4)
(1, 0)
(1, 0)
(1, 1)
(1, 1)
(1, 2)
(1, 2)
(1, 3)
(1, 3)
(1, 4)
(1, 4)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 2)
(0, 2)
(0, 3)
(0, 3)
(0, 4)
(0, 4)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 2)
(0, 2)
(0, 3)
(0, 3)
(0, 4)
(0, 4)
(0, 2)
(0, 2)
(0, 3)
(0, 3)
(0, 4)
(0, 4)
Mapping
Mapping
blob
blob
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
...
...
...
...
...
...
blob
blob
Mapping
Mapping
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
...
...
(1, 0)
(1, 0)
(1, 1)
(1, 1)
(1, 2)
(1, 2)
(1, 3)
(1, 3)
(1, 4)
(1, 4)
...
...
blob
blob
offset
offset
Mapping
Mapping
view(1, 3)(color, g)
view(1, 3)(color, g)
offset
offset
offset
offset
...
...
...
...
...
...
Viewer does not support full SVG 1.1
\ No newline at end of file +
View 3
View 3
View 2
View 2
View 1
View 1
Index space
Index space
Array
Array
dimensions
dimensions
0
0
1
1
...
...
0
0
1
1
...
...
alpha
alpha
color
color
g
g
r
r
b
b
RecordCoord<0, 0>
RecordCoord<0, 0>
RecordCoord<0, 1>
RecordCoord<0, 1>
RecordCoord<0, 2>
RecordCoord<0, 2>
RecordCoord<1>
RecordCoord<1>
Record dimension
Record dimension
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(1, 0)
(1, 0)
...
...
0
0
1
1
2
2
3
3
(0, 0)
(0, 0)
(0, 1)
(0, 1)
...
...
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
0
0
 
 
(0, 1)
(0, 1)
(0, 2)
(0, 2)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
0
0
1
1
(0, 3)
(0, 3)
(0, 4)
(0, 4)
(1, 0)
(1, 0)
(1, 1)
(1, 1)
(1, 2)
(1, 2)
(1, 3)
(1, 3)
(1, 4)
(1, 4)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 2)
(0, 2)
(0, 3)
(0, 3)
(0, 4)
(0, 4)
(0, 0)
(0, 0)
(0, 1)
(0, 1)
(0, 2)
(0, 2)
(0, 3)
(0, 3)
(0, 4)
(0, 4)
(0, 2)
(0, 2)
(0, 3)
(0, 3)
(0, 4)
(0, 4)
Mapping
Mapping
blob
blob
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
...
...
...
...
...
...
blob
blob
Mapping
Mapping
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
(1, 3)
...
...
(1, 0)
(1, 0)
(1, 1)
(1, 1)
(1, 2)
(1, 2)
(1, 3)
(1, 3)
(1, 4)
(1, 4)
...
...
blob
blob
offset
offset
Mapping
Mapping
view(1, 3)(color, g)
view(1, 3)(color, g)
offset
offset
offset
offset
...
...
...
...
...
...
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/docs/images/overview.svg b/docs/images/overview.svg index fca97bdff4..235810f326 100644 --- a/docs/images/overview.svg +++ b/docs/images/overview.svg @@ -1,3 +1,3 @@ -
non-terminal access
non-terminal access
View<Mapping, Blob>
View<Mapping, Blob>
operator()(Tag...)
operator()(Tag...)
terminal access
terminal access
VirtualRecord<View, ...>
VirtualRecord<View, .....
VirtualView<View>
VirtualView<View>
T&
T&
operator()(Array<N>)
operator()(Array<N>)
1
1
Mapping::blobCount
Mapping::blobCount
AoS
AoS
SoA
SoA
AoSoA
AoSoA
One
One
Split
Split
Blob
Blob

operator[](size_t) -> byte&

operator[](size_t) -> byte&
BlobAllocator
BlobAllocator
operator()(size_t) -> Blob
operator()(size_t) -> Blob
Legend
Legend
LLAMA class
LLAMA class
LLAMA concept
LLAMA concept
C++ std lib/lang
C++ std lib/lang
user provided
user provided
allocView(Mapping, BlobAllocator)
allocView(Mapping, BlobAllocator)
Mapping
Mapping

blobCount -> size_t
blobSize(size_t) -> size_t
blobNrAndOffset() -> NrAndOffset

blobCount -> size_t...
Record dimension
Record dimension
Type
Type
Type
Type
Tag
Tag
Tag
Tag
Field<Tag, Type>
Field<Tag, Type>
Field<Tag, Type>
Field<Tag, Type>
Record<Elements...>
Record<Elements...>
Record<Elements...>
Record<Elements...>
Tag1
Tag1
Tag2
Tag2
Tag3
Tag3
Tag4
Tag4
0
0
1
1
...
...
0
0
1
1
...
...
Array dimensions
Array dimensions
Array<N>
Array<N>
Creates
Creates
Composition
Composition
Aggregation
Aggregation
Implements
Implements
Viewer does not support full SVG 1.1
\ No newline at end of file +
non-terminal access
non-terminal access
View<Mapping, Blob>
View<Mapping, Blob>
operator()(Tag...)
operator()(Tag...)
terminal access
terminal access
VirtualRecord<View, ...>
VirtualRecord<View, .....
VirtualView<View>
VirtualView<View>
T&
T&
operator()(ArrayDims<N>)
operator()(ArrayDims<N>)
1
1
Mapping::blobCount
Mapping::blobCount
AoS
AoS
SoA
SoA
AoSoA
AoSoA
One
One
Split
Split
Blob
Blob

operator[](size_t) -> byte&

operator[](size_t) -> byte&
BlobAllocator
BlobAllocator
operator()(size_t) -> Blob
operator()(size_t) -> Blob
Legend
Legend
LLAMA class
LLAMA class
LLAMA concept
LLAMA concept
C++ std lib/lang
C++ std lib/lang
user provided
user provided
allocView(Mapping, BlobAllocator)
allocView(Mapping, BlobAllocator)
Mapping
Mapping

blobCount -> size_t
blobSize(size_t) -> size_t
blobNrAndOffset() -> NrAndOffset

blobCount -> size_t...
Record dimension
Record dimension
Type
Type
Type
Type
Tag
Tag
Tag
Tag
Field<Tag, Type>
Field<Tag, Type>
Field<Tag, Type>
Field<Tag, Type>
Record<Elements...>
Record<Elements...>
Record<Elements...>
Record<Elements...>
Tag1
Tag1
Tag2
Tag2
Tag3
Tag3
Tag4
Tag4
0
0
1
1
...
...
0
0
1
1
...
...
Array dimensions
Array dimensions
ArrayDims<N>
ArrayDims<N>
Creates
Creates
Composition
Composition
Aggregation
Aggregation
Implements
Implements
Viewer does not support full SVG 1.1
\ No newline at end of file diff --git a/docs/index.rst b/docs/index.rst index 27b092973b..28a3b6c071 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -31,7 +31,7 @@ LLAMA is licensed under the LGPL3+. pages/install pages/introduction - pages/domains + pages/dimensions pages/views pages/virtualrecord pages/iteration diff --git a/docs/pages/api.rst b/docs/pages/api.rst index 1723b34615..6db207ebf9 100644 --- a/docs/pages/api.rst +++ b/docs/pages/api.rst @@ -26,14 +26,14 @@ Useful helpers :members: .. doxygenfunction:: llama::structName -Array domain ------------ +Array dimensions +---------------- -.. doxygenstruct:: llama::ArrayDomain +.. doxygenstruct:: llama::ArrayDims -.. doxygenstruct:: llama::ArrayDomainIndexIterator +.. doxygenstruct:: llama::ArrayDimsIndexIterator :members: -.. doxygenstruct:: llama::ArrayDomainIndexRange +.. doxygenstruct:: llama::ArrayDimsIndexRange :members: Record dimension @@ -112,11 +112,11 @@ Mappings Common utilities ^^^^^^^^^^^^^^^^ -.. doxygenstruct:: llama::mapping::LinearizeArrayDomainCpp +.. doxygenstruct:: llama::mapping::LinearizeArrayDimsCpp :members: -.. doxygenstruct:: llama::mapping::LinearizeArrayDomainFortran +.. doxygenstruct:: llama::mapping::LinearizeArrayDimsFortran :members: -.. doxygenstruct:: llama::mapping::LinearizeArrayDomainMorton +.. doxygenstruct:: llama::mapping::LinearizeArrayDimsMorton :members: Tree mapping diff --git a/docs/pages/blobs.rst b/docs/pages/blobs.rst index 16c41a6773..8fb46f5f61 100644 --- a/docs/pages/blobs.rst +++ b/docs/pages/blobs.rst @@ -62,8 +62,8 @@ Creating a small view of :math:`4 \times 4` may look like this: .. code-block:: C++ - using ArrayDomain = llama::ArrayDomain<2>; - constexpr ArrayDomain miniSize{4, 4}; + using ArrayDims = llama::ArrayDims<2>; + constexpr ArrayDims miniSize{4, 4}; using Mapping = /* some simple mapping */; using BlobAllocator = llama::bloballoc::Stack< diff --git a/docs/pages/domains.rst b/docs/pages/dimensions.rst similarity index 85% rename from docs/pages/domains.rst rename to docs/pages/dimensions.rst index 40ef30c72d..3ebaad5aa0 100644 --- a/docs/pages/domains.rst +++ b/docs/pages/dimensions.rst @@ -1,37 +1,36 @@ .. include:: common.rst -.. _label-domains: +.. _label-dimensions: Dimensions ========== -As mentioned in the section before, LLAMA distinguishes between the array domain and the record dimension. -The most important difference is that the array domain is defined at *run time* whereas the record dimension is defined at *compile time*. +As mentioned in the section before, LLAMA distinguishes between the array and the record dimensions. +The most important difference is that the array dimensions are defined at *run time* whereas the record dimension is defined at *compile time*. This allows to make the problem size itself a run time value but leaves the compiler room to optimize the data access. .. _label-ad: -Array domain ------------- +Array dimensions +---------------- -The array domain is an :math:`N`-dimensional array with :math:`N` itself being a +The array dimensions are an :math:`N`-dimensional array with :math:`N` itself being a compile time value but with run time values inside. LLAMA brings its own :ref:`array class ` for such kind of data structs which is ready for interoperability with hardware accelerator C++ dialects such as CUDA (Nvidia) or HIP (AMD), or abstraction libraries such as the already mentioned alpaka. -A definition of a three-dimensional array domain of the size -:math:`128 \times 256 \times 32` looks like this: +A definition of three array dimensions of the size :math:`128 \times 256 \times 32` looks like this: .. code-block:: C++ - llama::ArrayDomain arrayDomainSize{128, 256, 32}; + llama::ArrayDims arrayDimsSize{128, 256, 32}; The template arguments are deduced by the compiler using `CTAD `_. -The full type of :cpp:`arrayDomainSize` is :cpp:`llama::ArrayDomain<3>`. +The full type of :cpp:`arrayDimsSize` is :cpp:`llama::ArrayDims<3>`. -.. _label-dd: +.. _label-rd: Record dimension ---------------- diff --git a/docs/pages/introduction.rst b/docs/pages/introduction.rst index 93f902929c..1c8d4107aa 100644 --- a/docs/pages/introduction.rst +++ b/docs/pages/introduction.rst @@ -100,7 +100,7 @@ The core data structure of LLAMA is the :ref:`View `, which holds the memory for the data and provides methods to access the data space. In order to create a view, a `Mapping` is needed which is an abstract concept. LLAMA offers many kinds of mappings and users can also provide their own mappings. -Mappings are constructed from a :ref:`record dimension `, containing tags, and an :ref:`Array domain `. +Mappings are constructed from a :ref:`record dimension `, containing tags, and :ref:`array dimensions `. In addition to a mapping defining the memory layout, an array of :ref:`Blobs ` is needed for a view, supplying the actual storage behind the view. A blob is any object representing a contiguous chunk of memory, byte-wise addressable using :cpp:`operator[]`. A suitable Blob array is either directly provided by the user or built using a :ref:`BlobAllocator ` when a view is created by a call to `allocView`. @@ -108,8 +108,8 @@ A blob allocator is again an abstract concept and any object returning a blob of LLAMA comes with a set of predefined blob allocators and users can again provider their own. Once a view is created, the user can navigate on the data managed by the view. -On top of a view, a :ref:`VirtualView ` can be created, offering access to a subrange of the array domain. -Elements of the array domain, called records, are accessed on both, View and VirtualView, by calling :cpp:`operator()` with an instance of the array domain. +On top of a view, a :ref:`VirtualView ` can be created, offering access to a subspace of the array dimensions. +Elements of the array dimensions, called records, are accessed on both, View and VirtualView, by calling :cpp:`operator()` with an array dimensions coordinate as instance of :cpp:`ArrayDims`. This access returns a :ref:`VirtualRecord `, allowing further access using the tags from the record dimension, until eventually a reference to actual data in memory is returned. diff --git a/docs/pages/iteration.rst b/docs/pages/iteration.rst index b9b8293bc4..64542f507d 100644 --- a/docs/pages/iteration.rst +++ b/docs/pages/iteration.rst @@ -5,18 +5,18 @@ Iteration ========= -Array domain iterating ----------------------- +Array dimensions iteration +-------------------------- -The array domain spans an N-dimensional space of integral indices. +The array dimensions span an N-dimensional space of integral indices. Sometimes we just want to quickly iterate over all coordinates in this index space. -This is what :cpp:`llama::ArrayDomainRange` is for, which is a range in the C++ sense and +This is what :cpp:`llama::ArrayDimsIndexRange` is for, which is a range in the C++ sense and offers the :cpp:`begin()` and :cpp:`end()` member functions with corresponding iterators to support STL algorithms or the range-for loop. .. code-block:: C++ - llama::ArrayDomain<2> ad{3, 3}; - llama::ArrayDomainIndexRange range{ad}; + llama::ArrayDims<2> ad{3, 3}; + llama::ArrayDimsIndexRange range{ad}; std::for_each(range.begin(), range.end(), [](auto coord) { // coord is {0, 0}, {0, 1}, {0, 2}, {1, 0}, {1, 1}, {1, 2}, {2, 0}, {2, 1}, {2, 2} @@ -27,7 +27,7 @@ offers the :cpp:`begin()` and :cpp:`end()` member functions with corresponding } -Record dimension iterating +Record dimension iteration -------------------------- The record dimension is iterated using :cpp:`llama::forEachLeaf`. @@ -114,7 +114,7 @@ Having an iterator to a view opens up the standard library for use in conjunctio .. code-block:: C++ - using ArrayDomain = llama::ArrayDomain<1>; + using ArrayDims = llama::ArrayDims<1>; // ... auto view = llama::allocView(mapping); @@ -136,8 +136,8 @@ Since virtual records interact with each other based on the tags and not the und .. code-block:: C++ - auto aosView = llama::allocView(llama::mapping::AoS{arrayDomain}); - auto soaView = llama::allocView(llama::mapping::SoA{arrayDomain}); + auto aosView = llama::allocView(llama::mapping::AoS{arrayDimsSize}); + auto soaView = llama::allocView(llama::mapping::SoA{arrayDimsSize}); // ... std::copy(begin(aosView), end(aosView), begin(soaView)); diff --git a/docs/pages/mappings.rst b/docs/pages/mappings.rst index a137dc488f..adeb50ffbc 100644 --- a/docs/pages/mappings.rst +++ b/docs/pages/mappings.rst @@ -5,8 +5,8 @@ Mappings ======== -One of the core tasks of LLAMA is to map an address from the array domain and -record dimension to some address in the allocated memory space. +One of the core tasks of LLAMA is to map an address from the array and +record dimensions to some address in the allocated memory space. This is particularly challenging if the compiler shall still be able to optimize the resulting memory accesses (vectorization, reordering, aligned loads, etc.). The compiler needs to **understand** the semantic of the mapping at compile time. @@ -26,19 +26,19 @@ The view requires each mapping to fulfill the following concept: template concept Mapping = requires(M m) { - typename M::ArrayDomain; + typename M::ArrayDims; typename M::RecordDim; { M::blobCount } -> std::convertible_to; llama::Array{}; // validates constexpr-ness { m.blobSize(std::size_t{}) } -> std::same_as; - { m.blobNrAndOffset(typename M::ArrayDomain{}) } -> std::same_as; + { m.blobNrAndOffset(typename M::ArrayDims{}) } -> std::same_as; }; -That is, each mapping type needs to expose the types :cpp:`M::ArrayDomain` and :cpp:`M::RecordDim`. +That is, each mapping type needs to expose the types :cpp:`M::ArrayDims` and :cpp:`M::RecordDim`. Furthermore, each mapping needs to provide a static constexpr member variable :cpp:`blobCount` and two member functions. :cpp:`blobSize(i)` gives the size in bytes of the :cpp:`i`\ th block of memory needed for this mapping. :cpp:`i` is in the range of :cpp:`0` to :cpp:`blobCount - 1`. -:cpp:`blobNrAndOffset(ad)` implements the core mapping logic by translating a array domain coordinate :cpp:`ad` into a value of :cpp:`llama::NrAndOffset`, containing the blob number of offset within the blob where the value should be stored. +:cpp:`blobNrAndOffset(ad)` implements the core mapping logic by translating an array coordinate :cpp:`ad` into a value of :cpp:`llama::NrAndOffset`, containing the blob number of offset within the blob where the value should be stored. AoS mappings ------------ @@ -49,12 +49,12 @@ However, they do not vectorize well in practice. .. code-block:: C++ - llama::mapping::AoS mapping{arrayDomainSize}; - llama::mapping::AoS mapping{arrayDomainSize}; // respect alignment - llama::mapping::AoS mapping{arrayDomainSize}; // respect alignment, column major + llama::mapping::AoS mapping{arrayDimsSize}; + llama::mapping::AoS mapping{arrayDimsSize}; // respect alignment + llama::mapping::AoS mapping{arrayDimsSize}; // respect alignment, column major -By default, the :cpp:`ArrayDomain` is linearized using :cpp:`llama::mapping::LinearizeArrayDomainCpp` and the layout is tightly packed. +By default, the :cpp:`ArrayDims` is linearized using :cpp:`llama::mapping::LinearizeArrayDimsCpp` and the layout is tightly packed. LLAMA provides the aliases :cpp:`llama::mapping::AlignedAoS` and :cpp:`llama::mapping::PackedAoS` for convenience. @@ -63,7 +63,7 @@ but, since the mapping code is more complicated, compilers currently fail to aut .. code-block:: C++ - llama::mapping::AoSoA mapping{arrayDomainSize}; + llama::mapping::AoSoA mapping{arrayDimsSize}; .. _label-tree-mapping: @@ -77,12 +77,12 @@ This layout auto vectorizes well in practice. .. code-block:: C++ - llama::mapping::SoA mapping{arrayDomainSize}; - llama::mapping::SoA mapping{arrayDomainSize}; // separate blob for each attribute - llama::mapping::SoA mapping{arrayDomainSize}; // separate blob for each attribute, column major + llama::mapping::SoA mapping{arrayDimsSize}; + llama::mapping::SoA mapping{arrayDimsSize}; // separate blob for each attribute + llama::mapping::SoA mapping{arrayDimsSize}; // separate blob for each attribute, column major -By default, the :cpp:`ArrayDomain` is linearized using :cpp:`llama::mapping::LinearizeArrayDomainCpp` and the layout is mapped into a single blob. +By default, the :cpp:`ArrayDims` is linearized using :cpp:`llama::mapping::LinearizeArrayDimsCpp` and the layout is mapped into a single blob. LLAMA provides the aliases :cpp:`llama::mapping::SingleBlobSoA` and :cpp:`llama::mapping::MultiBlobSoA` for convenience. @@ -96,25 +96,25 @@ The AoSoA mapping has a mandatory additional parameter specifying the number of .. code-block:: C++ - llama::mapping::AoSoA mapping{arrayDomainSize}; // inner array has 8 values - llama::mapping::AoSoA mapping{arrayDomainSize}; // inner array has 8 values, column major + llama::mapping::AoSoA mapping{arrayDimsSize}; // inner array has 8 values + llama::mapping::AoSoA mapping{arrayDimsSize}; // inner array has 8 values, column major -By default, the :cpp:`ArrayDomain` is linearized using :cpp:`llama::mapping::LinearizeArrayDomainCpp`. +By default, the :cpp:`ArrayDims` is linearized using :cpp:`llama::mapping::LinearizeArrayDimsCpp`. LLAMA also provides a helper :cpp:`llama::mapping::maxLanes` which can be used to determine the maximum vector lanes which can be used for a given record dimension and vector register size. In this example, the inner array a size of N so even the largest type in the record dimension can fit N times into a vector register of 256bits size (e.g. AVX2). .. code-block:: C++ - llama::mapping::AoSoA> mapping{arrayDomainSize}; + llama::mapping::AoSoA> mapping{arrayDimsSize}; One mapping ----------- -The One mapping is intended to map all coordinates in the array domain onto the same memory location. +The One mapping is intended to map all coordinates in the array dimensions onto the same memory location. This is commonly used in the `llama::One` virtual record, but also offers interesting applications in conjunction with the `llama::mapping::Split` mapping. @@ -129,9 +129,9 @@ The remaining record dimension is mapped using a second mapping. .. code-block:: C++ - llama::mapping::Split, llama::mapping::SoA, llama::mapping::PackedAoS> - mapping{arrayDomainSize}; // maps the subtree at index 1 as SoA, the rest as packed AoS + mapping{arrayDimsSize}; // maps the subtree at index 1 as SoA, the rest as packed AoS Split mappings can be nested to map a record dimension into even fancier combinations. @@ -145,7 +145,7 @@ WARNING: The tree mapping is currently not maintained and we consider deprecatio The LLAMA tree mapping is one approach to archieve the goal of mixing different mapping approaches. Furthermore, it tries to establish a general mapping description language and mapping definition framework. -Let's take the example record dimension from the :ref:`domain section`: +Let's take the example record dimension from the :ref:`dimensions section`: .. image:: ../images/layout_tree.svg @@ -155,9 +155,9 @@ representing the repetition of branches and to define tree operations which create new trees out of the old ones while providing methods to translate tree coordinates from one tree to another. -This is best demonstrated by an example. First of all the array domain needs to be -represented as such an tree too. Let's assume a array domain of -:math:`128 \times 64`: +This is best demonstrated by an example. +First of all the array dimensions needs to be represented as such an tree too. +Let's assume array dimensions of :math:`128 \times 64`: .. image:: ../images/ud_tree_2.svg @@ -166,8 +166,8 @@ The record dimension is already a tree, but as it has no run time influence, onl .. image:: ../images/layout_tree_2.svg -Now the two trees are connected so that we can represent array domain and record -dimension with one tree: +Now the two trees are connected so that we can represent array and record +dimensions with one tree: .. image:: ../images/start_tree_2.svg @@ -189,7 +189,7 @@ Struct of array but with a padding after each 1024 elements may look like this: The size of the leaf type in "pad" of course needs to be determined based on the desired aligment and sub tree sizes. -Such a tree (with smaller array domain for easier drawing) … +Such a tree (with smaller array dimensions for easier drawing) … .. image:: ../images/example_tree.svg @@ -208,19 +208,19 @@ a further constructor parameter for the instantiation of this tuple. }; using Mapping = llama::mapping::tree::Mapping< - ArrayDomain, + ArrayDims, RecordDim, decltype(treeOperationList) >; Mapping mapping( - arrayDomainSize, + arrayDimsSize, treeOperationList ); // or using CTAD and an unused argument for the record dimension: llama::mapping::tree::Mapping mapping( - arrayDomainSize, + arrayDimsSize, llama::Tuple{ llama::mapping::tree::functor::LeafOnlyRT() }, diff --git a/docs/pages/views.rst b/docs/pages/views.rst index 85776d1458..32a52d1515 100644 --- a/docs/pages/views.rst +++ b/docs/pages/views.rst @@ -5,11 +5,9 @@ View ==== -The view is the main data structure a LLAMA user will work with. It takes -coordinates in the array domain and record dimension and returns a reference to a record -in memory which can be read from or written to. For easier use, some -useful operations such as :cpp:`+=` are overloaded to operate on all record -fields inside the record dimension at once. +The view is the main data structure a LLAMA user will work with. +It takes coordinates in the array and record dimensions and returns a reference to a record in memory which can be read from or written to. +For easier use, some useful operations such as :cpp:`+=` are overloaded to operate on all record fields inside the record dimension at once. .. _label-factory: @@ -22,7 +20,7 @@ A view is allocated using the helper function :cpp:`allocView`, which takes a .. code-block:: C++ using Mapping = ...; // see next section about mappings - Mapping mapping(arrayDomainSize); // see section about domains + Mapping mapping(arrayDimsSize); // see section about dimensions auto view = allocView(mapping); // optional blob allocator as 2nd argument The :ref:`mapping ` and :ref:`blob allocator ` @@ -36,24 +34,24 @@ Data access LLAMA tries to have an array of struct like interface. When accessing an element of the view, the array part comes first, followed by tags from the record dimension. -In C++, runtime values like the array domain coordinate are normal function parameters +In C++, runtime values like the array dimensions coordinates are normal function parameters whereas compile time values such as the record dimension tags are usually given as template arguments. However, compile time information can be stored in a type, instantiated as a value and then passed to a function template deducing the type again. This trick allows to pass both, runtime and compile time values as function arguments. E.g. instead of calling :cpp:`f()` we can call :cpp:`f(MyType{})` and let the compiler deduce the template argument of :cpp:`f`. This trick is used in LLAMA to specify the access to a value of a view. -An example access with the domains defined in the :ref:`domain section ` could look like this: +An example access with the dimensions defined in the :ref:`dimensions section ` could look like this: .. code-block:: C++ view(1, 2, 3)(color{}, g{}) = 1.0; -It is also possible to access the array domain with one compound argument like this: +It is also possible to access the array dimensions with one compound argument like this: .. code-block:: C++ - const ArrayDomain pos{1, 2, 3}; + const ArrayDims pos{1, 2, 3}; view(pos)(color{}, g{}) = 1.0; // or view({1, 2, 3})(color{}, g{}) = 1.0; @@ -82,7 +80,7 @@ This object is a central data type of LLAMA called :cpp:`llama::VirtualRecord`. VirtualView ----------- -Virtual views can be created on top of existing views, offering shifted access to a subrange of the array domain. +Virtual views can be created on top of existing views, offering shifted access to a subspace of the array dimensions. .. code-block:: C++ diff --git a/docs/pages/virtualrecord.rst b/docs/pages/virtualrecord.rst index 460cf85f5d..f220a03343 100644 --- a/docs/pages/virtualrecord.rst +++ b/docs/pages/virtualrecord.rst @@ -28,8 +28,8 @@ This object is a :cpp:`llama::VirtualRecord`. float& g = vdColor(g{}); g = 1.0; -Supplying the array domain coordinates to a view access returns such a :cpp:`llama::VirtualRecord`, storing this array domain coordiante. -This object can be thought of like a record in the :math:`N`-dimensional array domain space, +Supplying the array dimensions coordinate to a view access returns such a :cpp:`llama::VirtualRecord`, storing this array dimensions coordiante. +This object can be thought of like a record in the :math:`N`-dimensional array dimensions space, but as the fields of this record may not be contiguous in memory, it is not a real object in the C++ sense and thus called virtual. Accessing subparts of a :cpp:`llama::VirtualRecord` is done using `operator()` and the tag types from the record dimension. diff --git a/examples/alpaka/asyncblur/asyncblur.cpp b/examples/alpaka/asyncblur/asyncblur.cpp index d8193bc3d2..bd2aea0f72 100644 --- a/examples/alpaka/asyncblur/asyncblur.cpp +++ b/examples/alpaka/asyncblur/asyncblur.cpp @@ -86,7 +86,7 @@ struct BlurKernel // Using SoA for the shared memory constexpr auto sharedChunkSize = ElemsPerBlock + 2 * KernelSize; const auto sharedMapping = llama::mapping::SoA( - typename View::ArrayDomain{sharedChunkSize, sharedChunkSize}, + typename View::ArrayDims{sharedChunkSize, sharedChunkSize}, typename View::RecordDim{}); constexpr auto sharedMemSize = llama::sizeOf * sharedChunkSize * sharedChunkSize; auto& sharedMem = alpaka::declareSharedVar(acc); @@ -105,8 +105,8 @@ struct BlurKernel const std::size_t bStart[2] = {bi[0] * ElemsPerBlock + threadIdxInBlock[0], bi[1] * ElemsPerBlock + threadIdxInBlock[1]}; const std::size_t bEnd[2] = { - alpaka::math::min(acc, bStart[0] + ElemsPerBlock + 2 * KernelSize, oldImage.mapping.arrayDomainSize[0]), - alpaka::math::min(acc, bStart[1] + ElemsPerBlock + 2 * KernelSize, oldImage.mapping.arrayDomainSize[1]), + alpaka::math::min(acc, bStart[0] + ElemsPerBlock + 2 * KernelSize, oldImage.mapping.arrayDimsSize[0]), + alpaka::math::min(acc, bStart[1] + ElemsPerBlock + 2 * KernelSize, oldImage.mapping.arrayDimsSize[1]), }; LLAMA_INDEPENDENT_DATA for (auto y = bStart[0]; y < bEnd[0]; y += threadsPerBlock) @@ -119,8 +119,8 @@ struct BlurKernel const std::size_t start[2] = {ti[0] * Elems, ti[1] * Elems}; const std::size_t end[2] = { - alpaka::math::min(acc, start[0] + Elems, oldImage.mapping.arrayDomainSize[0] - 2 * KernelSize), - alpaka::math::min(acc, start[1] + Elems, oldImage.mapping.arrayDomainSize[1] - 2 * KernelSize), + alpaka::math::min(acc, start[0] + Elems, oldImage.mapping.arrayDimsSize[0] - 2 * KernelSize), + alpaka::math::min(acc, start[1] + Elems, oldImage.mapping.arrayDimsSize[1] - 2 * KernelSize), }; LLAMA_INDEPENDENT_DATA @@ -208,12 +208,12 @@ try } // LLAMA - using ArrayDomain = llama::ArrayDomain<2>; + using ArrayDims = llama::ArrayDims<2>; auto treeOperationList = llama::Tuple{llama::mapping::tree::functor::LeafOnlyRT()}; - const auto hostMapping = llama::mapping::tree::Mapping{ArrayDomain{buffer_y, buffer_x}, treeOperationList, Pixel{}}; + const auto hostMapping = llama::mapping::tree::Mapping{ArrayDims{buffer_y, buffer_x}, treeOperationList, Pixel{}}; const auto devMapping = llama::mapping::tree::Mapping{ - ArrayDomain{CHUNK_SIZE + 2 * KERNEL_SIZE, CHUNK_SIZE + 2 * KERNEL_SIZE}, + ArrayDims{CHUNK_SIZE + 2 * KERNEL_SIZE, CHUNK_SIZE + 2 * KERNEL_SIZE}, treeOperationList, PixelOnAcc{}}; @@ -298,14 +298,14 @@ try struct VirtualHostElement { llama::VirtualView virtualHost; - const ArrayDomain validMiniSize; + const ArrayDims validMiniSize; }; std::list virtualHostList; for (std::size_t chunk_y = 0; chunk_y < chunks[0]; ++chunk_y) for (std::size_t chunk_x = 0; chunk_x < chunks[1]; ++chunk_x) { // Create virtual view with size of mini view - const ArrayDomain validMiniSize{ + const ArrayDims validMiniSize{ ((chunk_y < chunks[0] - 1) ? CHUNK_SIZE : (img_y - 1) % CHUNK_SIZE + 1) + 2 * KERNEL_SIZE, ((chunk_x < chunks[1] - 1) ? CHUNK_SIZE : (img_x - 1) % CHUNK_SIZE + 1) + 2 * KERNEL_SIZE}; llama::VirtualView virtualHost(hostView, {chunk_y * CHUNK_SIZE, chunk_x * CHUNK_SIZE}, validMiniSize); diff --git a/examples/alpaka/nbody/nbody.cpp b/examples/alpaka/nbody/nbody.cpp index effb89b6e1..a578372243 100644 --- a/examples/alpaka/nbody/nbody.cpp +++ b/examples/alpaka/nbody/nbody.cpp @@ -153,18 +153,18 @@ struct UpdateKernel { // if there is only 1 thread per block, use stack instead of shared memory if constexpr (BlockSize == 1) - return llama::allocViewStack(); + return llama::allocViewStack(); else { constexpr auto sharedMapping = [] { - constexpr auto arrayDomain = llama::ArrayDomain{BlockSize}; + constexpr auto arrayDims = llama::ArrayDims{BlockSize}; if constexpr (MappingSM == AoS) - return llama::mapping::AoS{arrayDomain, Particle{}}; + return llama::mapping::AoS{arrayDims, Particle{}}; if constexpr (MappingSM == SoA) - return llama::mapping::SoA{arrayDomain, Particle{}}; + return llama::mapping::SoA{arrayDims, Particle{}}; if constexpr (MappingSM == AoSoA) - return llama::mapping::AoSoA{arrayDomain}; + return llama::mapping::AoSoA{arrayDims}; }(); static_assert(decltype(sharedMapping)::blobCount == 1); @@ -180,9 +180,9 @@ struct UpdateKernel // TODO: we could optimize here, because only velocity is ever updated auto pi = [&] { - constexpr auto arrayDomain = llama::ArrayDomain{Elems}; + constexpr auto arrayDims = llama::ArrayDims{Elems}; constexpr auto mapping - = llama::mapping::SoA{arrayDomain}; + = llama::mapping::SoA{arrayDims}; constexpr auto blobAlloc = llama::bloballoc::Stack * Elems>{}; return llama::allocView(mapping, blobAlloc); }(); @@ -264,15 +264,15 @@ void run(std::ostream& plotFile) auto mapping = [] { - const auto arrayDomain = llama::ArrayDomain{PROBLEM_SIZE}; + const auto arrayDims = llama::ArrayDims{PROBLEM_SIZE}; if constexpr (MappingGM == AoS) - return llama::mapping::AoS{arrayDomain, Particle{}}; + return llama::mapping::AoS{arrayDims, Particle{}}; if constexpr (MappingGM == SoA) - return llama::mapping::SoA{arrayDomain, Particle{}}; + return llama::mapping::SoA{arrayDims, Particle{}}; // if constexpr (MappingGM == 2) - // return llama::mapping::SoA{arrayDomain}; + // return llama::mapping::SoA{arrayDims}; if constexpr (MappingGM == AoSoA) - return llama::mapping::AoSoA{arrayDomain}; + return llama::mapping::AoSoA{arrayDims}; }(); Stopwatch watch; diff --git a/examples/alpaka/vectoradd/vectoradd.cpp b/examples/alpaka/vectoradd/vectoradd.cpp index 8239f38695..276f110840 100644 --- a/examples/alpaka/vectoradd/vectoradd.cpp +++ b/examples/alpaka/vectoradd/vectoradd.cpp @@ -80,21 +80,21 @@ try Queue queue(devAcc); // LLAMA - const auto arrayDomain = llama::ArrayDomain{PROBLEM_SIZE}; + const auto arrayDims = llama::ArrayDims{PROBLEM_SIZE}; const auto mapping = [&] { if constexpr (MAPPING == 0) - return llama::mapping::AoS{arrayDomain, Vector{}}; + return llama::mapping::AoS{arrayDims, Vector{}}; if constexpr (MAPPING == 1) - return llama::mapping::SoA{arrayDomain, Vector{}}; + return llama::mapping::SoA{arrayDims, Vector{}}; if constexpr (MAPPING == 2) - return llama::mapping::SoA{arrayDomain}; + return llama::mapping::SoA{arrayDims}; if constexpr (MAPPING == 3) - return llama::mapping::tree::Mapping{arrayDomain, llama::Tuple{}, Vector{}}; + return llama::mapping::tree::Mapping{arrayDims, llama::Tuple{}, Vector{}}; if constexpr (MAPPING == 4) return llama::mapping::tree::Mapping{ - arrayDomain, + arrayDims, llama::Tuple{llama::mapping::tree::functor::LeafOnlyRT()}, Vector{}}; }(); diff --git a/examples/bufferguard/bufferguard.cpp b/examples/bufferguard/bufferguard.cpp index 9c8b91fa9c..a4f3281f16 100644 --- a/examples/bufferguard/bufferguard.cpp +++ b/examples/bufferguard/bufferguard.cpp @@ -21,18 +21,18 @@ using Vector = llama::Record< >; // clang-format on -template