~chaffra/+junk/trilinos

« back to all changes in this revision

Viewing changes to packages/fei/base/fei_Graph_Impl.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Christophe Prud'homme, Christophe Prud'homme, Johannes Ring
  • Date: 2009-12-13 12:53:22 UTC
  • mfrom: (5.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091213125322-in0nrdjc55deqsw9
Tags: 10.0.3.dfsg-1
[Christophe Prud'homme]
* New upstream release

[Johannes Ring]
* debian/patches/libname.patch: Add prefix 'libtrilinos_' to all
  libraries. 
* debian/patches/soname.patch: Add soversion to libraries.
* debian/watch: Update download URL.
* debian/control:
  - Remove python-numeric from Build-Depends (virtual package).
  - Remove automake and autotools from Build-Depends and add cmake to
    reflect switch to CMake.
  - Add python-support to Build-Depends.
* debian/rules: 
  - Cleanup and updates for switch to CMake.

Show diffs side-by-side

added added

removed removed

Lines of Context:
10
10
 
11
11
#include <fei_Graph_Impl.hpp>
12
12
#include <fei_EqnComm.hpp>
 
13
#include <fei_CommUtils.hpp>
13
14
#include <fei_TemplateUtils.hpp>
14
15
#include <fei_VectorSpace.hpp>
15
16
 
18
19
#include <fei_ErrMacros.hpp>
19
20
 
20
21
//----------------------------------------------------------------------------
21
 
fei::Graph_Impl::Graph_Impl(fei::SharedPtr<snl_fei::CommUtils<int> > commUtils,
22
 
                      int firstLocalRow,
23
 
                      int lastLocalRow)
 
22
fei::Graph_Impl::Graph_Impl(MPI_Comm comm, int firstLocalRow, int lastLocalRow)
24
23
  : localGraphData_(NULL),
25
24
    remoteGraphData_(),
26
25
    eqnComm_(),
27
26
    firstLocalRow_(firstLocalRow),
28
27
    lastLocalRow_(lastLocalRow),
29
 
    localProc_(commUtils->localProc()),
30
 
    numProcs_(commUtils->numProcs()),
31
 
    commUtils_(commUtils)
 
28
    localProc_(0),
 
29
    numProcs_(1),
 
30
    comm_(comm)
32
31
{
 
32
  localProc_ = fei::localProc(comm_);
 
33
  numProcs_  = fei::numProcs(comm_);
33
34
  //for remoteGraphData_, we don't know what the range of row-numbers will
34
35
  //be, so we'll just construct it with -1,-1
35
36
  remoteGraphData_.resize(numProcs_);
36
37
  for(int p=0; p<numProcs_; ++p) {
37
38
    remoteGraphData_[p] = new remote_table_type(-1, -1);
38
39
  }
39
 
  eqnComm_.reset(new fei::EqnComm(commUtils_->getCommunicator(),
40
 
                               lastLocalRow-firstLocalRow+1));
 
40
  eqnComm_.reset(new fei::EqnComm(comm_, lastLocalRow-firstLocalRow+1));
41
41
  localGraphData_       = new table_type(firstLocalRow_, lastLocalRow_);
42
42
}
43
43
 
51
51
}
52
52
 
53
53
//----------------------------------------------------------------------------
54
 
int fei::Graph_Impl::addIndices(int row, int len, int* indices)
 
54
int fei::Graph_Impl::addIndices(int row, int len, const int* indices)
55
55
{
56
56
  if (row < 0) {
57
57
    return(-1);
119
119
    for(i=0; i<numIndices; ++i) {
120
120
      int ind = indices[i];
121
121
      if (ind < 0) {
122
 
        throw fei::Exception("fei::Graph_Impl::addDiagonals given negative index");
 
122
        throw std::runtime_error("fei::Graph_Impl::addDiagonals given negative index");
123
123
      }
124
124
 
125
125
      bool local = true;
213
213
 
214
214
  //now we can find out which procs we'll be receiving from.
215
215
  std::vector<int> recvProcs;
216
 
  commUtils_->mirrorProcs(sendProcs, recvProcs);
 
216
  fei::mirrorProcs(comm_, sendProcs, recvProcs);
217
217
 
218
218
  //next we'll declare arrays to receive into.
219
219
  std::vector<std::vector<int> > recv_ints(recvProcs.size());
223
223
  std::vector<MPI_Request> mpiReqs(recvProcs.size());
224
224
  std::vector<MPI_Status> mpiStatuses(recvProcs.size());
225
225
 
226
 
  int tag1 = 20070503;
 
226
  int tag1 = 11113;
227
227
 
228
228
  unsigned offset = 0;
229
229
  for(unsigned i=0; i<recvProcs.size(); ++i) {
230
230
    MPI_Irecv(&recv_sizes[i], 1, MPI_INT, recvProcs[i],
231
 
              tag1, commUtils_->getCommunicator(), &mpiReqs[i]);
 
231
              tag1, comm_, &mpiReqs[i]);
232
232
  }
233
233
 
234
234
  //now we'll pack our to-be-sent data into buffers, and send the
242
242
 
243
243
    int isize = send_ints[i].size();
244
244
 
245
 
    MPI_Send(&isize, 1, MPI_INT, proc, tag1, commUtils_->getCommunicator());
 
245
    MPI_Send(&isize, 1, MPI_INT, proc, tag1, comm_);
246
246
  }
247
247
 
248
 
  MPI_Waitall(mpiReqs.size(), &mpiReqs[0], &mpiStatuses[0]);
 
248
  if (mpiReqs.size() > 0) {
 
249
    MPI_Waitall(mpiReqs.size(), &mpiReqs[0], &mpiStatuses[0]);
 
250
  }
249
251
 
250
252
  //now resize our recv buffers, and post the recvs.
251
 
  for(unsigned i=0; i<recvProcs.size(); ++i) {
 
253
  for(size_t i=0; i<recvProcs.size(); ++i) {
252
254
    int intsize = recv_sizes[i];
253
255
 
254
256
    recv_ints[i].resize(intsize);
255
257
 
256
258
    MPI_Irecv(&(recv_ints[i][0]), intsize, MPI_INT, recvProcs[i],
257
 
              tag1, commUtils_->getCommunicator(), &mpiReqs[i]);
 
259
              tag1, comm_, &mpiReqs[i]);
258
260
  }
259
261
 
260
262
  //now send our packed buffers.
261
 
  for(unsigned i=0; i<sendProcs.size(); ++i) {
 
263
  for(size_t i=0; i<sendProcs.size(); ++i) {
262
264
    int proc = sendProcs[i];
263
265
 
264
266
    MPI_Send(&(send_ints[i][0]), send_ints[i].size(), MPI_INT,
265
 
             proc, tag1, commUtils_->getCommunicator());
 
267
             proc, tag1, comm_);
266
268
  }
267
269
 
268
 
  MPI_Waitall(mpiReqs.size(), &mpiReqs[0], &mpiStatuses[0]);
 
270
  if (mpiReqs.size() > 0) {
 
271
    MPI_Waitall(mpiReqs.size(), &mpiReqs[0], &mpiStatuses[0]);
 
272
  }
269
273
 
270
274
  for(unsigned i=0; i<recvProcs.size(); ++i) {
271
275
    std::vector<int> recvdata = recv_ints[i];