00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #include "metisbin.h"
00016
00017
00018
00019
00021
00022 int main(int argc, char *argv[])
00023 {
00024 idx_t options[METIS_NOPTIONS];
00025 graph_t *graph;
00026 idx_t *perm, *iperm;
00027 params_t *params;
00028 int status=0;
00029
00030 params = parse_cmdline(argc, argv);
00031
00032 gk_startcputimer(params->iotimer);
00033 graph = ReadGraph(params);
00034 gk_stopcputimer(params->iotimer);
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046
00047
00048
00049 if (graph->ncon != 1) {
00050 printf("***The input graph contains %"PRIDX" constraints..\n"
00051 "***Ordering requires a graph with one constraint.\n", graph->ncon);
00052 exit(0);
00053 }
00054
00055 NDPrintInfo(params, graph);
00056
00057 perm = imalloc(graph->nvtxs, "main: perm");
00058 iperm = imalloc(graph->nvtxs, "main: iperm");
00059
00060 METIS_SetDefaultOptions(options);
00061 options[METIS_OPTION_CTYPE] = params->ctype;
00062 options[METIS_OPTION_IPTYPE] = params->iptype;
00063 options[METIS_OPTION_RTYPE] = params->rtype;
00064 options[METIS_OPTION_DBGLVL] = params->dbglvl;
00065 options[METIS_OPTION_UFACTOR] = params->ufactor;
00066 options[METIS_OPTION_NO2HOP] = params->no2hop;
00067 options[METIS_OPTION_COMPRESS] = params->compress;
00068 options[METIS_OPTION_CCORDER] = params->ccorder;
00069 options[METIS_OPTION_SEED] = params->seed;
00070 options[METIS_OPTION_NITER] = params->niter;
00071 options[METIS_OPTION_NSEPS] = params->nseps;
00072 options[METIS_OPTION_PFACTOR] = params->pfactor;
00073
00074 gk_malloc_init();
00075 gk_startcputimer(params->parttimer);
00076
00077 status = METIS_NodeND(&graph->nvtxs, graph->xadj, graph->adjncy, graph->vwgt,
00078 options, perm, iperm);
00079
00080 gk_stopcputimer(params->parttimer);
00081 if (gk_GetCurMemoryUsed() != 0)
00082 printf("***It seems that Metis did not free all of its memory! Report this.\n");
00083 params->maxmemory = gk_GetMaxMemoryUsed();
00084 gk_malloc_cleanup(0);
00085
00086
00087 if (status != METIS_OK) {
00088 printf("\n***Metis returned with an error.\n");
00089 }
00090 else {
00091 if (!params->nooutput) {
00092
00093 gk_startcputimer(params->iotimer);
00094 WritePermutation(params->filename, iperm, graph->nvtxs);
00095 gk_stopcputimer(params->iotimer);
00096 }
00097
00098 NDReportResults(params, graph, perm, iperm);
00099 }
00100
00101 FreeGraph(&graph);
00102 gk_free((void **)&perm, &iperm, LTERM);
00103 gk_free((void **)¶ms->filename, ¶ms->tpwgtsfile, ¶ms->tpwgts,
00104 ¶ms->ubvec, ¶ms, LTERM);
00105
00106 }
00107
00108
00109
00111
00112 void NDPrintInfo(params_t *params, graph_t *graph)
00113 {
00114 printf("******************************************************************************\n");
00115 printf("%s", METISTITLE);
00116 printf(" (HEAD: %s, Built on: %s, %s)\n", SVNINFO, __DATE__, __TIME__);
00117 printf(" size of idx_t: %zubits, real_t: %zubits, idx_t *: %zubits\n",
00118 8*sizeof(idx_t), 8*sizeof(real_t), 8*sizeof(idx_t *));
00119 printf("\n");
00120 printf("Graph Information -----------------------------------------------------------\n");
00121 printf(" Name: %s, #Vertices: %"PRIDX", #Edges: %"PRIDX"\n",
00122 params->filename, graph->nvtxs, graph->nedges/2);
00123
00124 printf("\n");
00125 printf("Options ---------------------------------------------------------------------\n");
00126 printf(" ctype=%s, rtype=%s, iptype=%s, seed=%"PRIDX", dbglvl=%"PRIDX"\n",
00127 ctypenames[params->ctype], rtypenames[params->rtype],
00128 iptypenames[params->iptype], params->seed, params->dbglvl);
00129
00130 printf(" ufactor=%.3f, pfactor=%.2f, no2hop=%s, ccorder=%s, compress=%s, , nooutput=%s\n",
00131 I2RUBFACTOR(params->ufactor),
00132 0.1*params->pfactor,
00133 (params->no2hop ? "YES" : "NO"),
00134 (params->ccorder ? "YES" : "NO"),
00135 (params->compress ? "YES" : "NO"),
00136 (params->nooutput ? "YES" : "NO")
00137 );
00138
00139 printf(" niter=%"PRIDX", nseps=%"PRIDX"\n", params->niter, params->nseps);
00140
00141 printf("\n");
00142 printf("Node-based Nested Dissection ------------------------------------------------\n");
00143 }
00144
00145
00146
00148
00149 void NDReportResults(params_t *params, graph_t *graph, idx_t *perm,
00150 idx_t *iperm)
00151 {
00152 size_t maxlnz, opc;
00153
00154 gk_startcputimer(params->reporttimer);
00155 ComputeFillIn(graph, perm, iperm, &maxlnz, &opc);
00156 printf(" Nonzeros: %6.3le \tOperation Count: %6.3le\n", (double)maxlnz, (double)opc);
00157
00158 gk_stopcputimer(params->reporttimer);
00159
00160
00161 printf("\nTiming Information ----------------------------------------------------------\n");
00162 printf(" I/O: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->iotimer));
00163 printf(" Ordering: \t\t %7.3"PRREAL" sec (METIS time)\n", gk_getcputimer(params->parttimer));
00164 printf(" Reporting: \t\t %7.3"PRREAL" sec\n", gk_getcputimer(params->reporttimer));
00165 printf("\nMemory Information ----------------------------------------------------------\n");
00166 printf(" Max memory used:\t\t %7.3"PRREAL" MB\n", (real_t)(params->maxmemory/(1024.0*1024.0)));
00167 printf("******************************************************************************\n");
00168
00169 }