Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use uniqueId() of first node to sort items in ItemsOwnerBuilder #1991

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
39 changes: 32 additions & 7 deletions arcane/src/arcane/mesh/ItemsOwnerBuilder.cc
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
// -*- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature -*-
//-----------------------------------------------------------------------------
// Copyright 2000-2024 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// Copyright 2000-2025 CEA (www.cea.fr) IFPEN (www.ifpenergiesnouvelles.com)
// See the top-level COPYRIGHT file for details.
// SPDX-License-Identifier: Apache-2.0
//-----------------------------------------------------------------------------
/*---------------------------------------------------------------------------*/
/* ItemsOwnerBuilder.cc (C) 2000-2024 */
/* ItemsOwnerBuilder.cc (C) 2000-2025 */
/* */
/* Classe pour calculer les propriétaires des entités. */
/*---------------------------------------------------------------------------*/
Expand Down Expand Up @@ -68,13 +68,26 @@
: public TraceAccessor
{
class ItemOwnerInfoSortTraits;

/*!
* \brief Informations sur une entité partagée.
*
* On conserve dans l'instance le uniqueId() du premier noeud
* de l'entité et on s'en sert comme clé primaire pour le tri.
* En général, les noeuds dont le uniqueId() est proche sont dans le même
* sous-domaine. Comme on se sert de cette valeur comme clé primaire
* du tri, cela permet de garantir une certaine cohérence topologique
* des entités distribuées et ainsi éviter de faire un all-to-all qui
* concerne un grand nombre de rangs.
*/
class ItemOwnerInfo
{
public:

ItemOwnerInfo() = default;
ItemOwnerInfo(Int64 item_uid, Int64 cell_uid, Int32 sender_rank, Int32 cell_owner)
ItemOwnerInfo(Int64 item_uid, Int64 first_node_uid, Int64 cell_uid, Int32 sender_rank, Int32 cell_owner)
: m_item_uid(item_uid)
, m_first_node_uid(first_node_uid)
, m_cell_uid(cell_uid)
, m_item_sender_rank(sender_rank)
, m_cell_owner(cell_owner)
Expand All @@ -83,9 +96,15 @@

public:

//! uniqueId() de l'entité
Int64 m_item_uid = NULL_ITEM_UNIQUE_ID;
//! uniqueId() du premier noeud de l'entité
Int64 m_first_node_uid = NULL_ITEM_UNIQUE_ID;
//! uniqueId() de la maille à laquelle l'entité appartient
Int64 m_cell_uid = NULL_ITEM_UNIQUE_ID;
//! rang de celui qui a créé cette instance
Int32 m_item_sender_rank = A_NULL_RANK;
//! Propriétaire de la maille connectée à cette entité
Int32 m_cell_owner = A_NULL_RANK;
};

Expand Down Expand Up @@ -121,6 +140,11 @@

static bool compareLess(const ItemOwnerInfo& k1, const ItemOwnerInfo& k2)
{
if (k1.m_first_node_uid < k2.m_first_node_uid)
return true;
if (k1.m_first_node_uid > k2.m_first_node_uid)
return false;

if (k1.m_item_uid < k2.m_item_uid)
return true;
if (k1.m_item_uid > k2.m_item_uid)
Expand Down Expand Up @@ -156,7 +180,7 @@
}
static ItemOwnerInfo maxValue()
{
return ItemOwnerInfo(INT64_MAX, INT64_MAX, INT32_MAX, INT32_MAX);
return ItemOwnerInfo(INT64_MAX, INT64_MAX, INT64_MAX, INT32_MAX, INT32_MAX);
}
static bool isValid(const ItemOwnerInfo& fsi)
{
Expand Down Expand Up @@ -217,7 +241,7 @@
for (Cell cell : face.cells()) {
if (verbose_level >= 2)
info() << "ADD lid=" << lid << " uid=" << face_uid << " cell_uid=" << cell.uniqueId() << " owner=" << cell.owner();
m_items_owner_info.add(ItemOwnerInfo(face_uid, cell.uniqueId(), my_rank, cell.owner()));
m_items_owner_info.add(ItemOwnerInfo(face_uid, face.node(0).uniqueId(), cell.uniqueId(), my_rank, cell.owner()));
}
}

Expand Down Expand Up @@ -249,7 +273,8 @@
info() << "END_ALL_ITEM_OWNER_SORTER time=" << (Real)(sort_end_time - sort_begin_time);
if (verbose_level >= 2)
for (const ItemOwnerInfo& x : m_items_owner_info) {
info() << "Sorted item_uid=" << x.m_item_uid << " cell_uid=" << x.m_cell_uid << " owner=" << x.m_cell_owner;
info() << "Sorted first_node_uid=" << x.m_first_node_uid << " item_uid="
<< x.m_item_uid << " cell_uid=" << x.m_cell_uid << " owner=" << x.m_cell_owner;

Check warning on line 277 in arcane/src/arcane/mesh/ItemsOwnerBuilder.cc

View check run for this annotation

Codecov / codecov/patch

arcane/src/arcane/mesh/ItemsOwnerBuilder.cc#L276-L277

Added lines #L276 - L277 were not covered by tests
}
}

Expand Down Expand Up @@ -338,7 +363,7 @@
}

auto exchanger{ ParallelMngUtils::createExchangerRef(pm) };

info() << "NbResendRanks=" << resend_items_owner_info_map.size();
for (const auto& [key, value] : resend_items_owner_info_map) {
if (verbose_level >= 1)
info() << "RESEND_INFO to_rank=" << key << " nb=" << value.size();
Expand Down
Loading