Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
msg_local_context.h
Go to the documentation of this file.
1#ifndef RHEO_MSG_LOCAL_CONTEXT_H
2#define RHEO_MSG_LOCAL_CONTEXT_H
23
24# include "rheolef/msg_util.h"
25namespace rheolef {
26
27/*F:
28NAME: msg_local_context -- receive pattern (@PACKAGE@ @VERSION@)
29DESCRIPTION:
30 Computes the receive compresed message local pattern,
31 i.e. the only part that does not requires communication.
32 (see "msg_to_context"(5)).
33ALGORITHM:
34 msg_local_context
35
36 "input": the index sets and the local processor index range
37 | idx(0:nidx-1), idy(0:nidx-1), istart, ilast
38 "output": the send and receive local contexts (to, from)
39 | to_loc_idx(0:n_local-1), from_loc_idy(0:n_local-1)
40 begin
41 | if n_local <> 0 then
42 | iloc := 0
43 | for k := 0 to nidx-1 do
44 | if idy(k) in (istart, ilast( then
45 | to_loc_idx(iloc) := idy(k) - istart
46 | from_loc_idy(iloc) := idy(k)
47 | iloc := iloc + 1
48 | endif
49 | endfor
50 | endif
51 end
52
53COMPLEXITY:
54 Memory and time complexity is O(receive_total_size).
55SEE ALSO: "msg_to_context"(5)
56
57METHODS: @msg_local_context
58AUTHORS:
59 LMC-IMAG, 38041 Grenoble cedex 9, France
60 | Pierre.Saramito@imag.fr
61DATE: 23 march 1999
62END:
63*/
64
65//<msg_local_context:
66template <
67 class InputIterator1,
68 class InputIterator2,
69 class Size,
70 class OutputIterator1,
71 class OutputIterator2>
72void
74 InputIterator1 idx, // nidx
75 InputIterator1 last_idx,
76 InputIterator2 idy, // nidx
77 Size idy_maxval,
78 Size istart,
79 Size ilast,
80 OutputIterator1 to_loc_idx, // n_local
81 OutputIterator1 last_to_loc_idx,
82 OutputIterator2 from_loc_idy) // n_local
83{
84 if (to_loc_idx == last_to_loc_idx) {
85 return;
86 }
87 while (idx != last_idx) {
88 Size idx_i = *idx;
89 if (idx_i >= istart && idx_i < ilast) {
90 Size idy_i = *idy;
91 assert_macro (idy_i < idy_maxval, "Scattering past end of TO vector");
92 (*to_loc_idx++) = idx_i - istart;
93 (*from_loc_idy++) = idy_i;
94 }
95 ++idx;
96 ++idy;
97 }
98}
99//>msg_local_context:
100} // namespace rheolef
101#endif // RHEO_MSG_LOCAL_CONTEXT_H
#define assert_macro(ok_condition, message)
Definition dis_macros.h:113
This file is part of Rheolef.
void msg_local_context(InputIterator1 idx, InputIterator1 last_idx, InputIterator2 idy, Size idy_maxval, Size istart, Size ilast, OutputIterator1 to_loc_idx, OutputIterator1 last_to_loc_idx, OutputIterator2 from_loc_idy)