Rheolef  7.1
an efficient C++ finite element environment
msg_to_context.h
Go to the documentation of this file.
1 #ifndef RHEO_MSG_TO_CONTEXT_H
2 #define RHEO_MSG_TO_CONTEXT_H
3 
24 # include "rheolef/msg_util.h"
25 namespace rheolef {
26 
27 /*F:
28 NAME: msg_to_context -- receive pattern (@PACKAGE@ @VERSION@)
29 DESCRIPTION:
30  Computes the receive compresed message pattern for gather
31  and scatter.
32  The local message part is computed by a separate algorithm
33  (see "msg_to_local_context"(5)).
34 ALGORITHM:
35  msg_to_context
36 
37  "input": the receive pattern and the permutation
38  | perm(0:receive_nproc-1)
39  | r_iproc(0:receive_nproc-1), r_size(0:receive_nproc-1),
40  | r_idx(0:receive_nproc*receive_max_size-1)
41  "output": the receive context (to)
42  | to_proc(0:receive_nproc-1), to_ptr(0:receive_nproc),
43  | to_idx(0:receive_total_size-1)
44  begin
45  | to_ptr(0) := 0
46  | for j := 0 to receive_nproc-1 do
47  | j1 := perm(j)
48  | to_proc(j) := r_iproc(j1)
49  | to_ptr(j+1) := r_ptr(j) + rsize(j1)
50  | for q := to_ptr(j) to to_tr(j+1)-1 do
51  | to_idx(q) := r_idx(j1, q-to_ptr(j)) - istart
52  | endfor
53  | endfor
54  end
55 
56 COMPLEXITY:
57  Memory and time complexity is O(receive_total_size).
58 
59 METHODS: @msg_to_context
60 AUTHORS:
61  LMC-IMAG, 38041 Grenoble cedex 9, France
62  | Pierre.Saramito@imag.fr
63 DATE: 23 march 1999
64 END:
65 */
66 
67 //<msg_to_context:
68 template <
69  class InputIterator1,
70  class InputRandomIterator2,
71  class InputRandomIterator3,
72  class InputRandomIterator4,
73  class Size,
74  class OutputIterator1,
75  class OutputIterator2,
76  class OutputIterator3>
77 void
79  InputIterator1 perm, // receive_nproc
80  InputIterator1 last_perm,
81  InputRandomIterator2 r_iproc, // receive_nproc
82  InputRandomIterator3 r_size, // receive_nproc
83  InputRandomIterator4 r_idx, // receive_nproc*receive_max_size
84  Size receive_max_size,
85  Size istart,
86  OutputIterator1 to_proc, // receive_nproc
87  OutputIterator2 to_ptr, // receive_nproc+1
88  OutputIterator3 to_idx) // receive_total_size
89 {
90  OutputIterator2 prec_ptr = to_ptr;
91  (*to_ptr++) = 0;
92  while (perm != last_perm) {
93  Size j1 = (*perm++);
94  (*to_proc++) = r_iproc[j1];
95  Size size = r_size[j1];
96  (*to_ptr++) = (*prec_ptr++) + size;
97  InputRandomIterator4 iter_idx = r_idx + j1*receive_max_size;
98  InputRandomIterator4 last_idx = iter_idx + size;
99  while (iter_idx != last_idx)
100  (*to_idx++) = (*iter_idx++) - istart;
101  }
102 }
103 
104 //>msg_to_context:
105 } // namespace rheolef
106 #endif // RHEO_MSG_TO_CONTEXT_H
rheolef::msg_to_context
void msg_to_context(InputIterator1 perm, InputIterator1 last_perm, InputRandomIterator2 r_iproc, InputRandomIterator3 r_size, InputRandomIterator4 r_idx, Size receive_max_size, Size istart, OutputIterator1 to_proc, OutputIterator2 to_ptr, OutputIterator3 to_idx)
Definition: msg_to_context.h:78
rheolef
This file is part of Rheolef.
Definition: compiler_eigen.h:37