Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
msg_from_context_pattern.h
Go to the documentation of this file.
1#ifndef RHEO_MSG_FROM_CONTEXT_PATTERN_H
2#define RHEO_MSG_FROM_CONTEXT_PATTERN_H
23
24# include "rheolef/msg_util.h"
25namespace rheolef {
26
27/*F:
28NAME: msg_from_context -- gather (@PACKAGE@ @VERSION@)
29DESCRIPTION:
30 Computes the receive compressed message pattern for gather
31 and scatter.
32ALGORITHM:
33 msg_from_context_pattern
34
35 "input": the ownership distribution and the indexes arrays
36 | msg_size(0:nproc)
37 "output": the receive context (from) and an auxilliary array proc2from_proc
38 | from_proc(0:send_nproc-1), from_ptr(0:send_nproc),
39 | proc2from_proc(0:nproc-1)
40 begin
41 | i := 0
42 | from_ptr(0) := 0
43 | for iproc := 0 to nproc-1 do
44 | if msg_size(iproc) <> 0 then
45 | from_proc(i) := iproc
46 | from_ptr(i+1) := from_ptr(i) + msg_size(i)
47 | proc2from_proc(iproc) := i
48 | i := i+1
49 | endif
50 | endfor
51 end
52NOTE:
53 At the end of the algorithm, we have i = send_nproc.
54COMPLEXITY:
55 Complexity is O(nproc).
56
57METHODS: @msg_from_context_pattern
58AUTHORS:
59 LMC-IMAG, 38041 Grenoble cedex 9, France
60 | Pierre.Saramito@imag.fr
61DATE: 6 january 1999
62END:
63*/
64
65//<msg_from_context_pattern:
66template <
67 class InputIterator1,
68 class OutputIterator1,
69 class OutputIterator2,
70 class OutputIterator3>
71void
73 InputIterator1 msg_size, // nproc
74 InputIterator1 last_msg_size,
75 OutputIterator1 from_proc, // send_nproc
76 OutputIterator2 from_ptr, // send_nproc+1
77 OutputIterator3 proc2from_proc) // nproc
78{
79 typedef typename std::iterator_traits<InputIterator1>::value_type Size;
80 Size iproc = 0;
81 Size i = 0;
82 Size ptr_val = 0;
83 (*from_ptr++) = ptr_val;
84 while (msg_size != last_msg_size) {
85 Size sz = (*msg_size++);
86 if (sz != 0) {
87 (*from_proc++) = iproc;
88 ptr_val += sz;
89 (*from_ptr++) = ptr_val;
90 (*proc2from_proc) = i;
91 i++;
92 }
93 proc2from_proc++;
94 iproc++;
95 }
96}
97//>msg_from_context_pattern:
98} // namespace rheolef
99#endif // RHEO_MSG_FROM_CONTEXT_PATTERN_H
This file is part of Rheolef.
void msg_from_context_pattern(InputIterator1 msg_size, InputIterator1 last_msg_size, OutputIterator1 from_proc, OutputIterator2 from_ptr, OutputIterator3 proc2from_proc)