13#ifndef ARCANE_STD_PARTITIONCONVERTER_H
14#define ARCANE_STD_PARTITIONCONVERTER_H
18#include "arcane/utils/ArrayConverter.h"
19#include "arcane/utils/ITraceMng.h"
35template <
typename TypeA,
typename TypeB>
36class PartitionConverter
41 PartitionConverter(
IParallelMng* pm = NULL,
Real max = (2 << 30),
bool check =
false)
50 m_zoomfactor.fill(1.0);
55 Integer ncon = 1,
bool check =
false)
62 computeContrib(input);
66 void reset(
Integer ncon = 1,
bool check =
false)
69 m_sum.resize(ncon + 1);
72 m_zoomfactor.resize(ncon);
78 template <
typename DataReal>
82 if (!m_check || imb.
size() < m_max.size())
86 computeContrib(input);
89 for (
int i = 0; i < m_max.size(); ++i) {
90 while (m_max[i] > imb[i] * m_sum[i] / partnum) {
101 Integer ncon = m_zoomfactor.size();
102 for (
Integer i = 0, is = input.
size(); i < is; ++i) {
103 m_sum[i % ncon] += (
Real)input[i] * multiplier;
105 m_sum[ncon] += input.
size();
109 for (
Integer i = 0, is = input.
size(); i < is; ++i) {
110 m_max[i % ncon] =
math::max((
Real)input[i] * multiplier, m_max[i % ncon]);
114 m_zoomfactor[0] = (m_maxAllowed - m_sum[ncon]) / (m_sum[0] + 1);
119 for (
Integer i = 0; i < ncon; ++i) {
120 m_zoomfactor[i] = (m_maxAllowed - m_sum[ncon]) / (m_sum[i] + 1);
123 for (
Integer i = 0; i < ncon; ++i) {
124 m_zoomfactor[i] =
math::min(1.0, m_zoomfactor[i]);
133 computeContrib(input);
134 Integer ncon = m_zoomfactor.size();
135 for (
Integer i = 0, is = input.
size(); i < is; ++i)
136 output[i] = (TypeB)((
Real)input[i] * m_zoomfactor[i % ncon]) + 1;
145 ARCANE_UNUSED(input);
146 ARCANE_UNUSED(output);
Modifiable view of an array of type T.
constexpr Integer size() const noexcept
Returns the size of the array.
Constant view of an array of type T.
constexpr Integer size() const noexcept
Number of elements in the array.
Interface of the parallelism manager for a subdomain.
1D vector of data with reference semantics.
__host__ __device__ Real2 min(Real2 a, Real2 b)
Returns the minimum of two Real2.
T max(const T &a, const T &b, const T &c)
Returns the maximum of three elements.
@ ReduceSum
Sum of values.
@ ReduceMax
Maximum of values.
-- tab-width: 2; indent-tabs-mode: nil; coding: utf-8-with-signature --
Int32 Integer
Type representing an integer.
double Real
Type representing a real number.