00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <parmetislib.h>
00016
00017
00018
00019
00020 void ParMETIS_PartKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
00021 idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, int *edgecut,
00022 idxtype *part, MPI_Comm *comm)
00023 {
00024 int i;
00025 int ncon = 1;
00026 floattype *tpwgts, ubvec[MAXNCON];
00027 int myoptions[10];
00028
00029 tpwgts = fmalloc(*nparts*ncon, "tpwgts");
00030 for (i=0; i<*nparts*ncon; i++)
00031 tpwgts[i] = 1.0/(floattype)(*nparts);
00032 for (i=0; i<ncon; i++)
00033 ubvec[i] = UNBALANCE_FRACTION;
00034
00035 if (options[0] == 0) {
00036 myoptions[0] = 0;
00037 }
00038 else {
00039 myoptions[0] = 1;
00040 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00041 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00042 }
00043
00044 ParMETIS_V3_PartKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag,
00045 &ncon, nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);
00046
00047 free(tpwgts);
00048 }
00049
00050
00051
00052
00053
00054
00055
00056
00057 void PARKMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,
00058 idxtype *part, int *options, MPI_Comm comm)
00059 {
00060 int wgtflag, numflag, edgecut, newoptions[5];
00061 int npes;
00062
00063 MPI_Comm_size(comm, &npes);
00064
00065 newoptions[0] = 1;
00066 newoptions[OPTION_IPART] = options[2];
00067 newoptions[OPTION_FOLDF] = options[1];
00068 newoptions[OPTION_DBGLVL] = options[4];
00069
00070 numflag = options[3];
00071 wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);
00072
00073 ParMETIS_PartKway(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag, &npes,
00074 newoptions, &edgecut, part, &comm);
00075
00076 options[0] = edgecut;
00077
00078 }
00079
00080
00081
00082
00083
00084
00085 void ParMETIS_PartGeomKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,
00086 idxtype *adjwgt, int *wgtflag, int *numflag, int *ndims, floattype *xyz, int *nparts,
00087 int *options, int *edgecut, idxtype *part, MPI_Comm *comm)
00088 {
00089 int i;
00090 int ncon = 1;
00091 floattype *tpwgts, ubvec[MAXNCON];
00092 int myoptions[10];
00093
00094 tpwgts = fmalloc(*nparts*ncon, "tpwgts");
00095 for (i=0; i<*nparts*ncon; i++)
00096 tpwgts[i] = 1.0/(floattype)(*nparts);
00097 for (i=0; i<ncon; i++)
00098 ubvec[i] = UNBALANCE_FRACTION;
00099
00100 if (options[0] == 0) {
00101 myoptions[0] = 0;
00102 }
00103 else {
00104 myoptions[0] = 1;
00105 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00106 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00107 }
00108
00109 ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz,
00110 &ncon, nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);
00111
00112 free(tpwgts);
00113 return;
00114 }
00115
00116
00117
00118
00119
00120
00121
00122 void ParMETIS_PartGeom(idxtype *vtxdist, int *ndims, floattype *xyz, idxtype *part, MPI_Comm *comm)
00123 {
00124 ParMETIS_V3_PartGeom(vtxdist, ndims, xyz, part, comm);
00125 }
00126
00127
00128
00129
00130
00131 void ParMETIS_PartGeomRefine(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
00132 idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *ndims,
00133 floattype *xyz, int *options, int *edgecut, idxtype *part, MPI_Comm *comm)
00134 {
00135 int i;
00136 int npes, nparts, ncon = 1;
00137 floattype *tpwgts, ubvec[MAXNCON];
00138 int myoptions[10];
00139
00140 MPI_Comm_size(*comm, &npes);
00141 nparts = npes;
00142
00143 tpwgts = fmalloc(nparts*ncon, "tpwgts");
00144 for (i=0; i<nparts*ncon; i++)
00145 tpwgts[i] = 1.0/(floattype)(nparts);
00146 for (i=0; i<ncon; i++)
00147 ubvec[i] = UNBALANCE_FRACTION;
00148
00149 if (options[0] == 0) {
00150 myoptions[0] = 0;
00151 }
00152 else {
00153 myoptions[0] = 1;
00154 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00155 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00156 }
00157
00158 ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz,
00159 &ncon, &nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);
00160
00161 free(tpwgts);
00162 return;
00163 }
00164
00165
00166
00167
00168
00169
00170 void PARGKMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,
00171 int ndims, floattype *xyz, idxtype *part, int *options, MPI_Comm comm)
00172 {
00173 int npes, wgtflag, numflag, edgecut, newoptions[5];
00174
00175 MPI_Comm_size(comm, &npes);
00176
00177 newoptions[0] = 1;
00178 newoptions[OPTION_IPART] = options[2];
00179 newoptions[OPTION_FOLDF] = options[1];
00180 newoptions[OPTION_DBGLVL] = options[4];
00181
00182 numflag = options[3];
00183 wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);
00184
00185 ParMETIS_PartGeomKway(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
00186 &ndims, xyz, &npes, newoptions, &edgecut, part, &comm);
00187
00188 options[0] = edgecut;
00189
00190 }
00191
00192
00193
00194
00195
00196
00197 void PARGRMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,
00198 int ndims, floattype *xyz, idxtype *part, int *options, MPI_Comm comm)
00199 {
00200 int wgtflag, numflag, edgecut, newoptions[5];
00201
00202 newoptions[0] = 1;
00203 newoptions[OPTION_IPART] = options[2];
00204 newoptions[OPTION_FOLDF] = options[1];
00205 newoptions[OPTION_DBGLVL] = options[4];
00206
00207 numflag = options[3];
00208 wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);
00209
00210 ParMETIS_PartGeomRefine(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
00211 &ndims, xyz, newoptions, &edgecut, part, &comm);
00212
00213 options[0] = edgecut;
00214
00215 }
00216
00217
00218
00219
00220
00221
00222 void PARGMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int ndims, floattype *xyz,
00223 idxtype *part, int *options, MPI_Comm comm)
00224 {
00225
00226 ParMETIS_PartGeom(vtxdist, &ndims, xyz, part, &comm);
00227
00228 options[0] = -1;
00229
00230 }
00231
00232
00233
00234
00235 void ParMETIS_RefineKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
00236 idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *options,
00237 int *edgecut, idxtype *part, MPI_Comm *comm)
00238 {
00239 int i;
00240 int nparts;
00241 int ncon = 1;
00242 floattype *tpwgts, ubvec[MAXNCON];
00243 int myoptions[10];
00244
00245 MPI_Comm_size(*comm, &nparts);
00246 tpwgts = fmalloc(nparts*ncon, "tpwgts");
00247 for (i=0; i<nparts*ncon; i++)
00248 tpwgts[i] = 1.0/(floattype)(nparts);
00249 for (i=0; i<ncon; i++)
00250 ubvec[i] = UNBALANCE_FRACTION;
00251
00252 if (options[0] == 0) {
00253 myoptions[0] = 0;
00254 }
00255 else {
00256 myoptions[0] = 1;
00257 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00258 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00259 myoptions[PMV3_OPTION_PSR] = COUPLED;
00260 }
00261
00262 ParMETIS_V3_RefineKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag,
00263 &ncon, &nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);
00264
00265 free(tpwgts);
00266 }
00267
00268
00269
00270
00271
00272
00273
00274 void PARRMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,
00275 idxtype *part, int *options, MPI_Comm comm)
00276 {
00277 int wgtflag, numflag, edgecut, newoptions[5];
00278
00279 newoptions[0] = 1;
00280 newoptions[OPTION_IPART] = options[2];
00281 newoptions[OPTION_FOLDF] = options[1];
00282 newoptions[OPTION_DBGLVL] = options[4];
00283
00284 numflag = options[3];
00285 wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);
00286
00287 ParMETIS_RefineKway(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
00288 newoptions, &edgecut, part, &comm);
00289
00290 options[0] = edgecut;
00291
00292 }
00293
00294
00295
00296
00297
00298 void ParMETIS_RepartLDiffusion(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
00299 idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *options,
00300 int *edgecut, idxtype *part, MPI_Comm *comm)
00301 {
00302 int i;
00303 int nparts;
00304 int ncon = 1;
00305 floattype *tpwgts, ubvec[MAXNCON];
00306 floattype ipc_factor = 1.0;
00307 int myoptions[10];
00308
00309 MPI_Comm_size(*comm, &nparts);
00310 tpwgts = fmalloc(nparts*ncon, "tpwgts");
00311 for (i=0; i<nparts*ncon; i++)
00312 tpwgts[i] = 1.0/(floattype)(nparts);
00313 for (i=0; i<ncon; i++)
00314 ubvec[i] = UNBALANCE_FRACTION;
00315
00316 if (options[0] == 0) {
00317 myoptions[0] = 0;
00318 }
00319 else {
00320 myoptions[0] = 1;
00321 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00322 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00323 myoptions[PMV3_OPTION_PSR] = COUPLED;
00324 }
00325
00326 ParMETIS_V3_AdaptiveRepart(vtxdist, xadj, adjncy, vwgt, NULL, adjwgt, wgtflag, numflag,
00327 &ncon, &nparts, tpwgts, ubvec, &ipc_factor, myoptions, edgecut, part, comm);
00328
00329 free(tpwgts);
00330 }
00331
00332
00333
00334
00335
00336
00337
00338 void PARUAMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,
00339 idxtype *part, int *options, MPI_Comm comm)
00340 {
00341 int wgtflag, numflag, edgecut, newoptions[5];
00342
00343 newoptions[0] = 1;
00344 newoptions[OPTION_IPART] = options[2];
00345 newoptions[OPTION_FOLDF] = options[1];
00346 newoptions[OPTION_DBGLVL] = options[4];
00347
00348 numflag = options[3];
00349 wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);
00350
00351 ParMETIS_RepartLDiffusion(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
00352 newoptions, &edgecut, part, &comm);
00353
00354 options[0] = edgecut;
00355
00356 }
00357
00358
00359
00360
00361 void ParMETIS_RepartGDiffusion(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
00362 idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *options,
00363 int *edgecut, idxtype *part, MPI_Comm *comm)
00364 {
00365 int i;
00366 int nparts;
00367 int ncon = 1;
00368 floattype *tpwgts, ubvec[MAXNCON];
00369 floattype ipc_factor = 100.0;
00370 int myoptions[10];
00371
00372 MPI_Comm_size(*comm, &nparts);
00373 tpwgts = fmalloc(nparts*ncon, "tpwgts");
00374 for (i=0; i<nparts*ncon; i++)
00375 tpwgts[i] = 1.0/(floattype)(nparts);
00376 for (i=0; i<ncon; i++)
00377 ubvec[i] = UNBALANCE_FRACTION;
00378
00379 if (options[0] == 0) {
00380 myoptions[0] = 0;
00381 }
00382 else {
00383 myoptions[0] = 1;
00384 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00385 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00386 myoptions[PMV3_OPTION_PSR] = COUPLED;
00387 }
00388
00389 ParMETIS_V3_AdaptiveRepart(vtxdist, xadj, adjncy, vwgt, NULL, adjwgt, wgtflag, numflag,
00390 &ncon, &nparts, tpwgts, ubvec, &ipc_factor, myoptions, edgecut, part, comm);
00391
00392 free(tpwgts);
00393 }
00394
00395
00396
00397
00398
00399
00400 void PARDAMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,
00401 idxtype *part, int *options, MPI_Comm comm)
00402 {
00403 int wgtflag, numflag, edgecut, newoptions[5];
00404
00405 newoptions[0] = 1;
00406 newoptions[OPTION_IPART] = options[2];
00407 newoptions[OPTION_FOLDF] = options[1];
00408 newoptions[OPTION_DBGLVL] = options[4];
00409
00410 numflag = options[3];
00411 wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);
00412
00413 ParMETIS_RepartGDiffusion(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,
00414 newoptions, &edgecut, part, &comm);
00415
00416 options[0] = edgecut;
00417
00418 }
00419
00420
00421
00422
00423 void ParMETIS_RepartRemap(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
00424 idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *options,
00425 int *edgecut, idxtype *part, MPI_Comm *comm)
00426 {
00427 int i;
00428 int nparts;
00429 int ncon = 1;
00430 floattype *tpwgts, ubvec[MAXNCON];
00431 floattype ipc_factor = 1000.0;
00432 int myoptions[10];
00433
00434 MPI_Comm_size(*comm, &nparts);
00435 tpwgts = fmalloc(nparts*ncon, "tpwgts");
00436 for (i=0; i<nparts*ncon; i++)
00437 tpwgts[i] = 1.0/(floattype)(nparts);
00438 for (i=0; i<ncon; i++)
00439 ubvec[i] = UNBALANCE_FRACTION;
00440
00441 if (options[0] == 0) {
00442 myoptions[0] = 0;
00443 }
00444 else {
00445 myoptions[0] = 1;
00446 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00447 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00448 myoptions[PMV3_OPTION_PSR] = COUPLED;
00449 }
00450
00451 ParMETIS_V3_AdaptiveRepart(vtxdist, xadj, adjncy, vwgt, NULL, adjwgt, wgtflag, numflag,
00452 &ncon, &nparts, tpwgts, ubvec, &ipc_factor, myoptions, edgecut, part, comm);
00453
00454 free(tpwgts);
00455 }
00456
00457
00458
00459
00460
00461 void ParMETIS_RepartMLRemap(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,
00462 idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *options,
00463 int *edgecut, idxtype *part, MPI_Comm *comm)
00464 {
00465 int i;
00466 int nparts;
00467 int ncon = 1;
00468 floattype *tpwgts, ubvec[MAXNCON];
00469 floattype ipc_factor = 1000.0;
00470 int myoptions[10];
00471
00472 MPI_Comm_size(*comm, &nparts);
00473 tpwgts = fmalloc(nparts*ncon, "tpwgts");
00474 for (i=0; i<nparts*ncon; i++)
00475 tpwgts[i] = 1.0/(floattype)(nparts);
00476 for (i=0; i<ncon; i++)
00477 ubvec[i] = UNBALANCE_FRACTION;
00478
00479 if (options[0] == 0) {
00480 myoptions[0] = 0;
00481 }
00482 else {
00483 myoptions[0] = 1;
00484 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00485 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00486 myoptions[PMV3_OPTION_PSR] = COUPLED;
00487 }
00488
00489 ParMETIS_V3_AdaptiveRepart(vtxdist, xadj, adjncy, vwgt, NULL, adjwgt, wgtflag, numflag,
00490 &ncon, &nparts, tpwgts, ubvec, &ipc_factor, myoptions, edgecut, part, comm);
00491
00492 free(tpwgts);
00493 }
00494
00495
00496
00497
00498
00499
00500 void ParMETIS_NodeND(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int *numflag,
00501 int *options, idxtype *order, idxtype *sizes, MPI_Comm *comm)
00502 {
00503 int myoptions[10];
00504
00505 if (options[0] == 0) {
00506 myoptions[0] = 0;
00507 }
00508 else {
00509 myoptions[0] = 1;
00510 myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];
00511 myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;
00512 myoptions[PMV3_OPTION_IPART] = options[OPTION_IPART];
00513 }
00514
00515 ParMETIS_V3_NodeND(vtxdist, xadj, adjncy, numflag, myoptions, order, sizes, comm);
00516 }
00517