ndmetis.c
Go to the documentation of this file.
1 /*
2  * Copyright 1994-2011, Regents of the University of Minnesota
3  *
4  * ndmetis.c
5  *
6  * Driver programs for nested disection ordering
7  *
8  * Started 8/28/94
9  * George
10  *
11  * $Id: ndmetis.c 13900 2013-03-24 15:27:07Z karypis $
12  *
13  */
14 
15 #include "metisbin.h"
16 
17 
18 
19 /*************************************************************************/
21 /*************************************************************************/
22 int main(int argc, char *argv[])
23 {
25  graph_t *graph;
26  idx_t *perm, *iperm;
28  int status=0;
29 
30  params = parse_cmdline(argc, argv);
31 
32  gk_startcputimer(params->iotimer);
34  gk_stopcputimer(params->iotimer);
35 
36  /* This is just for internal use to clean up some files
37  {
38  char fileout[8192];
39 
40  gk_free((void **)&graph->vwgt, &graph->adjwgt, &graph->vsize, LTERM);
41  sprintf(fileout, "ND/%s", params->filename);
42  if (graph->nvtxs > 25000)
43  WriteGraph(graph, fileout);
44  exit(0);
45  }
46  */
47 
48  /* Check if the graph is contiguous */
49  if (graph->ncon != 1) {
50  printf("***The input graph contains %"PRIDX" constraints..\n"
51  "***Ordering requires a graph with one constraint.\n", graph->ncon);
52  exit(0);
53  }
54 
56 
57  perm = imalloc(graph->nvtxs, "main: perm");
58  iperm = imalloc(graph->nvtxs, "main: iperm");
59 
73 
75  gk_startcputimer(params->parttimer);
76 
77  status = METIS_NodeND(&graph->nvtxs, graph->xadj, graph->adjncy, graph->vwgt,
78  options, perm, iperm);
79 
80  gk_stopcputimer(params->parttimer);
81  if (gk_GetCurMemoryUsed() != 0)
82  printf("***It seems that Metis did not free all of its memory! Report this.\n");
83  params->maxmemory = gk_GetMaxMemoryUsed();
85 
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  WritePermutation(params->filename, iperm, graph->nvtxs);
95  gk_stopcputimer(params->iotimer);
96  }
97 
99  }
100 
101  FreeGraph(&graph);
102  gk_free((void **)&perm, &iperm, LTERM);
103  gk_free((void **)&params->filename, &params->tpwgtsfile, &params->tpwgts,
104  &params->ubvec, &params, LTERM);
105 
106 }
107 
108 
109 /*************************************************************************/
111 /*************************************************************************/
113 {
114  printf("******************************************************************************\n");
115  printf("%s", METISTITLE);
116  printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);
117  printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",
118  8*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));
119  printf("\n");
120  printf("Graph Information -----------------------------------------------------------\n");
121  printf(" Name: %s, #Vertices: %"PRIDX", #Edges: %"PRIDX"\n",
122  params->filename, graph->nvtxs, graph->nedges/2);
123 
124  printf("\n");
125  printf("Options ---------------------------------------------------------------------\n");
126  printf(" ctype=%s, rtype=%s, iptype=%s, seed=%"PRIDX", dbglvl=%"PRIDX"\n",
127  ctypenames[params->ctype], rtypenames[params->rtype],
128  iptypenames[params->iptype], params->seed, params->dbglvl);
129 
130  printf(" ufactor=%.3f, pfactor=%.2f, no2hop=%s, ccorder=%s, compress=%s, , nooutput=%s\n",
131  I2RUBFACTOR(params->ufactor),
132  0.1*params->pfactor,
133  (params->no2hop ? "YES" : "NO"),
134  (params->ccorder ? "YES" : "NO"),
135  (params->compress ? "YES" : "NO"),
136  (params->nooutput ? "YES" : "NO")
137  );
138 
139  printf(" niter=%"PRIDX", nseps=%"PRIDX"\n", params->niter, params->nseps);
140 
141  printf("\n");
142  printf("Node-based Nested Dissection ------------------------------------------------\n");
143 }
144 
145 
146 /*************************************************************************/
148 /*************************************************************************/
150  idx_t *iperm)
151 {
152  size_t maxlnz, opc;
153 
154  gk_startcputimer(params->reporttimer);
155  ComputeFillIn(graph, perm, iperm, &maxlnz, &opc);
156  printf(" Nonzeros: %6.3le \tOperation Count: %6.3le\n", (double)maxlnz, (double)opc);
157 
158  gk_stopcputimer(params->reporttimer);
159 
160 
161  printf("\nTiming Information ----------------------------------------------------------\n");
162  printf(" I/O: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->iotimer));
163  printf(" Ordering: \t\t %7.3"PRREAL" sec (METIS time)\n", gk_getcputimer(params->parttimer));
164  printf(" Reporting: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->reporttimer));
165  printf("\nMemory Information ----------------------------------------------------------\n");
166  printf(" Max memory used:\t\t %7.3"PRREAL" MB\n", (real_t)(params->maxmemory/(1024.0*1024.0)));
167  printf("******************************************************************************\n");
168 
169 }
WritePermutation
void WritePermutation(char *fname, idx_t *iperm, idx_t n)
Definition: programs/io.c:477
I2RUBFACTOR
#define I2RUBFACTOR(ufactor)
Definition: metis/libmetis/macros.h:35
perm
idx_t idx_t idx_t idx_t idx_t * perm
Definition: include/metis.h:223
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_COMPRESS
@ METIS_OPTION_COMPRESS
Definition: include/metis.h:283
gk_free
void gk_free(void **ptr1,...)
Definition: memory.c:202
gk_getcputimer
#define gk_getcputimer(tmr)
Definition: gk_macros.h:35
imalloc
#define imalloc
Definition: gklib_rename.h:42
params_t
Definition: fis.c:15
PRREAL
#define PRREAL
Definition: include/metis.h:135
vanilla::params
static const SmartProjectionParams params
Definition: smartFactorScenarios.h:69
ReadGraph
graph_t * ReadGraph(params_t *params)
Definition: programs/io.c:22
METIS_OPTION_NITER
@ METIS_OPTION_NITER
Definition: include/metis.h:277
NDReportResults
void NDReportResults(params_t *params, graph_t *graph, idx_t *perm, idx_t *iperm)
Definition: ndmetis.c:149
METIS_OPTION_IPTYPE
@ METIS_OPTION_IPTYPE
Definition: include/metis.h:274
METIS_OPTION_CTYPE
@ METIS_OPTION_CTYPE
Definition: include/metis.h:273
main
int main(int argc, char *argv[])
Definition: ndmetis.c:22
gk_startcputimer
#define gk_startcputimer(tmr)
Definition: gk_macros.h:33
iperm
idx_t idx_t idx_t idx_t idx_t idx_t * iperm
Definition: include/metis.h:223
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
METIS_NodeND
int METIS_NodeND(idx_t *nvtxs, idx_t *xadj, idx_t *adjncy, idx_t *vwgt, idx_t *options, idx_t *perm, idx_t *iperm)
Definition: ometis.c:43
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
METIS_SetDefaultOptions
int METIS_SetDefaultOptions(idx_t *options)
Definition: auxapi.c:36
FreeGraph
#define FreeGraph
Definition: rename.h:98
METISTITLE
#define METISTITLE
Definition: libmetis/defs.h:18
PRIDX
#define PRIDX
Definition: include/metis.h:107
real_t
float real_t
Definition: include/metis.h:132
METIS_NOPTIONS
#define METIS_NOPTIONS
Definition: include/metis.h:175
METIS_OPTION_NO2HOP
@ METIS_OPTION_NO2HOP
Definition: include/metis.h:280
ComputeFillIn
void ComputeFillIn(graph_t *graph, idx_t *perm, idx_t *iperm, size_t *r_maxlnz, size_t *r_opc)
Definition: smbfactor.c:21
graph
NonlinearFactorGraph graph
Definition: doc/Code/OdometryExample.cpp:2
gk_GetCurMemoryUsed
size_t gk_GetCurMemoryUsed()
Definition: memory.c:233
NDPrintInfo
void NDPrintInfo(params_t *params, graph_t *graph)
Definition: ndmetis.c:112
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_PFACTOR
@ METIS_OPTION_PFACTOR
Definition: include/metis.h:285
graph_t
Definition: libmetis/struct.h:82
idx_t
int32_t idx_t
Definition: include/metis.h:101
gk_malloc_init
int gk_malloc_init()
Definition: memory.c:99
METIS_OPTION_CCORDER
@ METIS_OPTION_CCORDER
Definition: include/metis.h:284
METIS_OPTION_NSEPS
@ METIS_OPTION_NSEPS
Definition: include/metis.h:286


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:33:49