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 
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 
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)
116  params->ufactor = KMETIS_DEFAULT_UFACTOR;
117  else
118  params->ufactor = PMETIS_DEFAULT_UFACTOR;
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 }
I2RUBFACTOR
#define I2RUBFACTOR(ufactor)
Definition: metis/libmetis/macros.h:35
objval
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t * objval
Definition: include/metis.h:215
METIS_OPTION_UFACTOR
@ METIS_OPTION_UFACTOR
Definition: include/metis.h:287
METIS_OPTION_SEED
@ METIS_OPTION_SEED
Definition: include/metis.h:279
iptypenames
static char iptypenames[][15]
Definition: programs/defs.h:56
METIS_OPTION_OBJTYPE
@ METIS_OPTION_OBJTYPE
Definition: include/metis.h:272
gk_free
void gk_free(void **ptr1,...)
Definition: memory.c:202
mesh_t
Definition: libmetis/struct.h:126
mesh_t::eptr
idx_t * eptr
Definition: libmetis/struct.h:130
METIS_OPTION_PTYPE
@ METIS_OPTION_PTYPE
Definition: include/metis.h:271
METIS_PartMeshNodal
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
gk_getcputimer
#define gk_getcputimer(tmr)
Definition: gk_macros.h:35
imalloc
#define imalloc
Definition: gklib_rename.h:42
KMETIS_DEFAULT_UFACTOR
#define KMETIS_DEFAULT_UFACTOR
Definition: libmetis/defs.h:54
params_t
Definition: fis.c:15
METIS_PTYPE_RB
@ METIS_PTYPE_RB
Definition: include/metis.h:303
WriteMeshPartition
void WriteMeshPartition(char *fname, idx_t nparts, idx_t ne, idx_t *epart, idx_t nn, idx_t *npart)
Definition: programs/io.c:445
PRREAL
#define PRREAL
Definition: include/metis.h:135
vanilla::params
static const SmartProjectionParams params
Definition: smartFactorScenarios.h:69
METIS_OPTION_NITER
@ METIS_OPTION_NITER
Definition: include/metis.h:277
npart
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t idx_t * npart
Definition: include/metis.h:215
METIS_OPTION_IPTYPE
@ METIS_OPTION_IPTYPE
Definition: include/metis.h:274
METIS_GTYPE_DUAL
@ METIS_GTYPE_DUAL
Definition: include/metis.h:309
METIS_OPTION_CTYPE
@ METIS_OPTION_CTYPE
Definition: include/metis.h:273
gk_startcputimer
#define gk_startcputimer(tmr)
Definition: gk_macros.h:33
METIS_GTYPE_NODAL
@ METIS_GTYPE_NODAL
Definition: include/metis.h:310
METIS_OK
@ METIS_OK
Definition: include/metis.h:254
ctypenames
static char ctypenames[][15]
Definition: programs/defs.h:50
metisbin.h
rtypenames
static char rtypenames[][15]
Definition: programs/defs.h:53
LTERM
#define LTERM
Definition: gk_defs.h:14
gk_GetMaxMemoryUsed
size_t gk_GetMaxMemoryUsed()
Definition: memory.c:246
MPPrintInfo
void MPPrintInfo(params_t *params, mesh_t *mesh)
Definition: mpmetis.c:112
METIS_OPTION_CONTIG
@ METIS_OPTION_CONTIG
Definition: include/metis.h:282
METIS_PTYPE_KWAY
@ METIS_PTYPE_KWAY
Definition: include/metis.h:304
METIS_OPTION_DBGLVL
@ METIS_OPTION_DBGLVL
Definition: include/metis.h:276
METIS_OPTION_RTYPE
@ METIS_OPTION_RTYPE
Definition: include/metis.h:275
parse_cmdline
params_t * parse_cmdline(int argc, char *argv[])
Definition: fis.c:194
ReadTPwgts
void ReadTPwgts(params_t *params, idx_t ncon)
Definition: programs/io.c:275
METIS_SetDefaultOptions
int METIS_SetDefaultOptions(idx_t *options)
Definition: auxapi.c:36
epart
idx_t idx_t idx_t idx_t idx_t idx_t real_t idx_t idx_t idx_t * epart
Definition: include/metis.h:215
objtypenames
static char objtypenames[][15]
Definition: programs/defs.h:47
PMETIS_DEFAULT_UFACTOR
#define PMETIS_DEFAULT_UFACTOR
Definition: libmetis/defs.h:52
METIS_OPTION_MINCONN
@ METIS_OPTION_MINCONN
Definition: include/metis.h:281
mesh_t::eind
idx_t * eind
Definition: libmetis/struct.h:130
FreeMesh
#define FreeMesh
Definition: rename.h:155
METISTITLE
#define METISTITLE
Definition: libmetis/defs.h:18
PRIDX
#define PRIDX
Definition: include/metis.h:107
ptypenames
static char ptypenames[][15]
Definition: programs/defs.h:44
real_t
float real_t
Definition: include/metis.h:132
gtypenames
static char gtypenames[][15]
Definition: programs/defs.h:59
METIS_NOPTIONS
#define METIS_NOPTIONS
Definition: include/metis.h:175
main
int main(int argc, char *argv[])
Definition: mpmetis.c:22
METIS_OBJTYPE_CUT
@ METIS_OBJTYPE_CUT
Definition: include/metis.h:355
mesh_t::ncon
idx_t ncon
Definition: libmetis/struct.h:128
NULL
#define NULL
Definition: ccolamd.c:609
mesh_t::ewgt
idx_t * ewgt
Definition: libmetis/struct.h:131
gk_GetCurMemoryUsed
size_t gk_GetCurMemoryUsed()
Definition: memory.c:233
mesh_t::ne
idx_t ne
Definition: libmetis/struct.h:127
ReadMesh
mesh_t * ReadMesh(params_t *params)
Definition: programs/io.c:178
gk_stopcputimer
#define gk_stopcputimer(tmr)
Definition: gk_macros.h:34
options
Definition: options.h:16
gk_malloc_cleanup
void gk_malloc_cleanup(int showstats)
Definition: memory.c:118
METIS_OPTION_NCUTS
@ METIS_OPTION_NCUTS
Definition: include/metis.h:278
MPReportResults
void MPReportResults(params_t *params, mesh_t *mesh, idx_t *epart, idx_t *npart, idx_t objval)
Definition: mpmetis.c:168
mesh_t::nn
idx_t nn
Definition: libmetis/struct.h:127
METIS_PartMeshDual
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
idx_t
int32_t idx_t
Definition: include/metis.h:101
gk_malloc_init
int gk_malloc_init()
Definition: memory.c:99


gtsam
Author(s):
autogenerated on Sat Nov 16 2024 04:03:11