14#include "arcane/utils/TraceAccessor.h"
15#include "arcane/utils/FatalErrorException.h"
17#include "arcane/core/IParallelMng.h"
18#include "arcane/core/parallel/BitonicSort.h"
29template <
typename KeyType,
typename KeyTypeTraits> BitonicSort<KeyType, KeyTypeTraits>::
30BitonicSort(IParallelMng* parallel_mng)
31: TraceAccessor(parallel_mng->traceMng())
32, m_parallel_mng(parallel_mng)
39template <
typename KeyType,
typename KeyTypeTraits>
void BitonicSort<KeyType, KeyTypeTraits>::
40_init(ConstArrayView<KeyType> keys)
42 m_init_size = keys.size();
46 m_size = m_parallel_mng->reduce(Parallel::ReduceMax, m_init_size);
48 m_keys.resize(m_size);
49 m_key_ranks.resize(m_size);
50 m_key_indexes.resize(m_size);
52 Int32 rank = m_parallel_mng->commRank();
56 for (Integer i = 0; i < m_init_size; ++i) {
59 m_key_ranks[i] = rank;
64 KeyType max_value = KeyTypeTraits::maxValue();
65 for (
Int64 i = m_init_size; i < m_size; i++) {
66 m_keys[i] = max_value;
67 m_key_indexes[i] = -1;
68 m_key_ranks[i] = rank;
85template <
typename KeyType,
typename KeyTypeTraits>
void
93 info() <<
"BITONIC_SORT (64bit) want_rank?=" << m_want_index_and_rank
95 <<
" memsize=" <<
sizeof(
KeyType) * m_size
96 <<
" structsize=" <<
sizeof(
KeyType);
104 Int32 nb_rank = m_parallel_mng->commSize();
105 while (nb_rank > test) {
117 _mergeLevels(
jproc, size);
125 for (Integer i = 0; i < m_size; ++i) {
126 if (!KeyTypeTraits::isValid(m_keys[i])) {
132 info() <<
"END_BITONIC_SORT nb_merge=" << m_nb_merge;
134 m_keys.resize(m_size);
135 m_key_ranks.resize(m_size);
136 m_key_indexes.resize(m_size);
151template <
typename KeyType,
typename KeyTypeTraits>
void
156 for (Int32 i = 0; i < size / 2; ++i)
157 _mergeProcessors(begin + i, begin + size - 1 - i);
179 for (Int32 i = 0; i < size / 2; ++i)
180 _mergeProcessors(begin + i, begin + i + size / 2);
205 Int32
my_rank = m_parallel_mng->commRank();
207 if (
iproc2 >= m_parallel_mng->commSize())
216 info() <<
"SORT iproc1=" <<
iproc1 <<
" iproc2=" <<
iproc2;
231 requests.add(m_parallel_mng->send(m_key_indexes,
iproc1,
false));
232 requests.add(m_parallel_mng->send(m_key_ranks,
iproc1,
false));
235 requests.add(KeyTypeTraits::recv(m_parallel_mng,
iproc1, m_keys));
237 requests.add(m_parallel_mng->recv(m_key_indexes,
iproc1,
false));
238 requests.add(m_parallel_mng->recv(m_key_ranks,
iproc1,
false));
240 m_parallel_mng->waitAllRequests(requests);
268 buf2.add(KeyTypeTraits::maxValue());
282 <<
" proc2=" <<
iproc2 <<
" init-size=" << m_init_size;
325 for (Integer i = 0; i <
buf_size; i++) {
351 Int64 l = m_size / 2;
352 Int64
ir = m_size - 1;
371 m_keys[
ir] = m_keys[0];
372 m_key_indexes[
ir] = m_key_indexes[0];
373 m_key_ranks[
ir] = m_key_ranks[0];
385 if (
j <
ir && KeyTypeTraits::compareLess(m_keys[
j], m_keys[
j + 1]))
387 if (KeyTypeTraits::compareLess(
rra, m_keys[
j])) {
388 m_keys[i] = m_keys[
j];
389 m_key_indexes[i] = m_key_indexes[
j];
390 m_key_ranks[i] = m_key_ranks[
j];
#define ARCANE_FATAL(...)
Macro envoyant une exception FatalErrorException.
Lecteur des fichiers de maillage via la bibliothèque LIMA.
Algorithme de tri bitonique parallèle.
Vecteur 1D de données avec sémantique par valeur (style STL).
Implémentation de la concurrence.