@@ -197,6 +197,9 @@ Multi-component values can be stored:
197197 +-----------++-----------++---------++-----------+------+-----------++-----------++---------++-----------+
198198 ~~~~
199199
200+ Non interleaved storage allows coalescent memory accesses, which may be
201+ beneficial on some architectures, including GPUs.
202+
200203In a element-major pattern, values usually are stored as follows:
201204
202205~~~~
@@ -274,3 +277,39 @@ The `FunctionView` class has two template parameters:
274277The ` FunctionView ` class matches the ` FunctionEvaluator ` concept (See
275278Section @sec :mgis:function: overview and [ this page] ( evaluators.html ) for
276279details).
280+
281+ ## Tensorial functions
282+
283+ ### The ` TensorView ` class
284+
285+ The ` TensorView ` class allows to make views which returns tensorial
286+ objects from functions returning data in contiguous memory.
287+
288+ A ` TensorView ` is generally created by combining a ` FunctionView ` which
289+ a modifier such as ` as_stensor ` (See [ this page] ( evaluators.html ) for
290+ details).
291+
292+ ### The ` CoalescedMemoryAccessTensorView ` class
293+
294+ Coalescent memory access refers to an access pattern where each
295+ components of a function is accessed through its dedicated memory
296+ location (see the non-interleaved storage pattern described previously).
297+
298+ The ` CoalescedMemoryAccessTensorView ` class allows to make a tensorial
299+ function view from scalar function view on each components, as follows:
300+
301+ ~~~~ {.cxx}
302+ real values[8] = {1, 10, // components XX
303+ 2, 20, // components YY
304+ 3, 30, // components ZZ
305+ 4, 40}; // components XY
306+ const auto ne = size_type { 2 };
307+ auto space = BasicLinearSpace{ne};
308+ auto c_xx = ScalarFunctionView{space, std::span{values, ne}};
309+ auto c_yy = ScalarFunctionView{space, std::span{values + ne, ne}};
310+ auto c_zz = ScalarFunctionView{space, std::span{values + 2 * ne, ne}};
311+ auto c_xy = ScalarFunctionView{space, std::span{values + 3 * ne, ne}};
312+ auto f = CoalescedMemoryAccessTensorView<BasicLinearSpace,
313+ tfel::math::stensor<2, real>>{
314+ std::array{c_xx, c_yy, c_zz, c_xy}};
315+ ~~~~
0 commit comments