1 #ifndef _RHEOLEF_SCATTER_MESSAGE_H
2 #define _RHEOLEF_SCATTER_MESSAGE_H
27 #include "rheolef/compiler.h"
28 #ifdef _RHEOLEF_HAVE_MPI
32 template<
class Container,
bool T_is_MPI_simple = false>
33 class scatter_message {};
38 template<
class Container>
39 class scatter_message<Container,false> {
42 typedef typename Container::value_type
value_type;
43 typedef typename Container::allocator_type allocator_type;
50 std::vector<size_type> _indices;
51 std::vector<size_type> _procs;
52 std::vector<size_type> _starts;
56 const Container& values ()
const {
return _values; }
57 Container& values () {
return _values; }
58 const std::vector<size_type>& indices()
const {
return _indices; }
59 std::vector<size_type>& indices() {
return _indices; }
60 const std::vector<size_type>& procs ()
const {
return _procs; }
61 std::vector<size_type>& procs () {
return _procs; }
62 const std::vector<size_type>& starts ()
const {
return _starts; }
63 std::vector<size_type>& starts () {
return _starts; }
65 std::list<std::pair<size_type,mpi::request> > requests;
66 std::vector<mpi::status> sstatus;
68 std::vector<size_type> local_slots;
69 std::vector<size_type> local_slots_nonmatching;
70 bool local_nonmatching_computed;
78 scatter_message(
const value_type& init_value =
value_type(),
const allocator_type& alloc = allocator_type())
79 : _init_value (init_value),
87 local_slots_nonmatching(),
88 local_nonmatching_computed(false),
89 local_n_nonmatching(0),
95 _values.resize (n_data, _init_value);
96 _indices.resize (n_data);
97 _procs.resize (nproc);
98 _starts.resize (nproc+1);
100 template <
class InputIterator>
101 void load_values (InputIterator x);
103 template<
class OutputIterator,
class SetOp>
104 void store_values (OutputIterator y,
size_type i_receive, SetOp op)
const;
108 size_type n_proc()
const {
return _procs.size(); }
109 size_type n_data()
const {
return _indices.size(); }
110 size_type n_status()
const {
return sstatus.size(); }
111 size_type n_local()
const {
return local_slots.size(); }
112 size_type n_local_nonmatching()
const {
return local_slots_nonmatching.size(); }
117 template<
class Container>
118 class scatter_message<Container,true> :
public scatter_message<std::vector<typename Container::size_type>, false> {
120 typedef scatter_message<std::vector<typename Container::size_type>,
false> base;
123 typedef typename Container::value_type
value_type;
124 typedef typename value_type::value_type base_value_type;
128 std::vector<base_value_type> _multi_values;
129 std::vector<size_type> _multi_indices;
130 std::vector<size_type> _multi_procs;
131 std::vector<size_type> _multi_starts;
132 std::vector<size_type> _ptr;
133 std::vector<size_type> _multi_irecv2base_irecv;
137 const std::vector<base_value_type>& values ()
const {
return _multi_values; }
138 std::vector<base_value_type>& values () {
return _multi_values; }
140 const std::vector<size_type>& indices()
const {
return _multi_indices; }
141 std::vector<size_type>& indices() {
return _multi_indices; }
142 const std::vector<size_type>& procs ()
const {
return _multi_procs; }
143 std::vector<size_type>& procs () {
return _multi_procs; }
144 const std::vector<size_type>& starts ()
const {
return _multi_starts; }
145 std::vector<size_type>& starts () {
return _multi_starts; }
147 base& get_base() {
return *
this; }
158 _multi_irecv2base_irecv()
163 template <
class InputIterator>
164 void load_values (InputIterator x);
166 template<
class OutputIterator,
class SetOp>
167 void store_values (OutputIterator y,
size_type i_receive, SetOp op)
const;
171 size_type n_proc()
const {
return _multi_procs.size(); }
172 size_type n_data()
const {
return _multi_indices.size(); }
180 #include "rheolef/scatter_message.icc"
field::size_type size_type
This file is part of Rheolef.