2
* Copyright 1994-2011, Regents of the University of Minnesota
6
* Drivers for the mesh-to-graph coversion routines
11
* $Id: m2gmetis.c 10498 2011-07-06 16:41:38Z karypis $
19
/*************************************************************************/
20
/*! Let the game begin! */
21
/*************************************************************************/
22
int main(int argc, char *argv[])
29
params = parse_cmdline(argc, argv);
31
gk_startcputimer(params->iotimer);
32
mesh = ReadMesh(params);
34
gk_stopcputimer(params->iotimer);
37
printf("*** Meshes with more than one balancing constraint are not supported yet.\n");
41
M2GPrintInfo(params, mesh);
43
graph = CreateGraph();
46
gk_startcputimer(params->parttimer);
48
switch (params->gtype) {
49
case METIS_GTYPE_DUAL:
50
status = METIS_MeshToDual(&mesh->ne, &mesh->nn, mesh->eptr, mesh->eind,
51
¶ms->ncommon, ¶ms->numflag, &graph->xadj, &graph->adjncy);
53
if (status == METIS_OK) {
54
graph->nvtxs = mesh->ne;
55
graph->nedges = graph->xadj[graph->nvtxs];
60
case METIS_GTYPE_NODAL:
61
status = METIS_MeshToNodal(&mesh->ne, &mesh->nn, mesh->eptr, mesh->eind,
62
¶ms->numflag, &graph->xadj, &graph->adjncy);
64
if (status == METIS_OK) {
65
graph->nvtxs = mesh->nn;
66
graph->nedges = graph->xadj[graph->nvtxs];
72
gk_stopcputimer(params->parttimer);
73
if (gk_GetCurMemoryUsed() != 0)
74
printf("***It seems that Metis did not free all of its memory! Report this.\n");
75
params->maxmemory = gk_GetMaxMemoryUsed();
78
if (status != METIS_OK) {
79
printf("\n***Metis returned with an error.\n");
83
gk_startcputimer(params->iotimer);
84
WriteGraph(graph, params->outfile);
85
gk_stopcputimer(params->iotimer);
87
M2GReportResults(params, mesh, graph);
92
gk_free((void **)¶ms->filename, ¶ms->outfile, ¶ms, LTERM);
96
/*************************************************************************/
97
/*! This function prints run parameters */
98
/*************************************************************************/
99
void M2GPrintInfo(params_t *params, mesh_t *mesh)
101
printf("******************************************************************************\n");
102
printf("%s", METISTITLE);
103
printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);
104
printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",
105
8*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));
107
printf("Mesh Information ------------------------------------------------------------\n");
108
printf(" Name: %s, #Elements: %"PRIDX", #Nodes: %"PRIDX"\n",
109
params->filename, mesh->ne, mesh->nn);
111
printf("Options ---------------------------------------------------------------------\n");
112
printf(" gtype=%s, ncommon=%"PRIDX", outfile=%s\n",
113
gtypenames[params->gtype], params->ncommon, params->outfile);
119
/*************************************************************************/
120
/*! This function does any post-metis reporting */
121
/*************************************************************************/
122
void M2GReportResults(params_t *params, mesh_t *mesh, graph_t *graph)
125
gk_startcputimer(params->reporttimer);
127
printf(" - #nvtxs: %"PRIDX", #edges: %"PRIDX"\n", graph->nvtxs, graph->nedges);
129
gk_stopcputimer(params->reporttimer);
132
printf("\nTiming Information ----------------------------------------------------------\n");
133
printf(" I/O: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->iotimer));
134
printf(" Partitioning: \t\t %7.3"PRREAL" sec (METIS time)\n", gk_getcputimer(params->parttimer));
135
printf(" Reporting: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->reporttimer));
136
printf("\nMemory Information ----------------------------------------------------------\n");
137
printf(" Max memory used:\t\t %7.3"PRREAL" MB\n", (real_t)(params->maxmemory/(1024.0*1024.0)));
138
printf("******************************************************************************\n");