Skip to content

Commit b402051

Browse files
committed
documentation
1 parent 6f45b59 commit b402051

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

docs/containers.rst

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,40 @@
11
Containers
22
==========
33

4-
Hydra framework provides one dimensional STL-like vector containers for each supported back-end, aliasing the underlying Thrust types. Beyond this, Hydra implements two native multidimensional containers: ``hydra::multivector`` and ``hydra::multiarray`` .
5-
In these containers, the data corresponding to each dimension is stored in contiguous memory regions and when the container is traversed, each entry is accessed as
6-
a ``hydra::tuple``, where each field holds a value corresponding to a dimension. Both classes implement an interface completely compliant with a STL vector and
7-
also provides constant and non-constant accessors for the single dimensional data. The container
8-
``hydra::multivector`` is suitable to store data-sets where the dimensions are represented by entries with different POD types. ``hydra::multiarray`` is designed to store data-sets where all dimensions are represented by fields with the same type. Data is always copyable across different back-ends and movable between containers on the same back-end.
9-
10-
4+
Hydra framework provides an one-dimensional STL-like vector container for each supported back-end, aliasing the underlying Thrust types. The framework also implements two native multidimensional containers called hydra::multivector`` and ``hydra::multiarray`` .
5+
6+
In these containers, the data corresponding to each dimension is stored in contiguous memory addresses that can be traversed in a CPU/GPU cache friendly way, independently of the other dimensions. In the case of multidimensional containers, when the data is traversed each entry is accessed as
7+
a ``hydra::tuple`` object, where each field holds a value corresponding to a dimension.
8+
119
One-dimensional containers
1210
--------------------------
1311

14-
Hydra's one-dimensional containers are aliases to the corresponding [Thrust]_ vectors and defined for each supported back-end. They are:
12+
Hydra's one-dimensional containers are aliases to the corresponding [Thrust]_ vectors and are defined for each supported back-end. They are:
1513

16-
1. ``hydra::device::vector`` : storage allocated in the device back-end defined at compile time using the macro ``THRUST_DEVICE_SYSTEM``
17-
2. ``hydra::host::vector`` : storage allocated in the device back-end defined at compile time using the macro ``THRUST_HOST_SYSTEM``
14+
1. ``hydra::device::vector`` : storage allocated in the device back-end defined at compile time using the macro ``HYDRA_DEVICE_SYSTEM``
15+
2. ``hydra::host::vector`` : storage allocated in the device back-end defined at compile time using the macro ``HYDRA_HOST_SYSTEM``
1816
3. ``hydra::omp::vector`` : storage allocated in the [OpenMP]_ back-end. Usually the CPU memory space.
1917
4. ``hydra::tbb::vector`` : storage allocated in the [TBB]_ back-end. Usually the CPU memory space.
2018
5. ``hydra::cuda::vector`` : storage allocated in the [CUDA]_ back-end. The GPU memory space.
2119
6. ``hydra::cpp::vector`` : storage allocated in the [CPP]_ back-end. Usually the CPU memory
2220

23-
The usage of these containers is extensively documented in the [Thrust]_ library.
21+
The usage of these containers is extensively documented in STL and [Thrust]_ library. Hydra also implements range-semantics for many of these containers.
2422

2523
Multi-dimensional containers
2624
----------------------------
2725

2826
Hydra implements two multidimensional containers:``hydra::multivector`` and ``hydra::multiarray``.
2927
These containers store data using [SoA]_ layout and provides a STL-vector compliant interface.
3028

31-
The best way to understand how these containers operates is to visualize them as a table, there each row corresponds to a entry and each column to a dimension. The design of ``hydra::multivector`` and ``hydra::multiarray`` makes possible to iterate over the container to access a complete row
32-
or to iterate over one or more columns to access only the data of interest in a given entry, without to load the entire row.
29+
Both classes provides constant and non-constant accessors for the single dimensional data. The container
30+
``hydra::multivector`` is suitable to store data-sets where the dimensions are represented by entries with different POD types. ``hydra::multiarray`` is designed to store data-sets where all dimensions are represented by fields of the same type. Data is always copyable across different back-ends and movable between containers on the same back-end.
31+
32+
The best way to understand how these containers operate is to visualize them as a table, there each row corresponds to a entry and each column to a dimension. The design of ``hydra::multivector`` and ``hydra::multiarray`` makes possible to iterate over the container to access a complete row
33+
or to iterate over one or more columns to access only the data of interest in a given entry, without loading the entire row.
3334

34-
When the user iterates over the whole container, each entry (row) is returned as a ``hydra::tuple``. If the user iterates over one single column, the entries have the type of the column. If two or more columns are accessed, entry's data is returned as again as ``hydra::tuple`` containing only the elements of interest. Hydra's multi-dimensional containers can hold any type of data per dimension, but there is not real gain using these containers for describing dimensions with non-POD data.
35+
When the user iterates over the whole container, each entry (row) is returned as a ``hydra::tuple``. If the user iterates over one single column, the entries have the type of the column. If two or more columns are accessed, entry's data is returned as again as ``hydra::tuple`` containing only the elements of interest. Hydra's multi-dimensional containers can hold any type of data per dimension, but there is not real gain using these containers for describing dimensions with non-POD or non alignable data.
3536

36-
Both containers can store the state of arbitrary objects and perform type conversions on-the-fly, using suitable overloaded iterators and ``push_back()`` methods.
37+
These containers can store the state of arbitrary objects and perform type conversions on-the-fly, using suitable overloaded iterators and ``push_back()`` methods.
3738

3839

3940
``hydra::multivector``
@@ -70,7 +71,7 @@ this will print in stdout something like it :
7071
...
7172
(9, 18, 9.0, 18.0)
7273
73-
To access the columns the user needs to deploy ``hydra::placeholders``: _0, _1, _2,...,_99;
74+
To access the columns the user needs ``hydra::placeholders``: _0, _1, _2,..., _99;
7475

7576
.. code-block:: cpp
7677
:name: multivector-example2
@@ -90,7 +91,8 @@ To access the columns the user needs to deploy ``hydra::placeholders``: _0, _1,
9091
}
9192
9293
for(auto x = mvector.begin(_1, _3);
93-
x != mvector.end(_1, _3); x++ )
94+
x != mvector.end(_1, _3); ++x )
95+
9496
std::cout << *x << std::endl;
9597
9698
now in stdout the user will get:
@@ -120,13 +122,13 @@ It is not necessary to access each field stored in each entry to perform a conve
120122
mvector.push_back(hydra::make_tuple( i, 2*i, i, 2*i));
121123
}
122124
123-
auto caster = [] __host__ device__ (hydra::tuple<int, int, double, double>& entry )
125+
auto caster = [] __host__ device__ ( hydra::tuple<int, int, double, double>& entry )
124126
{
125127
126-
hydra::complex<int> c_int(hydra::get<0>(entry), hydra::get<1>(entry));
127-
hydra::complex<double> c_double(hydra::get<2>(entry), hydra::get<2>(entry));
128+
hydra::complex<int> cint(hydra::get<0>(entry), hydra::get<1>(entry));
129+
hydra::complex<double> cdouble(hydra::get<2>(entry), hydra::get<2>(entry));
128130
129-
return hydra::make_pair( c_int, c_double );
131+
return hydra::make_pair( cint, cdouble );
130132
};
131133
132134
for(auto x = mvector.begin(caster); x != mvector.end(caster); x++ )
@@ -142,9 +144,11 @@ stdout will look like:
142144
...
143145
((9, 18), (9.0, 18.0))
144146
147+
Same effect can be
148+
145149

146150
``hydra::multiarray``
147-
......................
151+
.................
148152

149153

150154
``hydra::multiarray`` templates are instantiated passing the type and the number of dimensions via and the back-end where memory will be allocated. The snippet

0 commit comments

Comments
 (0)