1
/* Copyright 2008 ENSEIRB, INRIA & CNRS
1
/* Copyright 2008-2010 ENSEIRB, INRIA & CNRS
3
3
** This file is part of the Scotch software package for static mapping,
4
4
** graph partitioning and sparse matrix ordering.
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)",
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 */
123
double kbalval; /* Imbalance tolerance value */
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;
123
133
#ifdef SCOTCH_PTHREAD
124
134
int thrdlvlreqval;
125
135
int thrdlvlproval;
126
136
#endif /* SCOTCH_PTHREAD */
128
flagval = C_FLAGNONE; /* Default behavior */
138
flagval = C_FLAGNONE; /* Default behavior */
139
straval = 0; /* No strategy flags */
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);
177
kbalval = 0.01; /* Set default load imbalance value */
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 */
179
194
else { /* If found an option name */
180
195
switch (argv[i][1]) {
198
flagval |= C_FLAGKBALVAL;
199
kbalval = atof (&argv[i][2]);
200
if ((kbalval < 0.0) ||
203
((argv[i][2] != '0') && (argv[i][2] != '.')))) {
204
errorPrint ("main: invalid load imbalance ratio");
208
case 'c' : /* Strategy selection parameters */
209
for (j = 2; argv[i][j] != '\0'; j ++) {
210
switch (argv[i][j]) {
213
straval |= SCOTCH_STRATBALANCE;
217
straval |= SCOTCH_STRATQUALITY;
221
straval |= SCOTCH_STRATSPEED;
225
straval |= SCOTCH_STRATSAFETY;
229
straval |= SCOTCH_STRATSCALABILITY;
232
errorPrint ("main: invalid strategy selection option (\"%c\")", argv[i][j]);
181
236
#ifdef SCOTCH_DEBUG_ALL
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);
197
253
case 'R' : /* Root process (if necessary) */
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");
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 */
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);
353
if ((straval != 0) || ((flagval & C_FLAGKBALVAL) != 0)) {
355
errorPrint ("main: options '-b' / '-c' and '-m' are exclusive");
357
SCOTCH_stratDgraphMapBuild (&stradat, straval, (SCOTCH_Num) procglbnbr, (SCOTCH_Num) C_partNbr, kbalval);
293
360
clockStop (&runtime[0]); /* Get input time */
294
361
clockInit (&runtime[1]);
301
368
clockStart (&runtime[1]);
303
SCOTCH_dgraphMapInit (&grafdat, &mapdat, &archdat, NULL);
304
SCOTCH_dgraphMapCompute (&grafdat, &mapdat, &stradat); /* Perform mapping */
370
SCOTCH_dgraphGhst (&grafdat); /* Compute it once for good */
372
SCOTCH_dgraphMapInit (&grafdat, &mappdat, &archdat, NULL);
373
SCOTCH_dgraphMapCompute (&grafdat, &mappdat, &stradat); /* Perform mapping */
306
375
clockStop (&runtime[1]); /* Get computation time */
313
382
clockStart (&runtime[0]);
315
SCOTCH_dgraphMapSave (&grafdat, &mapdat, (proclocnum == protglbnum) ? C_filepntrmapout : NULL); /* Write mapping */
384
SCOTCH_dgraphMapSave (&grafdat, &mappdat, (proclocnum == protglbnum) ? C_filepntrmapout : NULL); /* Write mapping */
317
386
clockStop (&runtime[0]); /* Get output time */
368
437
#endif /* COMMON_MEMORY_TRACE */
370
439
if (flagval & C_FLAGVERBMAP)
371
SCOTCH_dgraphMapView (&grafdat, &mapdat, C_filepntrlogout);
440
SCOTCH_dgraphMapView (&grafdat, &mappdat, C_filepntrlogout);
373
442
fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */
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);