~ubuntu-branches/ubuntu/trusty/scotch/trusty-proposed

« back to all changes in this revision

Viewing changes to src/scotch/dgmap.c

  • Committer: Bazaar Package Importer
  • Author(s): "Adam C. Powell, IV", Christophe Trophime, Adam C. Powell, IV
  • Date: 2010-12-29 13:07:19 UTC
  • mfrom: (1.1.6 upstream)
  • Revision ID: james.westby@ubuntu.com-20101229130719-jwalolw5d6av6wqx
Tags: 5.1.11.dfsg-1
[Christophe Trophime]
* New upstream release
* Forward-ported patches to version 5.1.10b.
* Install scotch headers properly.
* Fix chrpath commands in debian/rules.
* Fix (pt)scotch library install paths.
* Fix lintian errors and warnings.

[Adam C. Powell, IV]
* Forward-ported patches to version 5.1.11.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/* Copyright 2008 ENSEIRB, INRIA & CNRS
 
1
/* Copyright 2008-2010 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.
42
42
/**   DATES      : # Version 5.0  : from : 12 jun 2008     **/
43
43
/**                                 to   : 28 aug 2008     **/
44
44
/**                # Version 5.1  : from : 26 oct 2008     **/
45
 
/**                                 to   : 22 nov 2008     **/
 
45
/**                                 to   : 28 aug 2010     **/
46
46
/**                                                        **/
47
47
/************************************************************/
48
48
 
78
78
static const char *         C_usageList[] = {     /* Usage */
79
79
  "dgmap [<input source file> [<input target file> [<output mapping file> [<output log file>]]]] <options>",
80
80
  "dgpart [<nparts>] [<input source file> [<output mapping file> [<output log file>]]] <options>",
 
81
  "  -b<val>    : Load imbalance tolerance (default: 0.01)",
 
82
  "  -c<opt>    : Choose default mapping strategy according to one or several of <opt>:",
 
83
  "                 b  : enforce load balance as much as possible",
 
84
  "                 q  : privilege quality over speed (default)",
 
85
  "                 s  : privilege speed over quality",
 
86
  "                 t  : enforce safety",
 
87
  "                 x  : enforce scalability",
81
88
  "  -h         : Display this help",
82
89
  "  -m<strat>  : Set parallel mapping strategy (see user's manual)",
83
90
  "  -r<num>    : Set root process for centralized files (default is 0)",
105
112
int                         argc,
106
113
char *                      argv[])
107
114
{
108
 
  SCOTCH_Dgraph       grafdat;                    /* Source graph            */
109
 
  SCOTCH_Num          grafflag;                   /* Source graph properties */
110
 
  SCOTCH_Arch         archdat;                    /* Target architecture     */
111
 
  SCOTCH_Strat        stradat;                    /* Mapping strategy        */
112
 
  SCOTCH_Dmapping     mapdat;                     /* Mapping data            */
 
115
  SCOTCH_Dgraph       grafdat;                    /* Source graph              */
 
116
  SCOTCH_Num          grafflag;                   /* Source graph properties   */
 
117
  SCOTCH_Arch         archdat;                    /* Target architecture       */
 
118
  SCOTCH_Dmapping     mappdat;                    /* Mapping data              */
 
119
  SCOTCH_Strat        stradat;                    /* Mapping strategy          */
 
120
  SCOTCH_Num          straval;
 
121
  char *              straptr;
 
122
  int                 flagval;
 
123
  double              kbalval;                    /* Imbalance tolerance value */
113
124
  int                 procglbnbr;
114
125
  int                 proclocnum;
115
 
  int                 protglbnum;                 /* Root process        */
116
 
  Clock               runtime[2];                 /* Timing variables    */
117
 
  double              reduloctab[12];             /* 3 * (min, max, sum) */
 
126
  int                 protglbnum;                 /* Root process              */
 
127
  Clock               runtime[2];                 /* Timing variables          */
 
128
  double              reduloctab[12];             /* 3 * (min, max, sum)       */
118
129
  double              reduglbtab[12];
119
130
  MPI_Datatype        redutype;
120
131
  MPI_Op              reduop;
121
 
  int                 flagval;
122
132
  int                 i, j;
123
133
#ifdef SCOTCH_PTHREAD
124
134
  int                 thrdlvlreqval;
125
135
  int                 thrdlvlproval;
126
136
#endif /* SCOTCH_PTHREAD */
127
137
 
128
 
  flagval = C_FLAGNONE;                           /* Default behavior */
 
138
  flagval = C_FLAGNONE;                           /* Default behavior  */
 
139
  straval = 0;                                    /* No strategy flags */
 
140
  straptr = NULL;
 
141
 
129
142
  i = strlen (argv[0]);
130
143
  if ((i >= 5) && (strncmp (argv[0] + i - 5, "gpart", 5) == 0)) {
131
144
    flagval |= C_FLAGPART;
161
174
  grafflag = 0;                                   /* Use vertex and edge weights */
162
175
  SCOTCH_stratInit (&stradat);
163
176
 
 
177
  kbalval = 0.01;                                 /* Set default load imbalance value */
 
178
 
164
179
  for (i = 0; i < C_FILENBR; i ++)                /* Set default stream pointers */
165
180
    C_fileTab[i].pntr = (C_fileTab[i].mode[0] == 'r') ? stdin : stdout;
166
181
  for (i = 1; i < argc; i ++) {                   /* Loop for all option codes                        */
178
193
    }
179
194
    else {                                        /* If found an option name */
180
195
      switch (argv[i][1]) {
 
196
        case 'B' :
 
197
        case 'b' :
 
198
          flagval |= C_FLAGKBALVAL;
 
199
          kbalval = atof (&argv[i][2]);
 
200
          if ((kbalval < 0.0) ||
 
201
              (kbalval > 1.0) ||
 
202
              ((kbalval == 0.0) &&
 
203
               ((argv[i][2] != '0') && (argv[i][2] != '.')))) {
 
204
            errorPrint ("main: invalid load imbalance ratio");
 
205
          }
 
206
          break;
 
207
        case 'C' :
 
208
        case 'c' :                                /* Strategy selection parameters */
 
209
          for (j = 2; argv[i][j] != '\0'; j ++) {
 
210
            switch (argv[i][j]) {
 
211
              case 'B' :
 
212
              case 'b' :
 
213
                straval |= SCOTCH_STRATBALANCE;
 
214
                break;
 
215
              case 'Q' :
 
216
              case 'q' :
 
217
                straval |= SCOTCH_STRATQUALITY;
 
218
                break;
 
219
              case 'S' :
 
220
              case 's' :
 
221
                straval |= SCOTCH_STRATSPEED;
 
222
                break;
 
223
              case 'T' :
 
224
              case 't' :
 
225
                straval |= SCOTCH_STRATSAFETY;
 
226
                break;
 
227
              case 'X' :
 
228
              case 'x' :
 
229
                straval |= SCOTCH_STRATSCALABILITY;
 
230
                break;
 
231
              default :
 
232
                errorPrint ("main: invalid strategy selection option (\"%c\")", argv[i][j]);
 
233
            }
 
234
          }
 
235
          break;
181
236
#ifdef SCOTCH_DEBUG_ALL
182
237
        case 'D' :
183
238
        case 'd' :
190
245
          return     (0);
191
246
        case 'M' :
192
247
        case 'm' :
 
248
          straptr = &argv[i][2];
193
249
          SCOTCH_stratExit (&stradat);
194
250
          SCOTCH_stratInit (&stradat);
195
 
          SCOTCH_stratDgraphMap (&stradat, &argv[i][2]);
 
251
          SCOTCH_stratDgraphMap (&stradat, straptr);
196
252
          break;
197
253
        case 'R' :                                /* Root process (if necessary) */
198
254
        case 'r' :
220
276
          }
221
277
          break;
222
278
        case 'V' :
223
 
          fprintf (stderr, "dgmap/dgpart, version %s - F. Pellegrini\n", SCOTCH_VERSION);
224
 
          fprintf (stderr, "Copyright 2008 ENSEIRB, INRIA & CNRS, France\n");
 
279
          fprintf (stderr, "dgmap/dgpart, version " SCOTCH_VERSION_STRING "\n");
 
280
          fprintf (stderr, "Copyright 2008-2010 ENSEIRB, INRIA & CNRS, France\n");
225
281
          fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n");
226
282
          return  (0);
227
283
        case 'v' :                                /* Output control info */
287
343
  SCOTCH_archInit (&archdat);                     /* Create architecture structure          */
288
344
  if ((flagval & C_FLAGPART) != 0)                /* If program run as the partitioner      */
289
345
    SCOTCH_archCmplt (&archdat, C_partNbr);       /* Create a complete graph of proper size */
290
 
  else
 
346
  else {
 
347
    if (C_filepntrtgtinp == NULL)
 
348
      errorPrint ("main: target architecture file not provided");
291
349
    SCOTCH_archLoad (&archdat, C_filepntrtgtinp); /* Read target architecture */
 
350
    C_partNbr = SCOTCH_archSize (&archdat);
 
351
  }
 
352
 
 
353
  if ((straval != 0) || ((flagval & C_FLAGKBALVAL) != 0)) {
 
354
    if (straptr != NULL)
 
355
      errorPrint ("main: options '-b' / '-c' and '-m' are exclusive");
 
356
 
 
357
    SCOTCH_stratDgraphMapBuild (&stradat, straval, (SCOTCH_Num) procglbnbr, (SCOTCH_Num) C_partNbr, kbalval);
 
358
  }
292
359
 
293
360
  clockStop (&runtime[0]);                        /* Get input time */
294
361
  clockInit (&runtime[1]);
300
367
 
301
368
  clockStart (&runtime[1]);
302
369
 
303
 
  SCOTCH_dgraphMapInit    (&grafdat, &mapdat, &archdat, NULL);
304
 
  SCOTCH_dgraphMapCompute (&grafdat, &mapdat, &stradat); /* Perform mapping */
 
370
  SCOTCH_dgraphGhst (&grafdat);                   /* Compute it once for good */
 
371
 
 
372
  SCOTCH_dgraphMapInit    (&grafdat, &mappdat, &archdat, NULL);
 
373
  SCOTCH_dgraphMapCompute (&grafdat, &mappdat, &stradat); /* Perform mapping */
305
374
 
306
375
  clockStop (&runtime[1]);                        /* Get computation time */
307
376
 
312
381
 
313
382
  clockStart (&runtime[0]);
314
383
 
315
 
  SCOTCH_dgraphMapSave (&grafdat, &mapdat, (proclocnum == protglbnum) ? C_filepntrmapout : NULL); /* Write mapping */
 
384
  SCOTCH_dgraphMapSave (&grafdat, &mappdat, (proclocnum == protglbnum) ? C_filepntrmapout : NULL); /* Write mapping */
316
385
 
317
386
  clockStop (&runtime[0]);                        /* Get output time */
318
387
 
368
437
#endif /* COMMON_MEMORY_TRACE */
369
438
  }
370
439
  if (flagval & C_FLAGVERBMAP)
371
 
    SCOTCH_dgraphMapView (&grafdat, &mapdat, C_filepntrlogout);
 
440
    SCOTCH_dgraphMapView (&grafdat, &mappdat, C_filepntrlogout);
372
441
 
373
442
  fileBlockClose (C_fileTab, C_FILENBR);          /* Always close explicitely to end eventual (un)compression tasks */
374
443
 
375
 
  SCOTCH_dgraphMapExit (&grafdat, &mapdat);
 
444
  SCOTCH_dgraphMapExit (&grafdat, &mappdat);
376
445
  SCOTCH_dgraphExit    (&grafdat);
377
446
  SCOTCH_stratExit     (&stradat);
378
447
  SCOTCH_archExit      (&archdat);