1
#ifndef BOOST_PP_IS_ITERATING
2
#ifndef _RHEOLEF_POLYMORHIC_SCATTER_MESSAGE_H
3
#define _RHEOLEF_POLYMORHIC_SCATTER_MESSAGE_H
5
/// This file is part of Rheolef.
7
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
9
/// Rheolef is free software; you can redistribute it and/or modify
10
/// it under the terms of the GNU General Public License as published by
11
/// the Free Software Foundation; either version 2 of the License, or
12
/// (at your option) any later version.
14
/// Rheolef is distributed in the hope that it will be useful,
15
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
16
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
17
/// GNU General Public License for more details.
19
/// You should have received a copy of the GNU General Public License
20
/// along with Rheolef; if not, write to the Free Software
21
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
23
/// =========================================================================
25
// create distributed to sequential scatter context for polymorphic_array
27
#include "rheolef/polymorphic_data_vector.h"
31
/// @brief scatter buffer for polymorphic_array
32
template<class T, class V, int NV>
33
struct polymorphic_scatter_buffer {};
35
/// @brief scatter mesage area handler for polymorphic_array
36
template<class T, class V, int NV>
37
struct polymorphic_scatter_message {};
39
// ----------------------------------------------------------
40
// run here the recursive inclusion of this file:
41
// ----------------------------------------------------------
42
// _RHEOLEF_POLYMORPHIC_MAX_SIZE was defined by "polymorphic_data_vector.h"
43
#define BOOST_PP_ITERATION_LIMITS (0, _RHEOLEF_POLYMORPHIC_MAX_SIZE)
44
#define BOOST_PP_FILENAME_1 "rheolef/polymorphic_scatter_message.h" // this file
45
#include BOOST_PP_ITERATE()
47
} // namespace rheolef
48
#endif // _RHEOLEF_POLYMORPHIC_SCATTER_MESSAGE_H
49
#else // BOOST_PP_IS_ITERATING
50
// ----------------------------------------------------------
51
// here, this file is recursively included with growing "N" :
52
// ----------------------------------------------------------
53
#define N BOOST_PP_ITERATION()
55
template<class T, class V>
56
class polymorphic_scatter_message<T,V,N> {
58
typedef typename polymorphic_data_vector<T,V,N>::size_type size_type;
59
static const size_type _n_variant = N;
63
std::vector<boost::array<size_type,_n_variant> > start_variant; // n_proc+1
65
// not used in polymorphic case: for compatibility with msg_scatter_init generic code:
66
std::vector<size_type> starts; // n_proc+1
68
std::vector<size_type> procs; // n_proc
70
boost::array<std::list<std::pair<size_type,mpi::request> >,
71
_n_variant> requests; // n_proc
72
std::vector<size_type> indices; // n_data
74
polymorphic_data_vector<T,V,N> values; // n_data
75
std::vector<mpi::status> sstatus; // n_status
77
std::vector<size_type> local_slots; // n_local
78
std::vector<size_type> local_slots_nonmatching;
79
bool local_nonmatching_computed;// n_local_nonmatching
80
size_type local_n_nonmatching;
82
size_type local_copy_start;
83
size_type local_copy_length;
87
polymorphic_scatter_message()
96
local_slots_nonmatching(),
97
local_nonmatching_computed(false),
98
local_n_nonmatching(0),
103
void resize (size_type n_data, size_type nproc) {
104
start_variant.resize (nproc+1);
105
starts.resize (nproc+1);
106
procs.resize (nproc);
107
indices.resize (n_data);
111
size_type n_proc() const { return procs.size(); }
112
size_type n_data() const { return indices.size(); }
113
size_type n_status() const { return sstatus.size(); }
114
size_type n_local() const { return local_slots.size(); }
115
size_type n_local_nonmatching() const { return local_slots_nonmatching.size(); }
117
#endif // _RHEOLEF_POLYMORHIC_SCATTER_MESSAGE_H