Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
ElmerCSC
GitHub Repository: ElmerCSC/elmerfem
Path: blob/devel/elmergrid/src/metis-5.1.0/programs/ndmetis.c
3206 views
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
/*************************************************************************/
20
/*! Let the game begin! */
21
/*************************************************************************/
22
int main(int argc, char *argv[])
23
{
24
idx_t options[METIS_NOPTIONS];
25
graph_t *graph;
26
idx_t *perm, *iperm;
27
params_t *params;
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
74
gk_malloc_init();
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();
84
gk_malloc_cleanup(0);
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
/*************************************************************************/
110
/*! This function prints run parameters */
111
/*************************************************************************/
112
void NDPrintInfo(params_t *params, graph_t *graph)
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
/*************************************************************************/
147
/*! This function does any post-ordering reporting */
148
/*************************************************************************/
149
void NDReportResults(params_t *params, graph_t *graph, idx_t *perm,
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
}
170
171