Rheolef  7.2
an efficient C++ finite element environment
 
Loading...
Searching...
No Matches
msg_from_context_indices.h
Go to the documentation of this file.
1#ifndef RHEO_MSG_FROM_CONTEXT_INDICES_H
2#define RHEO_MSG_FROM_CONTEXT_INDICES_H
23
24# include "rheolef/msg_util.h"
25namespace rheolef {
26
27/*F:
28NAME: msg_from_context_indices -- gather (@PACKAGE@ @VERSION@)
29DESCRIPTION:
30 Computes the receive compressed message pattern for gather
31 and scatter.
32 Suppose indexes are sorted by increasing order.
33ALGORITHM:
34 msg_from_context_indices
35
36 "input": the owner and indice arrays, the current process
37 | owner(0:nidx-1), idy(0:nidx-1),
38 | proc2from_proc(0:nproc-1), my_proc
39 "input-output": the pointer array, used for accumulation
40 | ptr(0:nidx)
41 "output": the receive context (from) indice array
42 | from_idx(0:nidx-1)
43 begin
44 | for k := 0 to nidx-1 do
45 | iproc := owner(k)
46 | if iproc <> my_proc then
47 | i := proc2from_proc(iproc)
48 | p := ptr(i)
49 | ptr(i) := p + 1
50 | from_idx(p) := idy(k)
51 | endif
52 | endfor
53 end
54COMPLEXITY:
55 Complexity is O(nidx).
56TODO:
57 Uses input iterators.
58METHODS: @msg_from_context_indices
59AUTHORS:
60 LMC-IMAG, 38041 Grenoble cedex 9, France
61 | Pierre.Saramito@imag.fr
62DATE: 6 january 1999
63END:
64*/
65
66//<msg_from_context_indices:
67template <
68 class InputIterator1,
69 class InputIterator2,
70 class InputRandomIterator,
71 class Proc,
72 class Size,
73 class MutableRandomIterator,
74 class OutputIterator>
75void
77 InputIterator1 owner, // nidx
78 InputIterator1 last_owner,
79 InputIterator2 idy, // nidx
80 InputRandomIterator proc2from_proc, // nproc
81 Proc my_proc,
82 Size idy_maxval,
83 MutableRandomIterator ptr, // send_nproc+1
84 OutputIterator from_idx) // nidx
85{
86 Size nidx = distance(owner,last_owner);
87 for (Size i = 0; i < nidx; i++) {
88 if (owner[i] != my_proc) {
89 assert_macro (idy[i] < idy_maxval, "Scattering past end of TO vector: idy="
90 << idy[i] << " out of range 0.." << idy_maxval-1);
91 Size p = ptr[proc2from_proc[owner[i]]]++;
92 from_idx[p] = idy[i];
93 }
94 }
95}
96//>msg_from_context_indices:
97} // namespace rheolef
98#endif // RHEO_MSG_FROM_CONTEXT_INDICES_H
#define assert_macro(ok_condition, message)
Definition dis_macros.h:113
This file is part of Rheolef.
void msg_from_context_indices(InputIterator1 owner, InputIterator1 last_owner, InputIterator2 idy, InputRandomIterator proc2from_proc, Proc my_proc, Size idy_maxval, MutableRandomIterator ptr, OutputIterator from_idx)
Definition sphere.icc:25