⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 backcompat.c

📁 一个用来实现偏微分方程中网格的计算库
💻 C
📖 第 1 页 / 共 2 页
字号:
/* * Copyright 1997, Regents of the University of Minnesota * * backcompat.c * * This file ensures backwards compatability with previous ParMETIS releases * * Started 10/19/96 * George * * $Id: backcompat.c 2501 2007-11-20 02:33:29Z benkirk $ * */#include <parmetislib.h>/******************************************************************************  This function computes a partitioning.*****************************************************************************/void ParMETIS_PartKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,       idxtype *adjwgt, int *wgtflag, int *numflag, int *nparts, int *options, int *edgecut,       idxtype *part, MPI_Comm *comm){  int i;  int ncon = 1;  float *tpwgts, ubvec[MAXNCON];  int myoptions[10];  tpwgts = fmalloc(*nparts*ncon, "tpwgts");  for (i=0; i<*nparts*ncon; i++)    tpwgts[i] = 1.0/(float)(*nparts);  for (i=0; i<ncon; i++)    ubvec[i] = UNBALANCE_FRACTION;  if (options[0] == 0) {    myoptions[0] = 0;  }  else {    myoptions[0] = 1;    myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];    myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;  }  ParMETIS_V3_PartKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag,  &ncon, nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);  free(tpwgts);}/*********************************************************************************** * * This function is the entry point of the parallel k-way multilevel partitionioner. * * This function assumes nothing about the graph distribution. * * It is the general case. * ************************************************************************************/void PARKMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,		               idxtype *part, int *options, MPI_Comm comm){  int wgtflag, numflag, edgecut, newoptions[5];  int npes;  MPI_Comm_size(comm, &npes);  newoptions[0] = 1;  newoptions[OPTION_IPART] = options[2];  newoptions[OPTION_FOLDF] = options[1];  newoptions[OPTION_DBGLVL] = options[4];		        numflag = options[3];  wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);  ParMETIS_PartKway(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag, &npes,	newoptions, &edgecut, part, &comm);  options[0] = edgecut;}/******************************************************************************  This function computes a partitioning using coordinate data.*****************************************************************************/void ParMETIS_PartGeomKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, idxtype *vwgt,       idxtype *adjwgt, int *wgtflag, int *numflag, int *ndims, float *xyz, int *nparts,       int *options, int *edgecut, idxtype *part, MPI_Comm *comm){  int i;  int ncon = 1;  float *tpwgts, ubvec[MAXNCON];  int myoptions[10];  tpwgts = fmalloc(*nparts*ncon, "tpwgts");  for (i=0; i<*nparts*ncon; i++)    tpwgts[i] = 1.0/(float)(*nparts);  for (i=0; i<ncon; i++)    ubvec[i] = UNBALANCE_FRACTION;  if (options[0] == 0) {    myoptions[0] = 0;  }  else {    myoptions[0] = 1;    myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];    myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;  }  ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz,  &ncon, nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);  free(tpwgts);  return;}/************************************************************************************ This function is the entry point of the parallel ordering algorithm.* This function assumes that the graph is already nice partitioned among the* processors and then proceeds to perform recursive bisection.************************************************************************************/void ParMETIS_PartGeom(idxtype *vtxdist, int *ndims, float *xyz, idxtype *part, MPI_Comm *comm){  ParMETIS_V3_PartGeom(vtxdist, ndims, xyz, part, comm);}/******************************************************************************  This function computes a partitioning using coordinate data.*****************************************************************************/void ParMETIS_PartGeomRefine(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,  idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *ndims,  float *xyz, int *options, int *edgecut, idxtype *part, MPI_Comm *comm){  int i;  int npes, nparts, ncon = 1;  float *tpwgts, ubvec[MAXNCON];  int myoptions[10];  MPI_Comm_size(*comm, &npes);  nparts = npes;  tpwgts = fmalloc(nparts*ncon, "tpwgts");  for (i=0; i<nparts*ncon; i++)    tpwgts[i] = 1.0/(float)(nparts);  for (i=0; i<ncon; i++)    ubvec[i] = UNBALANCE_FRACTION;  if (options[0] == 0) {    myoptions[0] = 0;  }  else {    myoptions[0] = 1;    myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];    myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;  }  ParMETIS_V3_PartGeomKway(vtxdist, xadj, adjncy, vwgt, adjwgt, wgtflag, numflag, ndims, xyz,  &ncon, &nparts, tpwgts, ubvec, myoptions, edgecut, part, comm);  free(tpwgts);  return;}/************************************************************************************ This function is the entry point of the parallel kmetis algorithm that uses* coordinates to compute an initial graph distribution.************************************************************************************/void PARGKMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,                int ndims, float *xyz, idxtype *part, int *options, MPI_Comm comm){  int npes, wgtflag, numflag, edgecut, newoptions[5];  MPI_Comm_size(comm, &npes);  newoptions[0] = 1;  newoptions[OPTION_IPART] = options[2];  newoptions[OPTION_FOLDF] = options[1];  newoptions[OPTION_DBGLVL] = options[4];  numflag = options[3];  wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);  ParMETIS_PartGeomKway(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,     &ndims, xyz, &npes, newoptions, &edgecut, part, &comm);  options[0] = edgecut;}/************************************************************************************ This function is the entry point of the parallel rmetis algorithm that uses* coordinates to compute an initial graph distribution.************************************************************************************/void PARGRMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *vwgt, idxtype *adjncy, idxtype *adjwgt,                int ndims, float *xyz, idxtype *part, int *options, MPI_Comm comm){  int wgtflag, numflag, edgecut, newoptions[5];  newoptions[0] = 1;  newoptions[OPTION_IPART] = options[2];  newoptions[OPTION_FOLDF] = options[1];  newoptions[OPTION_DBGLVL] = options[4];  numflag = options[3];  wgtflag = (vwgt == NULL ? 0 : 2) + (adjwgt == NULL ? 0 : 1);  ParMETIS_PartGeomRefine(vtxdist, xadj, adjncy, vwgt, adjwgt, &wgtflag, &numflag,     &ndims, xyz, newoptions, &edgecut, part, &comm);  options[0] = edgecut;}/************************************************************************************ This function is the entry point of the parallel ordering algorithm.* This function assumes that the graph is already nice partitioned among the* processors and then proceeds to perform recursive bisection.************************************************************************************/void PARGMETIS(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy, int ndims, float *xyz,               idxtype *part, int *options, MPI_Comm comm){  ParMETIS_PartGeom(vtxdist, &ndims, xyz, part, &comm);  options[0] = -1;}/******************************************************************************  This function performs refinement on a partitioning.*****************************************************************************/void ParMETIS_RefineKway(idxtype *vtxdist, idxtype *xadj, idxtype *adjncy,       idxtype *vwgt, idxtype *adjwgt, int *wgtflag, int *numflag, int *options,       int *edgecut, idxtype *part, MPI_Comm *comm){  int i;  int nparts;  int ncon = 1;  float *tpwgts, ubvec[MAXNCON];  int myoptions[10];  MPI_Comm_size(*comm, &nparts);  tpwgts = fmalloc(nparts*ncon, "tpwgts");  for (i=0; i<nparts*ncon; i++)    tpwgts[i] = 1.0/(float)(nparts);  for (i=0; i<ncon; i++)    ubvec[i] = UNBALANCE_FRACTION;  if (options[0] == 0) {    myoptions[0] = 0;  }  else {    myoptions[0] = 1;    myoptions[PMV3_OPTION_DBGLVL] = options[OPTION_DBGLVL];    myoptions[PMV3_OPTION_SEED] = GLOBAL_SEED;    myoptions[PMV3_OPTION_PSR] = COUPLED;

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -