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

« back to all changes in this revision

Viewing changes to src/libscotch/library_dgraph_map.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:
40
40
/**                libSCOTCH library.                      **/
41
41
/**                                                        **/
42
42
/**   DATES      : # Version 5.1  : from : 12 jun 2008     **/
43
 
/**                                 to     29 mar 2010     **/
 
43
/**                                 to     14 aug 2010     **/
44
44
/**                                                        **/
45
45
/************************************************************/
46
46
 
68
68
/*                                  */
69
69
/************************************/
70
70
 
71
 
/*+ This routine parses the given
72
 
*** mapping strategy.
73
 
*** It returns:
74
 
*** - 0   : if string successfully scanned.
75
 
*** - !0  : on error.
76
 
+*/
77
 
 
78
 
int
79
 
SCOTCH_stratDgraphMap (
80
 
SCOTCH_Strat * const        stratptr,
81
 
const char * const          string)
82
 
{
83
 
  if (*((Strat **) stratptr) != NULL)
84
 
    stratExit (*((Strat **) stratptr));
85
 
 
86
 
  if ((*((Strat **) stratptr) = stratInit (&kdgraphmapststratab, string)) == NULL) {
87
 
    errorPrint ("SCOTCH_stratDgraphMap: error in parallel mapping strategy");
88
 
    return     (1);
89
 
  }
90
 
 
91
 
  return (0);
92
 
}
93
 
 
94
71
/*+ This routine initializes an API opaque
95
72
*** mapping with respect to the given source
96
73
*** graph and the locations of output parameters.
159
136
 
160
137
int
161
138
SCOTCH_dgraphMapCompute (
162
 
const SCOTCH_Dgraph * const grafptr,              /*+ Graph to map       +*/
 
139
SCOTCH_Dgraph * const       grafptr,              /*+ Graph to map       +*/
163
140
SCOTCH_Dmapping * const     mappptr,              /*+ Mapping to compute +*/
164
141
SCOTCH_Strat * const        stratptr)             /*+ Mapping strategy   +*/
165
142
{
167
144
  Kdmapping               mapmappdat;             /* Initial mapping domain      */
168
145
  const Strat *           mapstratptr;            /* Pointer to mapping strategy */
169
146
  LibDmapping * restrict  srcmappptr;
 
147
  Dgraph *                srcgrafptr;
170
148
  int                     o;
171
149
 
172
 
  if (*((Strat **) stratptr) == NULL)             /* Set default mapping strategy if necessary */
173
 
    *((Strat **) stratptr) = stratInit (&kdgraphmapststratab, "r{sep=m{asc=b{bnd=q{strat=f},org=q{strat=f}},low=q{strat=m{type=h,vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=b{bnd=d{dif=1,rem=1,pass=40}f{bal=0.005,move=80},org=f{bal=0.005,move=80}}}|m{type=h,vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=b{bnd=d{dif=1,rem=1,pass=40}f{bal=0.005,move=80},org=f{bal=0.005,move=80}}}},seq=q{strat=m{type=h,vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=b{bnd=d{dif=1,rem=1,pass=40}f{bal=0.005,move=80},org=f{bal=0.005,move=80}}}|m{type=h,vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=b{bnd=d{dif=1,rem=1,pass=40}f{bal=0.005,move=80},org=f{bal=0.005,move=80}}}}},seq=r{job=t,map=t,poli=S,sep=m{type=h,vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=b{bnd=d{dif=1,rem=1,pass=40}f{bal=0.005,move=80},org=f{bal=0.005,move=80}}}|m{type=h,vert=80,low=h{pass=10}f{bal=0.0005,move=80},asc=b{bnd=d{dif=1,rem=1,pass=40}f{bal=0.005,move=80},org=f{bal=0.005,move=80}}}}}");
 
150
  srcgrafptr = (Dgraph *) grafptr;
 
151
  srcmappptr = (LibDmapping *) mappptr;
 
152
 
 
153
#ifdef SCOTCH_DEBUG_DGRAPH2
 
154
  if (dgraphCheck (srcgrafptr) != 0) {
 
155
    errorPrint ("SCOTCH_dgraphMapCompute: invalid input graph");
 
156
    return     (1);
 
157
  }
 
158
#endif /* SCOTCH_DEBUG_DGRAPH2 */
 
159
 
 
160
  if (*((Strat **) stratptr) == NULL) {           /* Set default mapping strategy if necessary */
 
161
    ArchDom             archdomnorg;
 
162
 
 
163
    archDomFrst (&srcmappptr->m.archdat, &archdomnorg);
 
164
    SCOTCH_stratDgraphMapBuild (stratptr, SCOTCH_STRATQUALITY, srcgrafptr->procglbnbr, archDomSize (&srcmappptr->m.archdat, &archdomnorg), 0.01);
 
165
  }
174
166
  mapstratptr = *((Strat **) stratptr);
175
167
  if (mapstratptr->tabl != &kdgraphmapststratab) {
176
168
    errorPrint ("SCOTCH_dgraphMapCompute: not a parallel graph mapping strategy");
177
169
    return     (1);
178
170
  }
179
171
 
180
 
  srcmappptr = (LibDmapping *) mappptr;
181
 
  if (kdgraphInit (&mapgrafdat, (Dgraph *) grafptr, &srcmappptr->m) != 0)
 
172
  if (kdgraphInit (&mapgrafdat, srcgrafptr, &srcmappptr->m) != 0)
182
173
    return (1);
183
174
  mapmappdat.mappptr = &srcmappptr->m;
184
175
 
201
192
 
202
193
int
203
194
SCOTCH_dgraphMap (
204
 
const SCOTCH_Dgraph * const grafptr,              /*+ Graph to map        +*/
 
195
SCOTCH_Dgraph * const       grafptr,              /*+ Graph to map        +*/
205
196
const SCOTCH_Arch * const   archptr,              /*+ Target architecture +*/
206
197
SCOTCH_Strat * const        stratptr,             /*+ Mapping strategy    +*/
207
198
SCOTCH_Num * const          termloctab)           /*+ Mapping array       +*/
226
217
 
227
218
int
228
219
SCOTCH_dgraphPart (
229
 
const SCOTCH_Dgraph * const grafptr,              /*+ Graph to map     +*/
 
220
SCOTCH_Dgraph * const       grafptr,              /*+ Graph to map     +*/
230
221
const SCOTCH_Num            partnbr,              /*+ Number of parts  +*/
231
222
SCOTCH_Strat * const        stratptr,             /*+ Mapping strategy +*/
232
223
SCOTCH_Num * const          termloctab)           /*+ Mapping array    +*/
241
232
 
242
233
  return (o);
243
234
}
 
235
 
 
236
/*+ This routine parses the given
 
237
*** mapping strategy.
 
238
*** It returns:
 
239
*** - 0   : if string successfully scanned.
 
240
*** - !0  : on error.
 
241
+*/
 
242
 
 
243
int
 
244
SCOTCH_stratDgraphMap (
 
245
SCOTCH_Strat * const        stratptr,
 
246
const char * const          string)
 
247
{
 
248
  if (*((Strat **) stratptr) != NULL)
 
249
    stratExit (*((Strat **) stratptr));
 
250
 
 
251
  if ((*((Strat **) stratptr) = stratInit (&kdgraphmapststratab, string)) == NULL) {
 
252
    errorPrint ("SCOTCH_stratDgraphMap: error in parallel mapping strategy");
 
253
    return     (1);
 
254
  }
 
255
 
 
256
  return (0);
 
257
}
 
258
 
 
259
/*+ This routine provides predefined
 
260
*** mapping strategies.
 
261
*** It returns:
 
262
*** - 0   : if string successfully initialized.
 
263
*** - !0  : on error.
 
264
+*/
 
265
 
 
266
int
 
267
SCOTCH_stratDgraphMapBuild (
 
268
SCOTCH_Strat * const        stratptr,             /*+ Strategy to create              +*/
 
269
const SCOTCH_Num            flagval,              /*+ Desired characteristics         +*/
 
270
const SCOTCH_Num            procnbr,              /*+ Number of processes for running +*/
 
271
const SCOTCH_Num            partnbr,              /*+ Number of expected parts/size   +*/
 
272
const double                balrat)               /*+ Desired imbalance ratio         +*/
 
273
{
 
274
  char                bufftab[8192];              /* Should be enough */
 
275
  char                bbaltab[32];
 
276
  double              bbalval;
 
277
  char                verttab[32];
 
278
  Gnum                vertnbr;
 
279
  int                 parttmp;
 
280
  int                 blogval;
 
281
  double              blogtmp;
 
282
  char *              difpptr;
 
283
  char *              difsptr;
 
284
  char *              exapptr;
 
285
  char *              exasptr;
 
286
  char *              muceptr;
 
287
 
 
288
  for (parttmp = partnbr, blogval = 1; parttmp != 0; parttmp >>= 1, blogval ++) ; /* Get log2 of number of parts */
 
289
 
 
290
  vertnbr = MAX (2000 * procnbr, 10000);
 
291
  vertnbr = MIN (vertnbr, 100000);
 
292
  sprintf (verttab, GNUMSTRING, vertnbr);
 
293
 
 
294
  blogtmp = 1.0 / (double) blogval;               /* Taylor development of (1 + balrat) ^ (1 / blogval) */
 
295
  bbalval = (balrat * blogtmp) * (1.0 + (blogtmp - 1.0) * (balrat * 0.5 * (1.0 + (blogtmp - 2.0) * balrat / 3.0)));
 
296
  sprintf (bbaltab, "%lf", bbalval);
 
297
 
 
298
  strcpy (bufftab, "r{sep=m{vert=<VERT>,asc=b{bnd=<DIFP><MUCE><EXAP>,org=<MUCE><EXAP>},low=q{strat=(m{type=h,vert=80,low=h{pass=10}f{bal=<BBAL>,move=80},asc=b{bnd=<DIFS>f{bal=<BBAL>,move=80},org=f{bal=<BBAL>,move=80}}}|m{type=h,vert=80,low=h{pass=10}f{bal=<BBAL>,move=80},asc=b{bnd=<DIFS>f{bal=<BBAL>,move=80},org=f{bal=<BBAL>,move=80}}})<EXAS>},seq=q{strat=(m{type=h,vert=80,low=h{pass=10}f{bal=<BBAL>,move=80},asc=b{bnd=<DIFS>f{bal=<BBAL>,move=80},org=f{bal=<BBAL>,move=80}}}|m{type=h,vert=80,low=h{pass=10}f{bal=<BBAL>,move=80},asc=b{bnd=<DIFS>f{bal=<BBAL>,move=80},org=f{bal=<BBAL>,move=80}}})<EXAS>}},seq=r{sep=(m{type=h,vert=80,low=h{pass=10}f{bal=<BBAL>,move=80},asc=b{bnd=<DIFS>f{bal=<BBAL>,move=80},org=f{bal=<BBAL>,move=80}}}|m{type=h,vert=80,low=h{pass=10}f{bal=<BBAL>,move=80},asc=b{bnd=<DIFS>f{bal=<BBAL>,move=80},org=f{bal=<BBAL>,move=80}}})<EXAS>}}");
 
299
 
 
300
  muceptr = "/(edge<1000000)?q{strat=f};";        /* Multi-centralization */
 
301
  exapptr = "x{bal=<BBAL>}";                      /* Parallel exactifier  */
 
302
 
 
303
  if ((flagval & SCOTCH_STRATBALANCE) != 0) {
 
304
    exapptr = "x{bal=0}";
 
305
    exasptr = "f{bal=0}";
 
306
  }
 
307
  else
 
308
    exasptr = "";
 
309
 
 
310
  if ((flagval & SCOTCH_STRATSAFETY) != 0) {
 
311
    difpptr = "";
 
312
    difsptr = "";
 
313
  }
 
314
  else {
 
315
    difpptr = "(d{dif=1,rem=1,pass=40}|)";
 
316
    difsptr = "(d{dif=1,rem=1,pass=40}|)";
 
317
  }
 
318
 
 
319
  stringSubst (bufftab, "<MUCE>", muceptr);
 
320
  stringSubst (bufftab, "<EXAP>", exapptr);
 
321
  stringSubst (bufftab, "<EXAS>", exasptr);
 
322
  stringSubst (bufftab, "<DIFP>", difpptr);
 
323
  stringSubst (bufftab, "<DIFS>", difsptr);
 
324
  stringSubst (bufftab, "<BBAL>", bbaltab);
 
325
  stringSubst (bufftab, "<VERT>", verttab);
 
326
 
 
327
  if (SCOTCH_stratDgraphMap (stratptr, bufftab) != 0) {
 
328
    errorPrint ("SCOTCH_stratDgraphMapBuild: error in parallel mapping strategy");
 
329
    return     (1);
 
330
  }
 
331
 
 
332
  return (0);
 
333
}