Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
msg_local_optimize.h
Go to the documentation of this file.
1#ifndef RHEO_MSG_LOCAL_OPTIMIZE_H
2#define RHEO_MSG_LOCAL_OPTIMIZE_H
23
24# include "rheolef/msg_util.h"
25namespace rheolef {
26
27/*F:
28NAME: msg_local_optimize -- local scatter optimize (@PACKAGE@ @VERSION@)
29DESCRIPTION:
30 Optimize local exchanges during gatter/scatter.
31ALGORITHM:
32 msg_local_optimize
33
34 "input": the send and receive local contexts (to, from)
35 | to_loc_idx(0:n_local-1), from_loc_idy(0:n_local-1)
36 "output": the boolean, true when optimization is possible
37 | has_opt
38 begin
39 | if n_local = 0 then
40 | has_opt := false
41 | else
42 | to_start := to_loc_idx(0)
43 | from_start := from_loc_idy(0)
44 | has_opt := true
45 | i := 1
46 | while i < n_local and has_opt do
47 | to_start := to_start + 1
48 | from_start := from_start + 1
49 | if to_loc_idx(i) <> to_start
50 | or from_loc_idy(i) <> from_start then
51 | has_opt := false
52 | endif
53 | i := i + 1
54 | endwhile
55 | endif
56 end
57
58COMPLEXITY:
59 Memory and time complexity is O(receive_total_size).
60SEE ALSO: "msg_to_context"(5)
61
62METHODS: @msg_local_optimize
63AUTHORS:
64 LMC-IMAG, 38041 Grenoble cedex 9, France
65 | Pierre.Saramito@imag.fr
66DATE: 23 march 1999
67END:
68*/
69
70//<msg_local_optimize:
71template <
72 class InputIterator1,
73 class InputIterator2>
74bool
76 InputIterator1 to_loc_idx, // n_local
77 InputIterator1 last_to_loc_idx,
78 InputIterator2 from_loc_idy) // n_local
79{
80 typedef typename std::iterator_traits<InputIterator1>::value_type Size;
81 if (to_loc_idx == last_to_loc_idx) {
82 return false;
83 }
84 Size to_start = *to_loc_idx++;
85 Size from_start = *from_loc_idy++;
86 bool has_opt = true;
87 while (to_loc_idx != last_to_loc_idx && has_opt) {
88 to_start++;
89 from_start++;
90 if ((*to_loc_idx++) != to_start ||
91 (*from_loc_idy++) != from_start) {
92 has_opt = false;
93 }
94 }
95 return has_opt;
96}
97//>msg_local_optimize:
98} // namespace rheolef
99#endif // RHEO_MSG_LOCAL_OPTIMIZE_H
This file is part of Rheolef.
bool msg_local_optimize(InputIterator1 to_loc_idx, InputIterator1 last_to_loc_idx, InputIterator2 from_loc_idy)