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);
33  graph = ReadGraph(params);
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 
55  NDPrintInfo(params, graph);
56 
57  perm = imalloc(graph->nvtxs, "main: perm");
58  iperm = imalloc(graph->nvtxs, "main: iperm");
59 
60  METIS_SetDefaultOptions(options);
61  options[METIS_OPTION_CTYPE] = params->ctype;
62  options[METIS_OPTION_IPTYPE] = params->iptype;
63  options[METIS_OPTION_RTYPE] = params->rtype;
64  options[METIS_OPTION_DBGLVL] = params->dbglvl;
65  options[METIS_OPTION_UFACTOR] = params->ufactor;
66  options[METIS_OPTION_NO2HOP] = params->no2hop;
67  options[METIS_OPTION_COMPRESS] = params->compress;
68  options[METIS_OPTION_CCORDER] = params->ccorder;
69  options[METIS_OPTION_SEED] = params->seed;
70  options[METIS_OPTION_NITER] = params->niter;
71  options[METIS_OPTION_NSEPS] = params->nseps;
72  options[METIS_OPTION_PFACTOR] = params->pfactor;
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 
98  NDReportResults(params, graph, perm, iperm);
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 }
Definition: fis.c:15
#define I2RUBFACTOR(ufactor)
idx_t dbglvl
#define gk_startcputimer(tmr)
Definition: gk_macros.h:33
idx_t * xadj
#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
#define FreeGraph
Definition: rename.h:98
char * filename
Definition: fis.c:18
size_t gk_GetMaxMemoryUsed()
Definition: memory.c:246
real_t * tpwgts
void NDReportResults(params_t *params, graph_t *graph, idx_t *perm, idx_t *iperm)
Definition: ndmetis.c:149
idx_t nvtxs
idx_t idx_t idx_t idx_t idx_t idx_t * iperm
idx_t no2hop
int main(int argc, char *argv[])
Definition: ndmetis.c:22
#define METISTITLE
Definition: libmetis/defs.h:18
NonlinearFactorGraph graph
int METIS_SetDefaultOptions(idx_t *options)
Definition: auxapi.c:36
idx_t nooutput
real_t parttimer
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
params_t * parse_cmdline(int argc, char *argv[])
Definition: fis.c:194
#define PRIDX
idx_t nedges
#define METIS_NOPTIONS
size_t gk_GetCurMemoryUsed()
Definition: memory.c:233
idx_t ccorder
int32_t idx_t
char * tpwgtsfile
idx_t iptype
size_t maxmemory
idx_t idx_t idx_t idx_t idx_t * perm
int niter
Definition: gkgraph.c:17
idx_t ncon
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
graph_t * ReadGraph(params_t *params)
Definition: programs/io.c:22
real_t * ubvec
real_t iotimer
static char iptypenames[][15]
Definition: programs/defs.h:56
void gk_free(void **ptr1,...)
Definition: memory.c:202
idx_t * adjncy
static char ctypenames[][15]
Definition: programs/defs.h:50
idx_t compress
#define PRREAL
idx_t ufactor
real_t reporttimer
void NDPrintInfo(params_t *params, graph_t *graph)
Definition: ndmetis.c:112
int gk_malloc_init()
Definition: memory.c:99
void ComputeFillIn(graph_t *graph, idx_t *perm, idx_t *iperm, size_t *r_maxlnz, size_t *r_opc)
Definition: smbfactor.c:21
#define LTERM
Definition: gk_defs.h:14
void WritePermutation(char *fname, idx_t *iperm, idx_t n)
Definition: programs/io.c:477
idx_t pfactor
idx_t * vwgt


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