14#include "arcane/utils/NotImplementedException.h"
15#include "arcane/utils/CheckedConvert.h"
17#include "arcane/core/IParallelMng.h"
18#include "arcane/core/ISubDomain.h"
19#include "arcane/core/CommonVariables.h"
20#include "arcane/core/IMesh.h"
21#include "arcane/core/IMeshSubMeshTransition.h"
22#include "arcane/core/IMeshUtilities.h"
23#include "arcane/core/FactoryService.h"
25#include "arcane/core/Service.h"
26#include "arcane/core/ItemPrinter.h"
27#include "arcane/core/IMeshPartitioner.h"
28#include "arcane/core/BasicService.h"
30#include "arcane/core/IMeshPartitionConstraintMng.h"
31#include "arcane/impl/MeshPartitionerTesterService_axl.h"
54class MeshPartitionerTester
65 IMesh*
mesh()
const override {
return BasicService::mesh(); }
71 ARCANE_UNUSED(initial_partition);
72 ARCANE_UNUSED(nb_part);
81 Real maximumComputationTime()
const override {
return m_max_computation_time; }
93 m_cells_weight = weights;
94 m_nb_weight = nb_weight;
110 Real m_max_imbalance;
111 Real m_max_computation_time;
113 ArrayView<float> m_cells_weight;
120MeshPartitionerTester::
124, m_max_imbalance(0.0)
125, m_max_computation_time(0.0)
138 Int32 sub_rank_divider = 0;
140 sub_rank_divider =
options()->subRankDivider();
142 info() <<
"Using MeshPartitionerTester sub_rank_divider=" << sub_rank_divider;
150 warning() <<
"Can't test the mesh repartitioning with"
151 <<
"only one subdomain...";
157 if (initial_partition) {
169 Int64 nb_bloc = nb_rank * 3;
170 Int64 cell_index = 0;
174 Int64 new_owner = ((cell_index * nb_bloc) / nb_cell) % nb_rank;
175 cells_new_owner[cell] = CheckedConvert::toInt32(new_owner);
184 Integer max_cell_index = nb_cell / 2;
191 if (cell_index < (max_cell_index + (sid * 10))) {
194 if (cell_index != 0) {
195 Int32 xx = (new_owner * 2 + current_iteration + cell_index / 10 + 17) % nb_rank;
196 if (sub_rank_divider > 0) {
197 xx = xx / sub_rank_divider;
198 xx = (xx * sub_rank_divider + new_owner) % nb_rank;
204 cells_new_owner[cell] = new_owner;
209 cells_new_owner.synchronize();
210 if (
mesh->partitionConstraintMng()) {
212 mesh->partitionConstraintMng()->computeAndApplyConstraints();
214 mesh->utilities()->changeOwnersFromCells();
This file contains the various service factories and macros for registering services.
#define ARCANE_SERVICE_INTERFACE(ainterface)
Macro to declare an interface when registering a service.
Generation de la classe de base du Service.
ArcaneMeshPartitionerTesterServiceObject(const Arcane::ServiceBuildInfo &sbi)
Constructeur.
CaseOptionsMeshPartitionerTesterService * options() const
Options du jeu de données du service.
Modifiable view of an array of type T.
Int32 globalIteration() const
Current iteration number.
Interface for registering variables for load balancing.
Interface of a mesh partitioner.
Interface of a mesh partitioner.
virtual IPrimaryMesh * toPrimaryMesh()=0
Returns the instance in the form of an IPrimaryMesh.
Interface of the parallelism manager for a subdomain.
virtual Int32 commRank() const =0
Rank of this instance in the communicator.
virtual Int32 commSize() const =0
Number of instances in the communicator.
Interface of the subdomain manager.
virtual const CommonVariables & commonVariables() const =0
Information on standard variables.
virtual IParallelMng * parallelMng()=0
Returns the parallelism manager.
Int32 owner() const
Owner subdomain number of the entity.
Mesh repartitioning test class.
void setCellsWeight(ArrayView< float > weights, Integer nb_weight) override
Allows defining the weights of objects to be partitioned: ILoadBalanceMng must now be used.
void notifyEndPartition() override
Notification when a re-partitioning finishes (after entity exchange).
Real maxImbalance() const override
Maximum allowed imbalance.
void setMaximumComputationTime(Real v) override
Sets the proportion of computation time.
void setILoadBalanceMng(ILoadBalanceMng *) override
Changes the ILoadBalanceMng to use.
void setComputationTimes(RealConstArrayView v) override
Computation time of this subdomain. The first element indicates the computation time of the subdomain...
Real imbalance() const override
Computation time imbalance.
void setImbalance(Real v) override
Sets the computation time imbalance.
IMesh * mesh() const override
Mesh associated with the partitioner.
void build() override
Build-level construction of the service.
void partitionMesh(bool initial_partition) override
void setMaxImbalance(Real v) override
Sets the maximum allowed imbalance.
Exception when a function is not implemented.
Structure containing the information to create a service.
Service creation properties.
TraceMessage info() const
Flow for an information message.
TraceMessage warning() const
Flow for a warning message.
#define ARCANE_REGISTER_SERVICE(aclass, a_service_property,...)
Macro for registering a service.
ItemVariableScalarRefT< Int32 > VariableItemInt32
32-bit integer type quantity
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
std::int64_t Int64
Signed integer type of 64 bits.
Int32 Integer
Type representing an integer.
@ ST_CaseOption
The service is used at the dataset level.
@ ST_SubDomain
The service is used at the subdomain level.
UniqueArray< Real > RealUniqueArray
Dynamic 1D array of reals.
@ IK_Cell
Cell mesh entity.
double Real
Type representing a real number.
std::int32_t Int32
Signed integer type of 32 bits.
ConstArrayView< Real > RealConstArrayView
C equivalent of a 1D array of reals.