Arcane  v3.14.10.0
Documentation développeur
Chargement...
Recherche...
Aucune correspondance
BlockIndexList.h
1// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
2//-----------------------------------------------------------------------------
3// Copyright 2000-2022 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/* BlockIndexList.h (C) 2000-2023 */
9/* */
10/* Classe gérant un tableau d'indices sous la forme d'une liste de blocs. */
11/*---------------------------------------------------------------------------*/
12#ifndef ARCANE_BLOCKINDEXLIST_H
13#define ARCANE_BLOCKINDEXLIST_H
14/*---------------------------------------------------------------------------*/
15/*---------------------------------------------------------------------------*/
16
17#include "arcane/utils/TraceAccessor.h"
18#include "arcane/utils/UniqueArray.h"
19
20#include "arcane/ArcaneTypes.h"
21
22/*---------------------------------------------------------------------------*/
23/*---------------------------------------------------------------------------*/
24
25namespace Arcane
26{
27
28/*---------------------------------------------------------------------------*/
29/*---------------------------------------------------------------------------*/
35class ARCANE_CORE_EXPORT BlockIndex
36{
37 friend class BlockIndexList;
38
39 public:
40
41 static constexpr Int16 MAX_BLOCK_SIZE = 512;
42
43 private:
44
45 BlockIndex(const Int32* ptr, Int32 value_offset, Int16 size)
46 : m_block_start(ptr)
47 , m_value_offset(value_offset)
48 , m_size(size)
49 {}
50
51 public:
52
54 Int32 operator[](Int32 i) const
55 {
56 ARCANE_CHECK_AT(i, m_size);
57 return m_block_start[i] + m_value_offset;
58 }
59
61 Int16 size() const { return m_size; }
62
64 Int32 valueOffset() const { return m_value_offset; }
65
66 private:
67
68 const Int32* m_block_start = nullptr;
69 Int32 m_value_offset = 0;
70 Int16 m_size = 0;
71};
72
73/*---------------------------------------------------------------------------*/
74/*---------------------------------------------------------------------------*/
80class ARCANE_CORE_EXPORT BlockIndexList
81{
82 friend class BlockIndexListBuilder;
83
84 // TODO: pouvoir choisir un allocateur avec support accélérateur.
85
86 public:
87
88 Int32 nbBlock() const { return m_nb_block; }
89 Real memoryRatio() const;
90 void reset();
91 BlockIndex block(Int32 i) const
92 {
93 Int32 index = m_blocks_index_and_offset[i * 2];
94 Int32 offset = m_blocks_index_and_offset[(i * 2) + 1];
95 Int16 size = ((i + 1) != m_nb_block) ? m_block_size : m_last_block_size;
96 return BlockIndex(m_indexes.span().ptrAt(index), offset, size);
97 }
98 void fillArray(Array<Int32>& v);
99
100 private:
101
104 // Index dans 'm_indexes' et offset de chaque bloc
105 UniqueArray<Int32> m_blocks_index_and_offset;
107 Int32 m_original_size = 0;
109 Int32 m_nb_block = 0;
111 Int16 m_block_size = 0;
113 Int16 m_last_block_size = 0;
114
115 private:
116
117 void _setBlockIndexAndOffset(Int32 block, Int32 index, Int32 offset);
118 void _setNbBlock(Int32 nb_block);
119 Int32 _currentIndexPosition() const;
120 void _addBlockInfo(const Int32* data, Int16 size);
121 Int32 _computeNbContigusBlock() const;
122};
123
124/*---------------------------------------------------------------------------*/
125/*---------------------------------------------------------------------------*/
131class ARCANE_CORE_EXPORT BlockIndexListBuilder
132: public TraceAccessor
133{
134 public:
135
137
138 public:
139
140 void setVerbose(bool v) { m_is_verbose = v; }
141
149 void setBlockSizeAsPowerOfTwo(Int32 v);
150
151 public:
152
153 void build(BlockIndexList& block_index_list, SmallSpan<const Int32> indexes, const String& name);
154
155 private:
156
157 bool m_is_verbose = false;
158 Int16 m_block_size = 32;
159
160 private:
161
162 void _throwInvalidBlockSize [[noreturn]] (Int32 block_size);
163};
164
165/*---------------------------------------------------------------------------*/
166/*---------------------------------------------------------------------------*/
167
168} // namespace Arcane
169
170/*---------------------------------------------------------------------------*/
171/*---------------------------------------------------------------------------*/
172
173#endif
Classe permettant de construire un BlockIndexList.
Classe gérant un tableau sous la forme d'une liste de blocs.
UniqueArray< Int32 > m_indexes
Liste des indexes.
Bloc contenant une une liste d'indices avec un offset.
Int32 valueOffset() const
Offset des valeurs du bloc.
Int16 size() const
Taille du bloc.
Int32 operator[](Int32 i) const
i-ème valeur du bloc
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Definition Lima.cc:120
Interface du gestionnaire de traces.
Chaîne de caractères unicode.
-*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-