~ubuntu-branches/ubuntu/precise/scotch/precise

« back to all changes in this revision

Viewing changes to src/libscotch/dgraph_ghst.c

  • Committer: Package Import Robot
  • Author(s): "Adam C. Powell, IV"
  • Date: 2011-12-21 13:40:52 UTC
  • mfrom: (14.1.7 sid)
  • Revision ID: package-import@ubuntu.com-20111221134052-1yw353l7p7zoo51d
Tags: 5.1.12b.dfsg-1
* New upstream (closes: #652900).
* Rebuild with new mpi-defaults (closes: #652311).
* Forward-ported build-fixes.patch (just shifted one hunk two lines).
* New build-arch and build-indep targets in rules.
* Updated VCS URLs.
* Bumped Standards-Version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2007-2009 ENSEIRB, INRIA & CNRS
 
1
/* Copyright 2007-2009,2011 ENSEIRB, INRIA & CNRS
2
2
**
3
3
** This file is part of the Scotch software package for static mapping,
4
4
** graph partitioning and sparse matrix ordering.
50
50
/**                # Version 5.0  : from : 28 feb 2006     **/
51
51
/**                                 to     10 sep 2007     **/
52
52
/**                # Version 5.1  : from : 02 jul 2008     **/
53
 
/**                                 to     24 apr 2009     **/
 
53
/**                                 to     20 feb 2011     **/
54
54
/**                                                        **/
55
55
/************************************************************/
56
56
 
63
63
#include "module.h"
64
64
#include "common.h"
65
65
#include "dgraph.h"
 
66
#include "dgraph_allreduce.h"
66
67
#include "dgraph_ghst.h"
67
68
#include "dgraph_halo.h"
68
69
 
80
81
** - !0  : on error.
81
82
*/
82
83
 
 
84
DGRAPHALLREDUCEMAXSUMOP (2, 1)
 
85
 
83
86
int
84
87
dgraphGhst2 (
85
88
Dgraph * restrict const     grafptr,              /* Graph structure  */
101
104
  Gnum                      sortlocnum;
102
105
  Gnum *                    edgeloctax;           /* Pointer to original edgeloctax array          */
103
106
  Gnum *                    edgegsttax;           /* Pointer to ghost edge array, maybe the same   */
104
 
  int                       reduloctab[2];
105
 
  int                       reduglbtab[2];
 
107
  Gnum                      reduloctab[3];        /* Gnum to perform a maxsum operator             */
 
108
  Gnum                      reduglbtab[3];
106
109
  int                       cheklocval;
107
110
 
108
111
  if ((grafptr->flagval & DGRAPHHASEDGEGST) != 0) /* If ghost edge array already computed, do nothing */
138
141
  }
139
142
 
140
143
  reduloctab[0] = 1;                              /* Assume memory error and prepare data for aborting */
141
 
  reduloctab[1] = 0;
 
144
  reduloctab[1] =
 
145
  reduloctab[2] = 0;
142
146
  if (cheklocval != 0) {                          /* TRICK: Processes not on error will perform collective communication at end of routine */
143
 
    if (MPI_Allreduce (reduloctab, reduglbtab, 2, MPI_INT, MPI_MAX, grafptr->proccomm) != MPI_SUCCESS)
 
147
    if (dgraphAllreduceMaxSum (reduloctab, reduglbtab, 2, 1, grafptr->proccomm) != 0) {
144
148
      errorPrint ("dgraphGhst: communication error (1)");
145
 
    return (1);
 
149
      return (1);
 
150
    }
146
151
  }
147
152
 
148
153
  vertlocmin = grafptr->procvrttab[grafptr->proclocnum];
165
170
#ifdef SCOTCH_DEBUG_DGRAPH2
166
171
      if ((vertlocend < grafptr->baseval) || (vertlocend >= (grafptr->procvrttab[grafptr->procglbnbr]))) {
167
172
        errorPrint ("dgraphGhst: invalid edge array");
168
 
        if (MPI_Allreduce (reduloctab, reduglbtab, 2, MPI_INT, MPI_MAX, grafptr->proccomm) != MPI_SUCCESS)
 
173
        if (dgraphAllreduceMaxSum (reduloctab, reduglbtab, 2, 1, grafptr->proccomm) != 0)
169
174
          errorPrint ("dgraphGhst: communication error (2)");
170
175
        memFree (procsidtab);                     /* Free group leader */
171
176
        return  (1);
231
236
        if ((procngbnum > grafptr->procglbnbr) || /* If we have skipped a neighbor to which we have to send something */
232
237
            (grafptr->procsndtab[procngbnum] != 0)) {
233
238
          errorPrint ("dgraphGhst: internal error (1)");
234
 
          if (MPI_Allreduce (reduloctab, reduglbtab, 2, MPI_INT, MPI_MAX, grafptr->proccomm) != MPI_SUCCESS)
 
239
          if (dgraphAllreduceMaxSum (reduloctab, reduglbtab, 2, 1, grafptr->proccomm) != 0)
235
240
            errorPrint ("dgraphGhst: communication error (3)");
236
241
          memFree (procsidtab);                   /* Free group leader */
237
242
          return (1);
241
246
#ifdef SCOTCH_DEBUG_DGRAPH2
242
247
      if (grafptr->procsndtab[procngbnum] == 0) { /* If we had in fact no edges to send to this neighbor */
243
248
        errorPrint ("dgraphGhst: internal error (2)");
244
 
        if (MPI_Allreduce (reduloctab, reduglbtab, 2, MPI_INT, MPI_MAX, grafptr->proccomm) != MPI_SUCCESS)
 
249
        if (dgraphAllreduceMaxSum (reduloctab, reduglbtab, 2, 1, grafptr->proccomm) != 0)
245
250
          errorPrint ("dgraphGhst: communication error (4)");
246
251
        return (1);
247
252
      }
273
278
  grafptr->procsidnbr = procsidnbr;
274
279
 
275
280
  reduloctab[0] = 0;                              /* No memory error                 */
276
 
  reduloctab[1] = grafptr->procngbnbr;            /* Set maximum number of neighbors */
277
 
  if (MPI_Allreduce (reduloctab, reduglbtab, 2, MPI_INT, MPI_MAX, grafptr->proccomm) != MPI_SUCCESS) {
 
281
  reduloctab[1] =                                 /* Set maximum number of neighbors */
 
282
  reduloctab[2] = grafptr->procngbnbr;
 
283
  if (dgraphAllreduceMaxSum (reduloctab, reduglbtab, 2, 1, grafptr->proccomm) != 0) {
278
284
    errorPrint ("dgraphGhst: communication error (5)");
279
285
    return     (1);
280
286
  }
281
287
  if (reduglbtab[0] != 0)                         /* If error, propagated by some previous reduction operator */
282
288
    return (1);
283
289
 
 
290
  grafptr->procngbmax = reduglbtab[1];
284
291
  grafptr->flagval   |= DGRAPHFREEPSID | DGRAPHHASEDGEGST; /* Graph now has a valid ghost edge array */
285
 
  grafptr->procngbmax = reduglbtab[1];
 
292
#ifndef SCOTCH_COMM_COLL
 
293
#ifndef SCOTCH_COMM_PTOP
 
294
  if (((float) reduglbtab[2]) <= ((float) grafptr->procglbnbr * (float) (grafptr->procglbnbr - 1) * (float) SCOTCH_COMM_PTOP_RAT))
 
295
#endif /* SCOTCH_COMM_PTOP */
 
296
    grafptr->flagval |= DGRAPHCOMMPTOP;           /* If too few communications, use point-to-point instead */
 
297
#endif /* SCOTCH_COMM_COLL */
286
298
 
287
299
#ifdef SCOTCH_DEBUG_DGRAPH2
288
300
  if (dgraphHaloCheck (grafptr) != 0) {