This file is indexed.

/usr/include/rheolef/scatter_message.icc is in librheolef-dev 6.7-6.

This file is owned by root:root, with mode 0o644.

The actual contents of the file can be viewed below.

  1
  2
  3
  4
  5
  6
  7
  8
  9
 10
 11
 12
 13
 14
 15
 16
 17
 18
 19
 20
 21
 22
 23
 24
 25
 26
 27
 28
 29
 30
 31
 32
 33
 34
 35
 36
 37
 38
 39
 40
 41
 42
 43
 44
 45
 46
 47
 48
 49
 50
 51
 52
 53
 54
 55
 56
 57
 58
 59
 60
 61
 62
 63
 64
 65
 66
 67
 68
 69
 70
 71
 72
 73
 74
 75
 76
 77
 78
 79
 80
 81
 82
 83
 84
 85
 86
 87
 88
 89
 90
 91
 92
 93
 94
 95
 96
 97
 98
 99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
#ifndef _RHEOLEF_SCATTER_MESSAGE_ICC
#define _RHEOLEF_SCATTER_MESSAGE_ICC
///
/// This file is part of Rheolef.
///
/// Copyright (C) 2000-2009 Pierre Saramito <Pierre.Saramito@imag.fr>
///
/// Rheolef is free software; you can redistribute it and/or modify
/// it under the terms of the GNU General Public License as published by
/// the Free Software Foundation; either version 2 of the License, or
/// (at your option) any later version.
///
/// Rheolef is distributed in the hope that it will be useful,
/// but WITHOUT ANY WARRANTY; without even the implied warranty of
/// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
/// GNU General Public License for more details.
///
/// You should have received a copy of the GNU General Public License
/// along with Rheolef; if not, write to the Free Software
/// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
/// 
/// =========================================================================
//
// create distributed to sequential scatter context
// inspirated from petsc-2.0/vpscat.c: VecScatterCreate_PtoS(...)
//
#include "rheolef/compiler.h"

#ifdef _RHEOLEF_HAVE_MPI
#include "rheolef/scatter_message.h"
#include "rheolef/msg_left_permutation_apply.h"
#include "rheolef/msg_right_permutation_apply.h"

namespace rheolef {

// =================================================================================
// part 1: init
// =================================================================================
// case of multi-valued data:
// called after the scatter_message<Container,false> scatter is finished:
// => the size of each object to transmit is known
template<class Container>
void
scatter_message<Container,true>::multi_init ()
{
  // ----------------------------------------------
  // 1) count the total message size
  // ----------------------------------------------
  size_type n_data = base::n_data();
  _ptr.resize (n_data+1);
  _ptr [0] = 0;
  for (size_type i = 0; i < n_data; i++) {
    size_type size_i = base::_values [i];
    _ptr [i+1] = _ptr[i] + size_i;
  }
  size_type n_multi_data = _ptr[n_data];

  // ----------------------------------------------
  // 2) resize & fill multi_{values,indices} arrays
  // ----------------------------------------------
  _multi_values.resize  (n_multi_data);
#ifdef TO_CLEAN
  _multi_indices.resize (n_multi_data);
  typename std::vector<size_type>::const_iterator p = base::_indices.begin();
  std::vector<size_type> ip (n_data);
  for (size_type i = 0; i < n_data; i++) {
    ip[p[i]] = i;
  }
  // y[p[i]] == x[i] <==> x[ip[j]] == y[j]	
  // yptr[j]... yptr[j+1]-1 = range of multi-valued y[j]==x[i], j=p[i]
  std::vector<size_type> yptr (n_data+1);
  yptr [0] = 0;
  for (size_type j = 0; j < n_data; j++) {
    size_type size_j = base::_values [ip[j]];
    yptr[j+1] = yptr[j] + size_j;
  }
  for (size_type i = 0; i < n_data; i++) {
    size_type size_i = base::_values [i];
    size_type j = _ptr[i];
    for (size_type k = 0; k < size_i; j++) {
      _multi_indices [yptr[j]+k] = _ptr[i] + k;
    }
  }
#endif // TO_CLEAN
  // --------------------------------------------
  // 3) eliminate zero-sized multi-messages
  // --------------------------------------------
  // some values could asked for send/receive could be empty set, so 
  // the multi_nproc of send/receive could be < nproc for sizes
  // => check for empty messages, i.e. with zero-sized multi-valued containers(set,list,..)
  //    and MPI waits infinitely for empty messages to arrive...
  size_type nproc = base::_procs.size();
  std::vector<size_type> msg_size (nproc, 0);
  size_type multi_nproc = 0;
  for (size_type iproc = 0; iproc < nproc; iproc++) {
    for (size_type   i = base::_starts[iproc],
                last_i = base::_starts[iproc+1]; i < last_i; i++) {
      size_type size_i = base::_values [i];
      msg_size[iproc] += size_i;
    }
    if (msg_size[iproc] != 0) {
      multi_nproc++;
    }
  }
  // --------------------------------------------
  // 4) resize & fill multi_{procs,starts} arrays
  // --------------------------------------------
  _multi_procs.resize   (multi_nproc);
  _multi_starts.resize  (multi_nproc+1);
  _multi_irecv2base_irecv.resize  (multi_nproc);
  _multi_starts [0] = 0;
  for (size_type iproc = 0, multi_iproc = 0; iproc < nproc; iproc++) {
    if (msg_size[iproc] == 0) continue;
    _multi_procs  [multi_iproc]   = base::_procs [iproc];
    _multi_starts [multi_iproc+1] = _multi_starts [multi_iproc] + msg_size[iproc]; 
    _multi_irecv2base_irecv [multi_iproc] = iproc;
    multi_iproc++;
  }
}
// =================================================================================
// part 2: load and store
// =================================================================================
// values[i] = x[indices[i]], i=[0..n_data[
template<class Container>
template<class InputIterator>
void
scatter_message<Container,false>::load_values (InputIterator x)
{
   msg_right_permutation_apply (
     _indices.begin(),
     _indices.end(),
     x,
     _values.begin());
}
// the same with multi-valued data:
template<class Container>
template<class InputIterator>
void
scatter_message<Container,true>::load_values (InputIterator x)
{
  for (size_type i = 0, n_data = base::_indices.size(), z = 0; i < n_data; i++) {
    size_type pi = base::_indices[i];
    for (typename value_type::const_iterator first = x[pi].begin(), last = x[pi].end(); first != last; first++, z++) {
      _multi_values [z] = *first;
    }
  }
}
// y[indices[i]] = value[i], i=[start(i_recv)..starts(i_recv+1)[
template<class Container>
template<class OutputIterator, class SetOp>
void
scatter_message<Container,false>::store_values (OutputIterator y, size_type i_recv, SetOp op) const
{
  msg_left_permutation_apply (
    _values.begin()  + _starts[i_recv],
    op,
    _indices.begin() + _starts[i_recv],
    _indices.begin() + _starts[i_recv+1],
    y);
}
// the same with multi-valued data:
template<class Container>
template<class OutputIterator, class SetOp>
void
scatter_message<Container,true>::store_values (OutputIterator y, size_type i_multi_recv, SetOp op) const
{
  size_type i_recv = _multi_irecv2base_irecv [i_multi_recv];
  for (size_type i = base::_starts[i_recv], n_data = base::_starts[i_recv+1]; i < n_data; i++) {
    size_type pi = base::_indices[i];
    for (size_type z = _ptr[i], last_z = _ptr[i+1]; z < last_z; z++) {
      y[pi] += _multi_values [z];
    }
  }
}

} // namespace rheolef
#endif // _RHEOLEF_HAVE_MPI
#endif // _RHEOLEF_SCATTER_MESSAGE_ICC