00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include <parmetislib.h>
00016
00017
00018
00019
00020
00021
00022
00023 void ParMETIS_V3_PartMeshKway(idxtype *elmdist, idxtype *eptr, idxtype *eind, idxtype *elmwgt,
00024 int *wgtflag, int *numflag, int *ncon, int *ncommonnodes, int *nparts,
00025 floattype *tpwgts, floattype *ubvec, int *options, int *edgecut, idxtype *part,
00026 MPI_Comm *comm)
00027 {
00028 int i, nvtxs, nedges, gnedges, npes, mype;
00029 idxtype *xadj, *adjncy;
00030 timer TotalTmr, Mesh2DualTmr, ParMETISTmr;
00031 CtrlType ctrl;
00032
00033
00034
00035
00036 if (elmdist == NULL || eptr == NULL || eind == NULL || wgtflag == NULL ||
00037 numflag == NULL || ncon == NULL || ncommonnodes == NULL || nparts == NULL ||
00038 tpwgts == NULL || ubvec == NULL || options == NULL || edgecut == NULL ||
00039 part == NULL || comm == NULL) {
00040 printf("ERROR: One or more required parameters is NULL. Aborting.\n");
00041 abort();
00042 }
00043 if (((*wgtflag)&2) && elmwgt == NULL) {
00044 printf("ERROR: elmwgt == NULL when vertex weights were specified. Aborting.\n");
00045 abort();
00046 }
00047
00048
00049 SetUpCtrl(&ctrl, *nparts, (options[0] == 1 ? options[PMV3_OPTION_DBGLVL] : 0), *comm);
00050 npes = ctrl.npes;
00051 mype = ctrl.mype;
00052
00053 cleartimer(TotalTmr);
00054 cleartimer(Mesh2DualTmr);
00055 cleartimer(ParMETISTmr);
00056
00057 MPI_Barrier(ctrl.comm);
00058 starttimer(TotalTmr);
00059 starttimer(Mesh2DualTmr);
00060
00061 ParMETIS_V3_Mesh2Dual(elmdist, eptr, eind, numflag, ncommonnodes, &xadj, &adjncy, &(ctrl.comm));
00062
00063 if (ctrl.dbglvl&DBG_INFO) {
00064 nvtxs = elmdist[mype+1]-elmdist[mype];
00065 nedges = xadj[nvtxs] + (*numflag == 0 ? 0 : -1);
00066 rprintf(&ctrl, "Completed Dual Graph -- Nvtxs: %d, Nedges: %d \n",
00067 elmdist[npes], GlobalSESum(&ctrl, nedges));
00068 }
00069
00070 MPI_Barrier(ctrl.comm);
00071 stoptimer(Mesh2DualTmr);
00072
00073
00074
00075
00076
00077 starttimer(ParMETISTmr);
00078
00079 ParMETIS_V3_PartKway(elmdist, xadj, adjncy, elmwgt, NULL, wgtflag, numflag, ncon,
00080 nparts, tpwgts, ubvec, options, edgecut, part, &(ctrl.comm));
00081
00082 MPI_Barrier(ctrl.comm);
00083 stoptimer(ParMETISTmr);
00084 stoptimer(TotalTmr);
00085
00086 IFSET(ctrl.dbglvl, DBG_TIME, PrintTimer(&ctrl, Mesh2DualTmr, " Mesh2Dual"));
00087 IFSET(ctrl.dbglvl, DBG_TIME, PrintTimer(&ctrl, ParMETISTmr, " ParMETIS"));
00088 IFSET(ctrl.dbglvl, DBG_TIME, PrintTimer(&ctrl, TotalTmr, " Total"));
00089
00090 GKfree((void **)&xadj, (void **)&adjncy, LTERM);
00091
00092 FreeCtrl(&ctrl);
00093
00094 return;
00095 }