mpmetis.c
Go to the documentation of this file.
1 /*
2  * Copyright 1994-2011, Regents of the University of Minnesota
3  *
4  * mpmetis.c
5  *
6  * Drivers for the mesh partitioning routines
7  *
8  * Started 8/28/94
9  * George
10  *
11  * $Id: mpmetis.c 10567 2011-07-13 16:17:07Z karypis $
12  *
13  */
14 
15 #include "metisbin.h"
16 
17 
18 
19 /*************************************************************************/
21 /*************************************************************************/
22 int main(int argc, char *argv[])
23 {
25  mesh_t *mesh;
26  idx_t *epart, *npart;
27  idx_t objval;
29  int status=0;
30 
31  params = parse_cmdline(argc, argv);
32 
33  gk_startcputimer(params->iotimer);
34  mesh = ReadMesh(params);
35 
36  if (mesh->ncon > 1) {
37  printf("*** Meshes with more than one balancing constraint are not supported yet.\n");
38  exit(0);
39  }
40 
41  ReadTPwgts(params, mesh->ncon);
42  gk_stopcputimer(params->iotimer);
43 
44  MPPrintInfo(params, mesh);
45 
46  epart = imalloc(mesh->ne, "main: epart");
47  npart = imalloc(mesh->nn, "main: npart");
48 
49  METIS_SetDefaultOptions(options);
50  options[METIS_OPTION_PTYPE] = params->ptype;
51  options[METIS_OPTION_OBJTYPE] = params->objtype;
52  options[METIS_OPTION_CTYPE] = params->ctype;
53  options[METIS_OPTION_IPTYPE] = params->iptype;
54  options[METIS_OPTION_RTYPE] = params->rtype;
55  options[METIS_OPTION_DBGLVL] = params->dbglvl;
56  options[METIS_OPTION_UFACTOR] = params->ufactor;
57  options[METIS_OPTION_MINCONN] = params->minconn;
58  options[METIS_OPTION_CONTIG] = params->contig;
59  options[METIS_OPTION_SEED] = params->seed;
60  options[METIS_OPTION_NITER] = params->niter;
61  options[METIS_OPTION_NCUTS] = params->ncuts;
62 
63 
65  gk_startcputimer(params->parttimer);
66 
67  switch (params->gtype) {
68  case METIS_GTYPE_DUAL:
69  status = METIS_PartMeshDual(&mesh->ne, &mesh->nn, mesh->eptr, mesh->eind,
70  mesh->ewgt, NULL, &params->ncommon, &params->nparts,
71  params->tpwgts, options, &objval, epart, npart);
72  break;
73 
74  case METIS_GTYPE_NODAL:
75  status = METIS_PartMeshNodal(&mesh->ne, &mesh->nn, mesh->eptr, mesh->eind,
76  NULL, NULL, &params->nparts, params->tpwgts, options, &objval,
77  epart, npart);
78  break;
79  }
80 
81  gk_stopcputimer(params->parttimer);
82  if (gk_GetCurMemoryUsed() != 0)
83  printf("***It seems that Metis did not free all of its memory! Report this.\n");
84  params->maxmemory = gk_GetMaxMemoryUsed();
86 
87  if (status != METIS_OK) {
88  printf("\n***Metis returned with an error.\n");
89  }
90  else {
91  if (!params->nooutput) {
92  /* Write the solution */
93  gk_startcputimer(params->iotimer);
94  WriteMeshPartition(params->filename, params->nparts, mesh->ne, epart, mesh->nn, npart);
95  gk_stopcputimer(params->iotimer);
96  }
97 
98  MPReportResults(params, mesh, epart, npart, objval);
99  }
100 
101  FreeMesh(&mesh);
102  gk_free((void **)&epart, &npart, LTERM);
103  gk_free((void **)&params->filename, &params->tpwgtsfile, &params->tpwgts,
104  &params->ubvecstr, &params->ubvec, &params, LTERM);
105 
106 }
107 
108 
109 /*************************************************************************/
111 /*************************************************************************/
113 {
114  if (params->ufactor == -1) {
115  if (params->ptype == METIS_PTYPE_KWAY)
117  else
119  }
120 
121  printf("******************************************************************************\n");
122  printf("%s", METISTITLE);
123  printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);
124  printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",
125  8*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));
126  printf("\n");
127  printf("Mesh Information ------------------------------------------------------------\n");
128  printf(" Name: %s, #Elements: %"PRIDX", #Nodes: %"PRIDX", #Parts: %"PRIDX"\n",
129  params->filename, mesh->ne, mesh->nn, params->nparts);
130  if (mesh->ncon > 1)
131  printf(" Balancing Constraints: %"PRIDX"\n", mesh->ncon);
132 
133  printf("\n");
134  printf("Options ---------------------------------------------------------------------\n");
135  printf(" ptype=%s, objtype=%s, ctype=%s, rtype=%s, iptype=%s\n",
136  ptypenames[params->ptype], objtypenames[params->objtype], ctypenames[params->ctype],
137  rtypenames[params->rtype], iptypenames[params->iptype]);
138 
139  printf(" dbglvl=%"PRIDX", ufactor=%.3f, minconn=%s, contig=%s, nooutput=%s\n",
140  params->dbglvl,
141  I2RUBFACTOR(params->ufactor),
142  (params->minconn ? "YES" : "NO"),
143  (params->contig ? "YES" : "NO"),
144  (params->nooutput ? "YES" : "NO")
145  );
146 
147  printf(" seed=%"PRIDX", niter=%"PRIDX", ncuts=%"PRIDX"\n",
148  params->seed, params->niter, params->ncuts);
149 
150  printf(" gtype=%s, ncommon=%"PRIDX", niter=%"PRIDX", ncuts=%"PRIDX"\n",
151  gtypenames[params->gtype], params->ncommon, params->niter, params->ncuts);
152 
153  printf("\n");
154  switch (params->ptype) {
155  case METIS_PTYPE_RB:
156  printf("Recursive Partitioning ------------------------------------------------------\n");
157  break;
158  case METIS_PTYPE_KWAY:
159  printf("Direct k-way Partitioning ---------------------------------------------------\n");
160  break;
161  }
162 }
163 
164 
165 /*************************************************************************/
167 /*************************************************************************/
169  idx_t objval)
170 {
171 
172  gk_startcputimer(params->reporttimer);
173 
174  /* ComputePartitionInfo(params, graph, part); */
175 
176  printf(" - %s: %"PRIDX".\n\n",
177  (params->objtype == METIS_OBJTYPE_CUT ? "Edgecut" : "Volume"), objval);
178 
179  gk_stopcputimer(params->reporttimer);
180 
181 
182  printf("\nTiming Information ----------------------------------------------------------\n");
183  printf(" I/O: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->iotimer));
184  printf(" Partitioning: \t\t %7.3"PRREAL" sec (METIS time)\n", gk_getcputimer(params->parttimer));
185  printf(" Reporting: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->reporttimer));
186  printf("\nMemory Information ----------------------------------------------------------\n");
187  printf(" Max memory used:\t\t %7.3"PRREAL" MB\n", (real_t)(params->maxmemory/(1024.0*1024.0)));
188  printf("******************************************************************************\n");
189 
190 }
Definition: fis.c:15
#define I2RUBFACTOR(ufactor)
idx_t dbglvl
#define gk_startcputimer(tmr)
Definition: gk_macros.h:33
idx_t ncon
#define imalloc
Definition: gklib_rename.h:42
#define gk_stopcputimer(tmr)
Definition: gk_macros.h:34
static char rtypenames[][15]
Definition: programs/defs.h:53
idx_t minconn
idx_t objtype
char * filename
Definition: fis.c:18
mesh_t * ReadMesh(params_t *params)
Definition: programs/io.c:178
size_t gk_GetMaxMemoryUsed()
Definition: memory.c:246
idx_t contig
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t * epart
real_t * tpwgts
#define METISTITLE
Definition: libmetis/defs.h:18
int METIS_SetDefaultOptions(idx_t *options)
Definition: auxapi.c:36
idx_t nooutput
real_t parttimer
params_t * parse_cmdline(int argc, char *argv[])
Definition: fis.c:194
#define PRIDX
idx_t * ewgt
void MPPrintInfo(params_t *params, mesh_t *mesh)
Definition: mpmetis.c:112
#define METIS_NOPTIONS
size_t gk_GetCurMemoryUsed()
Definition: memory.c:233
int METIS_PartMeshDual(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *vwgt, idx_t *vsize, idx_t *ncommon, idx_t *nparts, real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart)
Definition: meshpart.c:90
void ReadTPwgts(params_t *params, idx_t ncon)
Definition: programs/io.c:275
static char objtypenames[][15]
Definition: programs/defs.h:47
#define FreeMesh
Definition: rename.h:155
static char ptypenames[][15]
Definition: programs/defs.h:44
int METIS_PartMeshNodal(idx_t *ne, idx_t *nn, idx_t *eptr, idx_t *eind, idx_t *vwgt, idx_t *vsize, idx_t *nparts, real_t *tpwgts, idx_t *options, idx_t *objval, idx_t *epart, idx_t *npart)
Definition: meshpart.c:22
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t * objval
static char gtypenames[][15]
Definition: programs/defs.h:59
int32_t idx_t
char * tpwgtsfile
void WriteMeshPartition(char *fname, idx_t nparts, idx_t ne, idx_t *epart, idx_t nn, idx_t *npart)
Definition: programs/io.c:445
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t idx_t * npart
idx_t iptype
size_t maxmemory
int niter
Definition: gkgraph.c:17
static SmartStereoProjectionParams params
void gk_malloc_cleanup(int showstats)
Definition: memory.c:118
float real_t
#define gk_getcputimer(tmr)
Definition: gk_macros.h:35
#define NULL
Definition: ccolamd.c:609
char * ubvecstr
real_t * ubvec
real_t iotimer
static char iptypenames[][15]
Definition: programs/defs.h:56
int main(int argc, char *argv[])
Definition: mpmetis.c:22
void gk_free(void **ptr1,...)
Definition: memory.c:202
static char ctypenames[][15]
Definition: programs/defs.h:50
#define PRREAL
#define PMETIS_DEFAULT_UFACTOR
Definition: libmetis/defs.h:55
idx_t ufactor
real_t reporttimer
idx_t nparts
idx_t * eptr
void MPReportResults(params_t *params, mesh_t *mesh, idx_t *epart, idx_t *npart, idx_t objval)
Definition: mpmetis.c:168
int gk_malloc_init()
Definition: memory.c:99
idx_t * eind
idx_t ncommon
#define LTERM
Definition: gk_defs.h:14
#define KMETIS_DEFAULT_UFACTOR
Definition: libmetis/defs.h:57


gtsam
Author(s):
autogenerated on Sat May 8 2021 02:43:01