Arcane  4.1.12.0
User documentation
Loading...
Searching...
No Matches
ItemFunctor.cc
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2026 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
4// See the top-level COPYRIGHT file for details.
5// SPDX-License-Identifier: Apache-2.0
6//-----------------------------------------------------------------------------
7/*---------------------------------------------------------------------------*/
8/* ItemFunctor.cc (C) 2000-2025 */
9/* */
10/* Functor over entities. */
11/*---------------------------------------------------------------------------*/
12/*---------------------------------------------------------------------------*/
13
14#include "arcane/core/ItemFunctor.h"
15#include "arcane/utils/Math.h"
16
17/*---------------------------------------------------------------------------*/
18/*---------------------------------------------------------------------------*/
19
20namespace Arcane
21{
22
23/*---------------------------------------------------------------------------*/
24/*---------------------------------------------------------------------------*/
25
26AbstractItemRangeFunctor::
27AbstractItemRangeFunctor(ItemVectorView items_view, Integer grain_size)
28: m_items(items_view)
29, m_block_size(SIMD_PADDING_SIZE)
30, m_nb_block(items_view.size())
31, m_block_grain_size(grain_size)
32{
33 // NOTE: if the range functor is used for vectorization, it must
34 // that items_view.localIds() be aligned. The problem is that we do not know
35 // exactly what the required alignment is. We could base it on
36 // \a m_block_size and say that the alignment is m_block_size * sizeof(Int32).
37 // In any case, the potential alignment problem will be detected by
38 // SimdItemEnumerator.
39 Integer nb_item = m_items.size();
40 m_nb_block = nb_item / m_block_size;
41 if ((nb_item % m_block_size) != 0)
42 ++m_nb_block;
43
44 m_block_grain_size = grain_size / m_block_size;
45}
46
47/*---------------------------------------------------------------------------*/
48/*---------------------------------------------------------------------------*/
49
50ItemVectorView AbstractItemRangeFunctor::
51_view(Integer begin_block, Integer nb_block, Int32* true_begin) const
52{
53 // Convert (begin_block, nb_block) to (begin, size) corresponding to m_items.
54 Integer begin = begin_block * m_block_size;
55 Integer nb_item = m_items.size();
56 Integer size = math::min(nb_block * m_block_size, nb_item - begin);
57 if (true_begin)
58 *true_begin = begin;
59 return m_items.subView(begin, size);
60}
61
62/*---------------------------------------------------------------------------*/
63/*---------------------------------------------------------------------------*/
64
65} // namespace Arcane
66
67/*---------------------------------------------------------------------------*/
68/*---------------------------------------------------------------------------*/
View on a vector of entities.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.