14#include <arccore/message_passing/ISerializeMessageList.h>
15#include <arccore/message_passing/Messages.h>
17#include <alien/index_manager/IAbstractFamily.h>
18#include <alien/index_manager/IndexManager.h>
19#include <alien/utils/Precomp.h>
20#include <alien/utils/Trace.h>
33 explicit EntryLocalId(Alien::Integer size)
34 : m_is_defined(size,
false)
37 void reserveLid(
const Integer count)
39 m_defined_lids.reserve(m_defined_lids.size() + count);
42 [[nodiscard]]
bool isDefinedLid(
const Integer localId)
const
44 return m_is_defined[localId];
47 void defineLid(
const Integer localId,
const Integer pos)
49 m_is_defined[localId] =
true;
50 Alien::add(m_defined_lids, std::make_pair(localId, pos));
53 void undefineLid(
const Integer localId)
55 m_is_defined[localId] =
false;
56 for (Integer i = 0; i < m_defined_lids.size(); ++i) {
57 if (m_defined_lids[i].first == localId) {
58 m_defined_lids[i] = m_defined_lids.back();
59 m_defined_lids.resize(m_defined_lids.size() - 1);
63 throw FatalErrorException(
64 A_FUNCINFO,
"Inconsistent state : cannot find id to remove");
67 [[nodiscard]]
const UniqueArray<std::pair<Integer, Integer>>& definedLids()
const
69 return m_defined_lids;
72 void freeDefinedLids()
74 Alien::freeData(m_defined_lids);
75 std::vector<bool>().swap(m_is_defined);
78 std::vector<bool> m_is_defined;
79 UniqueArray<std::pair<Integer, Integer>> m_defined_lids;
87 EntrySendRequest() =
default;
89 ~EntrySendRequest() =
default;
91 EntrySendRequest(
const EntrySendRequest& esr)
95 Arccore::Ref<Arccore::MessagePassing::ISerializeMessage> comm;
98 void operator=(
const EntrySendRequest&) =
delete;
105 EntryRecvRequest() =
default;
107 ~EntryRecvRequest() =
default;
111 Arccore::Ref<Arccore::MessagePassing::ISerializeMessage> comm;
112 UniqueArray<Int64> ids;
114 void operator=(
const EntryRecvRequest&) =
delete;
120IndexManager::IndexManager(
121Alien::IMessagePassingMng*
parallelMng, Alien::ITraceMng* traceMng)
123, m_trace_mng(traceMng)
127, m_local_entry_count(0)
128, m_global_entry_count(0)
129, m_global_entry_offset(0)
130, m_local_removed_entry_count(0)
131, m_global_removed_entry_count(0)
132, m_max_null_index_opt(false)
140IndexManager::~IndexManager()
151 m_state = Initialized;
153 m_local_entry_count = 0;
154 m_global_entry_count = 0;
155 m_global_entry_offset = 0;
156 m_local_removed_entry_count = 0;
157 m_global_removed_entry_count = 0;
170void IndexManager::setVerboseMode(
bool verbose)
178IndexManager::buildEntry(
179const String& name,
const IAbstractFamily* family,
const Integer kind)
181 if (m_state != Initialized)
182 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
185 if (name == e->getName())
186 throw FatalErrorException(A_FUNCINFO,
"Already defined entry");
193 auto* entry =
new ScalarIndexSet(name, uid,
this, kind);
202void IndexManager::defineIndex(
const ScalarIndexSet& entry, ConstArrayView<Integer> localIds)
204 if (m_state != Initialized)
205 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
207 ALIEN_ASSERT((entry.manager() ==
this), (
"Incompatible entry from another manager"));
209 const Integer uid = entry.getUid();
213 auto entry_local_ids = std::make_shared<EntryLocalId>(family->maxLocalId());
215 m_entry_local_ids[uid] = entry_local_ids;
217 auto owners = family->owners(localIds);
219 entry_local_ids->reserveLid(localIds.size());
220 for (Integer i = 0, is = localIds.size(); i < is; ++i) {
221 const Integer localId = localIds[i];
222 if (not entry_local_ids->isDefinedLid(localId)) {
224 entry_local_ids->defineLid(
225 localId, +(m_local_removed_entry_count + m_local_entry_count++));
228 entry_local_ids->defineLid(
229 localId, -(m_global_removed_entry_count + (++m_global_entry_count)));
239 if (m_state != Initialized)
240 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
242 ALIEN_ASSERT((entry.
manager() ==
this), (
"Incompatible entry from another manager"));
244 const Integer uid = entry.
getUid();
248 auto entry_local_ids = m_entry_local_ids[uid];
250 const auto owners = family->owners(localIds);
252 for (Integer localId : localIds) {
253 if (entry_local_ids->isDefinedLid(localId)) {
254 entry_local_ids->undefineLid(localId);
256 --m_local_entry_count;
257 ++m_local_removed_entry_count;
260 --m_global_entry_count;
261 ++m_global_removed_entry_count;
271 EntryIndexMap entry_index;
273 begin_prepare(entry_index);
275 if (m_parallel_mng->commSize() > 1) {
276 begin_parallel_prepare(entry_index);
277 end_parallel_prepare(entry_index);
280 sequential_prepare(entry_index);
283 end_prepare(entry_index);
288void IndexManager::begin_prepare(EntryIndexMap& entry_index)
290 if (m_state != Initialized)
291 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
293 Integer total_size = 0;
295 auto entry_local_ids = m_entry_local_ids[entry->getUid()];
296 total_size += entry_local_ids->definedLids().size();
299 entry_index.reserve(total_size);
302 const Integer entry_uid = entry->getUid();
304 const Integer entry_kind = entry->getKind();
305 auto entry_local_ids = m_entry_local_ids[entry_uid];
306 const auto& lids = entry_local_ids->definedLids();
307 for (Integer i = 0, is = lids.size(); i < is; ++i) {
308 const Integer item_localid = lids[i].first;
309 auto item = family->item(item_localid);
310 entry_index.push_back(InternalEntryIndex{ entry_uid, entry_kind, item.uniqueId(),
311 item_localid, lids[i].second, item.owner() });
313 entry_local_ids->freeDefinedLids();
316 m_entry_local_ids.clear();
319 std::sort(entry_index.begin(), entry_index.end(),
321 if (a.m_entry_kind != b.m_entry_kind)
322 return a.m_entry_kind < b.m_entry_kind;
323 else if (a.m_item_uid != b.m_item_uid)
324 return a.m_item_uid < b.m_item_uid;
326 return a.m_entry_uid < b.m_entry_uid;
329 ((Integer)entry_index.size() == m_local_entry_count + m_global_entry_count),
330 (
"Inconsistent global size"));
335void IndexManager::end_prepare(EntryIndexMap& entryIndex)
338 std::map<Integer, Integer> count_table;
339 for (
auto& i : entryIndex) {
340 count_table[i.m_entry_uid]++;
349 const Integer uid = entry->getUid();
350 const Integer size = count_table[uid];
354 all_items.resize(size);
355 all_indices.resize(size);
358 Integer ghost_i = size;
359 for (
auto& i : entryIndex) {
360 if (i.m_entry_uid == uid) {
361 const Integer local_id = i.m_item_localid;
362 const Integer index = i.m_item_index;
363 const bool is_own = isOwn(i);
365 all_items[own_i] = local_id;
366 all_indices[own_i] = index;
371 all_items[ghost_i] = local_id;
372 all_indices[ghost_i] = index;
377 const Integer own_size = own_i;
378 ALIEN_ASSERT((own_i == ghost_i), (
"Not merged insertion"));
388 cout() <<
"Entry ordering :";
390 cout() <<
"\tEntry '" << entry->getName() <<
"' placed at rank "
391 << entry->getUid() <<
" with " << getOwnLocalIds(*entry).size()
392 <<
" local / " << getAllLocalIds(*entry).size() <<
" global indexes ";
394 cout() <<
"Total local Entry indexes = " << m_local_entry_count;
405 typedef std::map<Integer, EntrySendRequest> SendRequestByEntry;
406 typedef std::map<Integer, SendRequestByEntry> SendRequests;
407 SendRequests sendRequests;
410 typedef std::list<EntryRecvRequest> RecvRequests;
411 RecvRequests recvRequests;
413 Alien::Ref<ISerializeMessageList> messageList;
419void IndexManager::begin_parallel_prepare(EntryIndexMap& entry_index)
422 ALIEN_ASSERT((m_parallel_mng->commSize() > 1), (
"Parallel mode expected"));
433 parallel = std::make_shared<ParallelRequests>();
436 for (
auto& entryIndex : entry_index) {
437 const Integer item_owner = entryIndex.m_item_owner;
439 parallel->sendRequests[item_owner][entryIndex.m_entry_uid].count++;
444 parallel->messageList =
445 Arccore::MessagePassing::mpCreateSerializeMessageListRef(m_parallel_mng);
448 UniqueArray<Integer> sendToDomains(2 * m_parallel_mng->commSize(), 0);
450 for (
auto i = parallel->sendRequests.begin(); i != parallel->sendRequests.end(); ++i) {
451 const Integer destDomainId = i->first;
452 auto& requests = i->second;
453 for (
auto& j : requests) {
454 EntrySendRequest& request = j.second;
455 const Integer entryImpl = j.first;
456 const String nameString =
m_entries[entryImpl]->getName();
459 sendToDomains[2 * destDomainId + 0] += 1;
460 sendToDomains[2 * destDomainId + 1] += request.count;
463 request.comm = parallel->messageList->createAndAddMessage(MessageRank(destDomainId),
464 Arccore::MessagePassing::ePointToPointMessageType::MsgSend);
466 auto sbuf = request.comm->serializer();
467 sbuf->setMode(Alien::ISerializer::ModeReserve);
468 sbuf->reserve(nameString);
469 sbuf->reserveInteger(1);
470 sbuf->reserve(Alien::ISerializer::DT_Int64, request.count);
471 sbuf->allocateBuffer();
472 sbuf->setMode(Alien::ISerializer::ModePut);
473 sbuf->put(nameString);
474 sbuf->put(request.count);
480 for (
auto& entryIndex : entry_index) {
481 const Integer entryImpl = entryIndex.m_entry_uid;
482 const Integer item_owner = entryIndex.m_item_owner;
483 const Int64 item_uid = entryIndex.m_item_uid;
485 parallel->sendRequests[item_owner][entryImpl].comm->serializer()->put(item_uid);
490 UniqueArray<Integer> recvFromDomains(2 * m_parallel_mng->commSize());
491 Arccore::MessagePassing::mpAllToAll(m_parallel_mng, sendToDomains, recvFromDomains, 2);
493 for (Integer isd = 0, nsd = m_parallel_mng->commSize(); isd < nsd; ++isd) {
494 Integer recvCount = recvFromDomains[2 * isd + 0];
495 while (recvCount-- > 0) {
496 auto recvMsg = parallel->messageList->createAndAddMessage(MessageRank(isd),
497 Arccore::MessagePassing::ePointToPointMessageType::MsgReceive);
500 recvRequest.comm = recvMsg;
505 parallel->messageList->processPendingMessages();
506 parallel->messageList->waitMessages(Arccore::MessagePassing::WaitAll);
507 parallel->messageList.reset();
512 parallel->messageList =
513 Arccore::MessagePassing::mpCreateSerializeMessageListRef(m_parallel_mng);
516 for (
auto i = parallel->recvRequests.begin(); i != parallel->recvRequests.end(); ++i) {
517 auto& recvRequest = *i;
522 auto sbuf = recvRequest.comm->serializer();
523 sbuf->setMode(Alien::ISerializer::ModeGet);
525 sbuf->get(nameString);
526 uidCount = sbuf->getInteger();
527 recvRequest.ids.resize(uidCount);
528 sbuf->getSpan(recvRequest.ids);
529 ALIEN_ASSERT((uidCount == recvRequest.ids.size()), (
"Inconsistency detected"));
531#ifndef NO_USER_WARNING
533#pragma message("CHECK: optimisable ?")
535#warning "CHECK: optimisable ?"
546 [&](ScalarIndexSet* s) { return s->getName() == nameString; });
550 throw FatalErrorException(
"Non local Entry Requested : degenerated system ?");
552 auto* currentEntry = *lookup;
553 const Integer entry_uid = currentEntry->getUid();
556 ArrayView<Int64> ids = recvRequest.ids;
559 const Integer entry_kind = currentEntry->getKind();
560 UniqueArray<Int32> lids(ids.size());
561 family->uniqueIdToLocalId(lids, ids);
563 auto owners = family->owners(lids);
564 for (Integer j = 0; j < uidCount; ++j) {
565 const Integer current_item_lid = lids[j];
566 const Int64 current_item_uid = ids[j];
567 const Integer current_item_owner = owners[j];
569 throw FatalErrorException(
"Non local EntryIndex requested");
572 current_item_lid, 0, current_item_owner };
575 auto lookup2 = std::lower_bound(entry_index.begin(), entry_index.end(),
577 if (a.m_entry_kind != b.m_entry_kind)
578 return a.m_entry_kind < b.m_entry_kind;
579 else if (a.m_item_uid != b.m_item_uid)
580 return a.m_item_uid < b.m_item_uid;
582 return a.m_entry_uid < b.m_entry_uid;
585 if ((lookup2 == entry_index.end()) || !(*lookup2 == lookup_entry))
586 throw FatalErrorException(
"Not locally defined entry requested");
590 ids[j] = lookup2->m_item_index;
595 auto dest = recvRequest.comm->destination();
596 auto orig = recvRequest.comm->source();
597 recvRequest.comm.reset();
598 recvRequest.comm = parallel->messageList->createAndAddMessage(dest,
599 Arccore::MessagePassing::ePointToPointMessageType::MsgSend);
601 auto sbuf = recvRequest.comm->serializer();
602 sbuf->setMode(Alien::ISerializer::ModeReserve);
603 sbuf->reserve(nameString);
604 sbuf->reserveInteger(1);
605 sbuf->reserveInteger(uidCount);
606 sbuf->allocateBuffer();
607 sbuf->setMode(Alien::ISerializer::ModePut);
608 sbuf->put(nameString);
618 UniqueArray<Integer> allLocalSizes(m_parallel_mng->commSize());
619 UniqueArray<Integer> myLocalSize(1);
620 myLocalSize[0] = m_local_entry_count;
621 Arccore::MessagePassing::mpAllGather(m_parallel_mng, myLocalSize, allLocalSizes);
624 m_global_entry_offset = 0;
625 for (Integer i = 0; i < m_parallel_mng->commRank(); ++i) {
626 m_global_entry_offset += allLocalSizes[i];
630 m_global_entry_count = 0;
631 for (Integer i = 0; i < m_parallel_mng->commSize(); ++i) {
632 m_global_entry_count += allLocalSizes[i];
638void IndexManager::end_parallel_prepare(EntryIndexMap& entry_index)
640 ALIEN_ASSERT((m_parallel_mng->commSize() > 1), (
"Parallel mode expected"));
644 Alien::UniqueArray<Integer> entry_reindex(m_local_entry_count);
645 Alien::fill(entry_reindex, -1);
648 Integer currentEntryIndex = m_global_entry_offset;
649 for (
auto& i : entry_index) {
651 const Integer newIndex = currentEntryIndex++;
652 ALIEN_ASSERT(newIndex >= 0,
"Invalid local id");
653 entry_reindex[i.m_item_index] = newIndex;
654 i.m_item_index = newIndex;
659 for (
auto& recvRequest : parallel->recvRequests) {
660 auto sbuf = recvRequest.comm->serializer();
661 for (
auto id : recvRequest.ids) {
662 sbuf->putInteger(entry_reindex[
id]);
667 typedef std::list<Alien::Ref<Alien::ISerializeMessage>> ReturnedRequests;
668 ReturnedRequests returnedRequests;
675 typedef std::map<Integer, EntrySendRequest*> SubFastReturnMap;
676 typedef std::map<String, SubFastReturnMap> FastReturnMap;
677 FastReturnMap fastReturnMap;
680 for (
auto i = parallel->sendRequests.begin(); i != parallel->sendRequests.end(); ++i) {
681 const Integer destDomainId = i->first;
682 auto& requests = i->second;
683 for (
auto& j : requests) {
684 auto& request = j.second;
685 const Integer entryImpl = j.first;
686 const String nameString =
m_entries[entryImpl]->getName();
693 request.comm.reset();
695 auto msg = parallel->messageList->createAndAddMessage(MessageRank(destDomainId),
696 Arccore::MessagePassing::ePointToPointMessageType::MsgReceive);
698 returnedRequests.push_back(msg);
700 fastReturnMap[nameString][destDomainId] = &request;
705 parallel->messageList->processPendingMessages();
707 parallel->messageList->waitMessages(Arccore::MessagePassing::WaitAll);
708 parallel->messageList.reset();
712 for (
auto& returnedRequest : returnedRequests) {
713 auto& message = returnedRequest;
714 auto origDomainId = message->destination().value();
715 auto sbuf = message->serializer();
716 sbuf->setMode(Alien::ISerializer::ModeGet);
718 sbuf->get(nameString);
720 (fastReturnMap[nameString][origDomainId] !=
nullptr), (
"Inconsistency detected"));
721 auto& request = *fastReturnMap[nameString][origDomainId];
724#ifdef ALIEN_DEBUG_ASSERT
725 const Integer idCount = sbuf.getInteger();
726 ALIEN_ASSERT((request.count == idCount), (
"Inconsistency detected"));
728 const Integer idCount = sbuf->getInteger();
729 ALIEN_ASSERT((request.count == idCount), (
"Inconsistency detected"));
735 for (
auto& entry : entry_index) {
736 const Integer item_owner = entry.m_item_owner;
738 const Integer entryImpl = entry.m_entry_uid;
739 auto& request = parallel->sendRequests[item_owner][entryImpl];
740 ALIEN_ASSERT((request.count > 0), (
"Unexpected empty request"));
742 auto sbuf = request.comm->serializer();
743 const Integer newIndex = sbuf->getInteger();
744 entry.m_item_index = newIndex;
751void IndexManager::sequential_prepare(EntryIndexMap& entry_index)
753 ALIEN_ASSERT((m_parallel_mng->commSize() <= 1), (
"Sequential mode expected"));
754 ALIEN_ASSERT((m_global_entry_count == 0),
755 (
"Unexpected global entries (%d)", m_global_entry_count));
766 Integer currentEntryIndex = 0;
767 for (
auto i = entry_index.begin(); i != entry_index.end(); ++i) {
769 (
"Item cannot be non-local for sequential mode"));
771 const Integer newIndex = currentEntryIndex++;
772 i->m_item_index = newIndex;
775 m_global_entry_count = m_local_entry_count;
783 if (m_state != Prepared)
784 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
786 ALIEN_ASSERT((entry.
manager() ==
this), (
"Incompatible entry from another manager"));
788 UniqueArray<Integer> allIds(family.
maxLocalId(), nullIndex());
789 const ConstArrayView<Integer> allIndices = getAllIndexes(entry);
790 const ConstArrayView<Integer> allLocalIds = getAllLocalIds(entry);
791 const Integer size = allIndices.size();
792 for (Integer i = 0; i < size; ++i)
793 allIds[allLocalIds[i]] = allIndices[i];
802 if (m_state != Prepared)
803 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
805 Integer max_family_size = 0;
806 for (Integer i = 0; i < entries.size(); ++i) {
809 (entries[i].manager() ==
this), (
"Incompatible entry from another manager"));
810 const auto& entry = entries[i];
812 max_family_size = std::max(max_family_size, family.
maxLocalId());
815 UniqueArray2<Integer> allIds;
816 Alien::allocateData(allIds, max_family_size, entries.size());
817 Alien::fill(allIds, nullIndex());
819 for (Integer i = 0; i < entries.size(); ++i) {
820 const auto& entry = entries[i];
821 const ConstArrayView<Integer> allIndices = getAllIndexes(entry);
822 const ConstArrayView<Integer> allLocalIds = getAllLocalIds(entry);
823 const Integer size = allIndices.size();
824 for (Integer j = 0; j < size; ++j)
825 allIds[allLocalIds[j]][i] = allIndices[i];
832void IndexManager::stats(Integer& globalSize, Integer& minLocalIndex, Integer& localSize)
const
834 if (m_state != Prepared)
835 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
837 globalSize = m_global_entry_count;
838 minLocalIndex = m_global_entry_offset;
839 localSize = m_local_entry_count;
845IndexManager::globalSize()
const
847 if (m_state != Prepared)
848 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
850 return m_global_entry_count;
856IndexManager::minLocalIndex()
const
858 if (m_state != Prepared)
859 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
861 return m_global_entry_offset;
867IndexManager::localSize()
const
869 if (m_state != Prepared)
870 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
872 return m_local_entry_count;
879 ConstArrayView<Integer> localIds,
885 cout() <<
"IndexManager: build scalar index set '" << name <<
"', kind=" << kind;
887 ScalarIndexSet en = buildEntry(name, addNewAbstractFamily(&family, alive), kind);
888 defineIndex(en, localIds);
896const String& name,
const IAbstractFamily& family, Integer kind, eKeepAlive alive)
899 cout() <<
"IndexManager: build scalar index set '" << name <<
"', kind=" << kind;
902 ScalarIndexSet en = buildEntry(name, addNewAbstractFamily(&family, alive), kind);
903 defineIndex(en, localIds.view());
909IndexManager::VectorIndexSet
911 ConstArrayView<Integer> localIds,
913 const UniqueArray<Integer>& kind,
917 cout() <<
"IndexManager: build vector index set '" << name
918 <<
"', size=" << kind.size();
920 const Integer size = kind.size();
921 VectorIndexSet ens(size);
922 const auto* f = addNewAbstractFamily(&family, alive);
923 for (Integer i = 0; i < size; ++i) {
924 ens[i] = buildEntry(Alien::format(
"{0}[{1}]", name, i), f, kind[i]);
925 defineIndex(ens[i], localIds);
932IndexManager::VectorIndexSet
935 const UniqueArray<Integer>& kind,
939 cout() <<
"IndexManager: build vector index set '" << name
940 <<
"', size=" << kind.size();
943 const Integer size = kind.size();
944 VectorIndexSet ens(size);
945 const auto* f = addNewAbstractFamily(&family, alive);
946 for (Integer i = 0; i < size; ++i) {
947 ens[i] = buildEntry(Alien::format(
"{0}[{1}]", name, i), f, kind[i]);
948 defineIndex(ens[i], localIds.view());
956IndexManager::addNewAbstractFamily(
const IAbstractFamily* family, eKeepAlive alive)
961 if (alive == eKeepAlive::DontClone) {
966 auto clone = std::shared_ptr<IAbstractFamily>(family->clone());
970 if (f.second == family)
971 f.second = clone.get();
979 return finder->second.get();
981 if (alive == eKeepAlive::DontClone) {
985 auto clone = std::shared_ptr<IAbstractFamily>(family->clone());
989 if (f.second == family)
990 f.second = clone.get();
1000ConstArrayView<Integer>
1001IndexManager::getOwnIndexes(
const ScalarIndexSet& entry)
const
1003 ALIEN_ASSERT((entry.manager() ==
this), (
"Incompatible entry from another manager"));
1004 if (m_state != Prepared)
1005 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
1012ConstArrayView<Integer>
1013IndexManager::getOwnLocalIds(
const ScalarIndexSet& entry)
const
1015 ALIEN_ASSERT((entry.manager() ==
this), (
"Incompatible entry from another manager"));
1016 if (m_state != Prepared)
1017 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
1024ConstArrayView<Integer>
1025IndexManager::getAllIndexes(
const ScalarIndexSet& entry)
const
1027 ALIEN_ASSERT((entry.manager() ==
this), (
"Incompatible entry from another manager"));
1028 if (m_state != Prepared)
1029 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
1036ConstArrayView<Integer>
1037IndexManager::getAllLocalIds(
const ScalarIndexSet& entry)
const
1039 ALIEN_ASSERT((entry.manager() ==
this), (
"Incompatible entry from another manager"));
1040 if (m_state != Prepared)
1041 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
1048const IAbstractFamily&
1049IndexManager::getFamily(
const ScalarIndexSet& entry)
const
1051 ALIEN_ASSERT((entry.manager() ==
this), (
"Incompatible entry from another manager"));
1052 if (m_state != Prepared)
1053 throw FatalErrorException(A_FUNCINFO,
"Inconsistent state");
1055 return *(it->second);
1062 m_max_null_index_opt = flag;
1064 alien_debug(flag, [&] { cout() <<
"IndexManager: null index optimized enabled"; });
1070IndexManager::nullIndex()
const
1072 ALIEN_ASSERT((m_state == Prepared), (
"nullIndex is valid only in Prepared state"));
1073 if (m_max_null_index_opt)
1074 return m_global_entry_offset + m_local_entry_count;
Interface for abstract families of items.
virtual SafeConstArrayView< Int32 > allLocalIds() const =0
Local ids of this family members.
virtual Int32 maxLocalId() const =0
Max local Id for this family.
void init()
Initialisation.
Integer getUid() const
Creation label.
const IndexManager * manager() const
Associated index manager.
std::map< Integer, UniqueArray< Integer > > m_entry_all_items
Local ids, sorted by owned then ghosts. By entry.
IMessagePassingMng * parallelMng() const
Parallel Manager used for the index computation.
UniqueArray< Integer > getIndexes(const ScalarIndexSet &entry) const
Give a translation table, indexed by items.
std::map< Integer, ConstArrayView< Integer > > m_entry_own_indices
Unique ids, only for owned, by entry.
std::map< const IAbstractFamily *, std::shared_ptr< IAbstractFamily > > m_abstract_families
Abstract families and associated clones (if handled).
void setMaxNullIndexOpt(bool flag)
define null index : default = -1, if true null_index = max_index+1
ScalarIndexSet buildScalarIndexSet(const String &name, ConstArrayView< Integer > localIds, const IAbstractFamily &family, Integer kind, eKeepAlive alive=DontClone)
std::map< Integer, ConstArrayView< Integer > > m_entry_own_items
Local ids, only for owned, by entry.
std::map< Integer, UniqueArray< Integer > > m_entry_all_indices
Unique ids, sorted by owned then ghosts. By entry.
Integer m_local_owner
current owner.
ScalarIndexSetVector m_entries
Table des Entry connues localement.
std::map< Integer, const IAbstractFamily * > m_entry_families
Family, by entry.
VectorIndexSet buildVectorIndexSet(const String &name, ConstArrayView< Integer > localIds, const IAbstractFamily &family, const UniqueArray< Integer > &kind, eKeepAlive alive=DontClone)
void removeIndex(const ScalarIndexSet &entry, ConstArrayView< Integer > localIds)
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --