38class ALIEN_EXPORT IndexManager
41 typedef UniqueArray<ScalarIndexSet> VectorIndexSet;
43 typedef std::vector<ScalarIndexSet*> ScalarIndexSetVector;
55 explicit Iterator(
const ScalarIndexSetVector::iterator& it)
58 void operator++() { m_iterator++; }
59 bool operator!=(
const Iterator& it) {
return m_iterator != it.m_iterator; }
63 ScalarIndexSetVector::iterator m_iterator;
69 explicit ConstIterator(
const ScalarIndexSetVector::const_iterator& it)
72 void operator++() { m_iterator++; }
73 bool operator!=(
const ConstIterator& it) {
return m_iterator != it.m_iterator; }
77 ScalarIndexSetVector::const_iterator m_iterator;
86 Integer m_item_localid;
92 return m_entry_uid == m.m_entry_uid && m.m_item_localid == m_item_localid;
97 explicit IndexManager(
98 Alien::IMessagePassingMng*
parallelMng, Alien::ITraceMng* traceMng =
nullptr);
100 virtual ~IndexManager();
105 bool isPrepared()
const {
return m_state == Prepared; }
107 void setVerboseMode(
bool verbose);
112 template <
typename T>
124 void stats(Integer& globalSize, Integer& minLocalIndex, Integer& localSize)
const;
126 Integer globalSize()
const;
128 Integer minLocalIndex()
const;
130 Integer localSize()
const;
146 ConstArrayView<Integer> localIds,
148 Integer kind, eKeepAlive alive = DontClone);
159 Integer kind, eKeepAlive alive = DontClone);
172 VectorIndexSet buildVectorIndexSet(
const String& name,
173 ConstArrayView<Integer> localIds,
175 const UniqueArray<Integer>& kind,
176 eKeepAlive alive = DontClone);
187 VectorIndexSet buildVectorIndexSet(
const String& name,
189 const UniqueArray<Integer>& kind,
190 eKeepAlive alive = DontClone);
200 void removeIndex(
const ScalarIndexSet& entry, ConstArrayView<Integer> localIds);
203 UniqueArray<Integer> getIndexes(
const ScalarIndexSet& entry)
const;
206 UniqueArray2<Integer> getIndexes(
const VectorIndexSet& entries)
const;
208 ConstArrayView<Integer> getOwnIndexes(
const ScalarIndexSet& entry)
const;
209 ConstArrayView<Integer> getOwnLocalIds(
const ScalarIndexSet& entry)
const;
210 ConstArrayView<Integer> getAllIndexes(
const ScalarIndexSet& entry)
const;
211 ConstArrayView<Integer> getAllLocalIds(
const ScalarIndexSet& entry)
const;
216 IMessagePassingMng*
parallelMng()
const {
return m_parallel_mng; }
219 void setMaxNullIndexOpt(
bool flag);
221 Integer nullIndex()
const;
223 Iterator begin() {
return Iterator(m_entries.begin()); }
224 Iterator end() {
return Iterator(m_entries.end()); }
225 ConstIterator begin()
const {
return ConstIterator(m_entries.begin()); }
226 ConstIterator end()
const {
return ConstIterator(m_entries.end()); }
229 ScalarIndexSet buildEntry(
230 const String& name,
const IAbstractFamily* itemFamily, Integer kind);
232 void defineIndex(
const ScalarIndexSet& entry, ConstArrayView<Integer> localIds);
234 typedef std::vector<InternalEntryIndex> EntryIndexMap;
236 void begin_prepare(EntryIndexMap& entry_index);
237 void begin_parallel_prepare(EntryIndexMap& entry_index);
238 void end_parallel_prepare(EntryIndexMap& entry_index);
239 void sequential_prepare(EntryIndexMap& entry_index);
240 void end_prepare(EntryIndexMap& entryIndex);
242 const IAbstractFamily* addNewAbstractFamily(
243 const IAbstractFamily* family, eKeepAlive alive);
246 Alien::IMessagePassingMng* m_parallel_mng =
nullptr;
247 Alien::ITraceMng* m_trace_mng =
nullptr;
259 Integer m_local_entry_count;
260 Integer m_global_entry_count;
261 Integer m_global_entry_offset;
262 Integer m_local_removed_entry_count;
263 Integer m_global_removed_entry_count;
265 bool m_max_null_index_opt;
292 std::map<Integer, std::shared_ptr<EntryLocalId>> m_entry_local_ids;
295 std::shared_ptr<ParallelRequests> parallel;
308 EntryIndexMap entry_index;
310 begin_prepare(entry_index);
312 if (m_parallel_mng->commSize() > 1) {
313 begin_parallel_prepare(entry_index);
315 std::sort(entry_index.begin(), entry_index.end(), t);
317 end_parallel_prepare(entry_index);
320 std::sort(entry_index.begin(), entry_index.end(), t);
322 sequential_prepare(entry_index);
325 end_prepare(entry_index);