int METISNAMEU(METIS_NodeWND) ( const SCOTCH_Num * const n, const SCOTCH_Num * const xadj, const SCOTCH_Num * const adjncy, const SCOTCH_Num * const vwgt, const SCOTCH_Num * const numflag, const SCOTCH_Num * const options, SCOTCH_Num * const perm, SCOTCH_Num * const iperm) { SCOTCH_Graph grafdat; /* Scotch graph object to interface with libScotch */ SCOTCH_Ordering ordedat; /* Scotch ordering object to interface with libScotch */ SCOTCH_Strat stradat; int o; o = METIS_ERROR; /* Assume an error */ SCOTCH_graphInit (&grafdat); if (SCOTCH_graphBuild (&grafdat, *numflag, *n, xadj, xadj + 1, vwgt, NULL, xadj[*n] - *numflag, adjncy, NULL) == 0) { SCOTCH_stratInit (&stradat); #ifdef SCOTCH_DEBUG_ALL if (SCOTCH_graphCheck (&grafdat) == 0) /* TRICK: next instruction called only if graph is consistent */ #endif /* SCOTCH_DEBUG_ALL */ { if (SCOTCH_graphOrderInit (&grafdat, &ordedat, iperm, perm, /* MeTiS and Scotch have opposite definitions for (inverse) permutations */ NULL, NULL, NULL) == 0) { if (SCOTCH_graphOrderCompute (&grafdat, &ordedat, &stradat) == 0) o = METIS_OK; SCOTCH_graphOrderExit (&grafdat, &ordedat); } } SCOTCH_stratExit (&stradat); } SCOTCH_graphExit (&grafdat); return (o); }
int main ( int argc, char * argv[]) { SCOTCH_Num vertnbr; /* Number of vertices */ SCOTCH_Graph grafdat; /* Source graph */ SCOTCH_Ordering ordedat; /* Graph ordering */ SCOTCH_Num * permtab; /* Permutation array */ SCOTCH_Strat stradat; /* Ordering strategy */ SCOTCH_Num straval; char * straptr; int flagval; Clock runtime[2]; /* Timing variables */ int i, j; errorProg ("gord"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } flagval = C_FLAGNONE; /* Default behavior */ straval = 0; /* No strategy flags */ straptr = NULL; SCOTCH_stratInit (&stradat); for (i = 0; i < C_FILENBR; i ++) /* Set default stream pointers */ C_fileTab[i].pntr = (C_fileTab[i].mode[0] == 'r') ? stdin : stdout; for (i = 1; i < argc; i ++) { /* Loop for all option codes */ if ((argv[i][0] != '-') || (argv[i][1] == '\0') || (argv[i][1] == '.')) { /* If found a file name */ if (C_fileNum < C_FILEARGNBR) /* File name has been given */ C_fileTab[C_fileNum ++].name = argv[i]; else errorPrint ("main: too many file names given"); } else { /* If found an option name */ switch (argv[i][1]) { case 'C' : case 'c' : /* Strategy selection parameters */ for (j = 2; argv[i][j] != '\0'; j ++) { switch (argv[i][j]) { case 'B' : case 'b' : straval |= SCOTCH_STRATBALANCE; break; case 'Q' : case 'q' : straval |= SCOTCH_STRATQUALITY; break; case 'S' : case 's' : straval |= SCOTCH_STRATSPEED; break; case 'T' : case 't' : straval |= SCOTCH_STRATSAFETY; break; default : errorPrint ("main: invalid strategy selection option '%c'", argv[i][j]); } } break; case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'M' : /* Output separator mapping */ case 'm' : flagval |= C_FLAGMAPOUT; if (argv[i][2] != '\0') C_filenamemapout = &argv[i][2]; break; case 'O' : /* Ordering strategy */ case 'o' : straptr = &argv[i][2]; SCOTCH_stratExit (&stradat); SCOTCH_stratInit (&stradat); SCOTCH_stratGraphOrder (&stradat, straptr); break; case 'T' : /* Output separator tree */ case 't' : flagval |= C_FLAGTREOUT; if (argv[i][2] != '\0') C_filenametreout = &argv[i][2]; break; case 'V' : fprintf (stderr, "gord, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2004,2007,2008,2010-2012 IPB, Universite de Bordeaux, INRIA & CNRS, France\n"); fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n"); return (0); case 'v' : /* Output control info */ for (j = 2; argv[i][j] != '\0'; j ++) { switch (argv[i][j]) { case 'S' : case 's' : flagval |= C_FLAGVERBSTR; break; case 'T' : case 't' : flagval |= C_FLAGVERBTIM; break; default : errorPrint ("main: unprocessed parameter '%c' in '%s'", argv[i][j], argv[i]); } } break; default : errorPrint ("main: unprocessed option '%s'", argv[i]); } } } fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */ clockInit (&runtime[0]); clockStart (&runtime[0]); SCOTCH_graphInit (&grafdat); /* Create graph structure */ SCOTCH_graphLoad (&grafdat, C_filepntrsrcinp, -1, 2); /* Read source graph */ SCOTCH_graphSize (&grafdat, &vertnbr, NULL); /* Get graph characteristics */ if (straval != 0) { if (straptr != NULL) errorPrint ("main: options '-c' and '-o' are exclusive"); SCOTCH_stratGraphOrderBuild (&stradat, straval, 0, 0.2); } clockStop (&runtime[0]); /* Get input time */ clockInit (&runtime[1]); clockStart (&runtime[1]); if ((permtab = (SCOTCH_Num *) memAlloc (vertnbr * sizeof (SCOTCH_Num))) == NULL) { errorPrint ("main: out of memory"); return (1); } SCOTCH_graphOrderInit (&grafdat, &ordedat, permtab, NULL, NULL, NULL, NULL); /* Create ordering */ SCOTCH_graphOrderCompute (&grafdat, &ordedat, &stradat); /* Perform ordering */ clockStop (&runtime[1]); /* Get ordering time */ #ifdef SCOTCH_DEBUG_ALL if (SCOTCH_graphOrderCheck (&grafdat, &ordedat) != 0) return (1); #endif /* SCOTCH_DEBUG_ALL */ clockStart (&runtime[0]); SCOTCH_graphOrderSave (&grafdat, &ordedat, C_filepntrordout); /* Write ordering */ if (flagval & C_FLAGMAPOUT) /* If mapping wanted */ SCOTCH_graphOrderSaveMap (&grafdat, &ordedat, C_filepntrmapout); /* Write mapping */ if (flagval & C_FLAGTREOUT) /* If separator tree wanted */ SCOTCH_graphOrderSaveTree (&grafdat, &ordedat, C_filepntrtreout); /* Write tree */ clockStop (&runtime[0]); /* Get output time */ if (flagval & C_FLAGVERBSTR) { fprintf (C_filepntrlogout, "S\tStrat="); SCOTCH_stratSave (&stradat, C_filepntrlogout); putc ('\n', C_filepntrlogout); } if (flagval & C_FLAGVERBTIM) { fprintf (C_filepntrlogout, "T\tOrder\t\t%g\nT\tI/O\t\t%g\nT\tTotal\t\t%g\n", (double) clockVal (&runtime[1]), (double) clockVal (&runtime[0]), (double) clockVal (&runtime[0]) + (double) clockVal (&runtime[1])); } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ SCOTCH_graphOrderExit (&grafdat, &ordedat); SCOTCH_stratExit (&stradat); SCOTCH_graphExit (&grafdat); memFree (permtab); #ifdef COMMON_PTHREAD pthread_exit ((void *) 0); /* Allow potential (un)compression tasks to complete */ #endif /* COMMON_PTHREAD */ return (0); }
int main ( int argc, char * argv[]) { FILE * fileptr; SCOTCH_Graph grafdat; SCOTCH_Ordering ordedat; SCOTCH_Strat stradat; SCOTCH_Num baseval; SCOTCH_Num vertnbr; SCOTCH_Num vertnum; SCOTCH_Num listnbr; SCOTCH_Num listnum; SCOTCH_Num * listtab; SCOTCH_errorProg (argv[0]); if (SCOTCH_graphInit (&grafdat) != 0) { /* Initialize source graph */ SCOTCH_errorPrint ("main: cannot initialize graph"); return (1); } if ((fileptr = fopen (argv[1], "r")) == NULL) { SCOTCH_errorPrint ("main: cannot open file (1)"); return (1); } if (SCOTCH_graphLoad (&grafdat, fileptr, -1, 0) != 0) { /* Read source graph */ SCOTCH_errorPrint ("main: cannot load graph"); return (1); } fclose (fileptr); SCOTCH_graphData (&grafdat, &baseval, &vertnbr, NULL, NULL, NULL, NULL, NULL, NULL, NULL); listnbr = (vertnbr + 1) / 2; /* Only keep half of the vertices in induced graph */ if ((listtab = malloc (listnbr * sizeof (SCOTCH_Num))) == NULL) { SCOTCH_errorPrint ("main: out of memory (1)"); return (1); } for (listnum = 0, vertnum = baseval + (listnbr / 4); /* Keep only middle half of the vertices */ listnum < listnbr; listnum ++, vertnum ++) listtab[listnum] = vertnum; if ((fileptr = tmpfile ()) == NULL) { /* Open temporary file for resulting output */ SCOTCH_errorPrint ("main: cannot open file (2)"); return (1); } if (SCOTCH_stratInit (&stradat) != 0) { /* Initialize ordering strategy */ SCOTCH_errorPrint ("main: cannot initialize strategy"); return (1); } if (SCOTCH_graphOrderInit (&grafdat, &ordedat, NULL, NULL, NULL, NULL, NULL) != 0) { /* Initialize ordering */ SCOTCH_errorPrint ("main: cannot initialize ordering (1)"); return (1); } if (SCOTCH_graphOrderCompute (&grafdat, &ordedat, &stradat) != 0) { SCOTCH_errorPrint ("main: cannot order graph"); return (1); } if (SCOTCH_graphOrderCheck (&grafdat, &ordedat) != 0) { SCOTCH_errorPrint ("main: invalid ordering (1)"); return (1); } SCOTCH_graphOrderSave (&grafdat, &ordedat, fileptr); /* Test ordering data output routines */ SCOTCH_graphOrderSaveMap (&grafdat, &ordedat, fileptr); SCOTCH_graphOrderSaveTree (&grafdat, &ordedat, fileptr); SCOTCH_graphOrderExit (&grafdat, &ordedat); /* Free computed ordering */ if (SCOTCH_graphOrderInit (&grafdat, &ordedat, NULL, NULL, NULL, NULL, NULL) != 0) { /* Initialize ordering again */ SCOTCH_errorPrint ("main: cannot initialize ordering (2)"); return (1); } if (SCOTCH_graphOrderComputeList (&grafdat, &ordedat, listnbr, listtab, &stradat) != 0) { SCOTCH_errorPrint ("main: cannot order induced graph"); return (1); } if (SCOTCH_graphOrderCheck (&grafdat, &ordedat) != 0) { SCOTCH_errorPrint ("main: invalid ordering (2)"); return (1); } SCOTCH_graphOrderSave (&grafdat, &ordedat, fileptr); /* Test ordering data output routines */ SCOTCH_graphOrderSaveMap (&grafdat, &ordedat, fileptr); SCOTCH_graphOrderSaveTree (&grafdat, &ordedat, fileptr); free (listtab); SCOTCH_stratExit (&stradat); SCOTCH_graphOrderExit (&grafdat, &ordedat); SCOTCH_graphExit (&grafdat); return (0); }
*/ FORTRAN ( \ SCOTCHFGRAPHORDERINIT, scotchfgraphorderinit, ( \ const SCOTCH_Graph * const grafptr, \ SCOTCH_Ordering * const ordeptr, \ SCOTCH_Num * const permtab, \ SCOTCH_Num * const peritab, \ SCOTCH_Num * const cblkptr, \ SCOTCH_Num * const rangtab, \ SCOTCH_Num * const treetab, \ int * const revaptr), \ (grafptr, ordeptr, permtab, peritab, \ cblkptr, rangtab, treetab, revaptr)) { *revaptr = SCOTCH_graphOrderInit (grafptr, ordeptr, permtab, peritab, cblkptr, rangtab, treetab); } /* ** */ FORTRAN ( \ SCOTCHFGRAPHORDEREXIT, scotchfgraphorderexit, ( \ const SCOTCH_Graph * const grafptr, \ SCOTCH_Ordering * const ordeptr), \ (grafptr, ordeptr)) { SCOTCH_graphOrderExit (grafptr, ordeptr); }
int main ( int argc, char * argv[]) { SCOTCH_Graph grafdat; SCOTCH_Num vertnbr; SCOTCH_Num * verttab; SCOTCH_Num * vendtab; SCOTCH_Num edgenbr; SCOTCH_Num * edgetab; SCOTCH_Num baseval; SCOTCH_Ordering ordedat; SCOTCH_Num * permtab; SCOTCH_Num * peritab; int i; errorProg ("gotst"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } for (i = 0; i < C_FILENBR; i ++) /* Set default stream pointers */ C_fileTab[i].pntr = (C_fileTab[i].mode[0] == 'r') ? stdin : stdout; for (i = 1; i < argc; i ++) { /* Loop for all option codes */ if ((argv[i][0] != '-') || (argv[i][1] == '\0') || (argv[i][1] == '.')) { /* If found a file name */ if (C_fileNum < C_FILEARGNBR) /* File name has been given */ C_fileTab[C_fileNum ++].name = argv[i]; else { errorPrint ("main: too many file names given"); return (1); } } else { /* If found an option name */ switch (argv[i][1]) { case 'H' : /* Give help */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "gotst, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2004,2007,2008,2010,2011 ENSEIRB, INRIA & CNRS, France\n"); fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n"); return (0); default : errorPrint ("main: unprocessed option '%s'", argv[i]); return (1); } } } fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */ SCOTCH_graphInit (&grafdat); SCOTCH_graphLoad (&grafdat, C_filepntrgrfinp, -1, 3); SCOTCH_graphData (&grafdat, &baseval, &vertnbr, &verttab, &vendtab, NULL, NULL, &edgenbr, &edgetab, NULL); #ifdef SCOTCH_DEBUG_ALL if (vendtab != (verttab + 1)) { errorPrint ("main: graph should be compact"); return (1); } #endif /* SCOTCH_DEBUG_ALL */ if (memAllocGroup ((void **) (void *) &peritab, (size_t) (vertnbr * sizeof (SCOTCH_Num)), &permtab, (size_t) (vertnbr * sizeof (SCOTCH_Num)), NULL) == NULL) { errorPrint ("main: out of memory"); return (1); } SCOTCH_graphOrderInit (&grafdat, &ordedat, permtab, peritab, NULL, NULL, NULL); SCOTCH_graphOrderLoad (&grafdat, &ordedat, C_filepntrordinp); if (SCOTCH_graphOrderCheck (&grafdat, &ordedat) != 0) { errorPrint ("main: invalid ordering"); return (1); } factorView (baseval, vertnbr, verttab, edgenbr, edgetab, permtab, peritab, C_filepntrdatout); fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ memFree (peritab); SCOTCH_graphOrderExit (&grafdat, &ordedat); SCOTCH_graphExit (&grafdat); #ifdef COMMON_PTHREAD pthread_exit ((void *) 0); /* Allow potential (un)compression tasks to complete */ #endif /* COMMON_PTHREAD */ return (0); }
int main ( int argc, char * argv[]) { SCOTCH_Graph grafdat; SCOTCH_Num vertnbr; SCOTCH_Num * verttab; SCOTCH_Num * vendtab; SCOTCH_Num edgenbr; SCOTCH_Num * edgetab; SCOTCH_Num baseval; SCOTCH_Ordering ordedat; SCOTCH_Num * permtab; SCOTCH_Num * peritab; int i; errorProg ("order_eval"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } for (i = 0; i < C_FILENBR; i ++) /* Set default stream pointers */ C_fileTab[i].pntr = (C_fileTab[i].mode[0] == 'r') ? stdin : stdout; for (i = 1; i < argc; i ++) { /* Loop for all option codes */ if ((argv[i][0] != '+') && /* If found a file name */ ((argv[i][0] != '-') || (argv[i][1] == '\0'))) { if (C_fileNum < C_FILEARGNBR) /* A file name has been given */ C_fileTab[C_fileNum ++].name = argv[i]; else { errorPrint ("main: too many file names given"); return (1); } } else { /* If found an option name */ switch (argv[i][1]) { case 'H' : /* Give help */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "order_eval, from gotst, version 5 - F. Pellegrini\n"); fprintf (stderr, "Copyright 2004,2007 ENSEIRB, INRIA & CNRS, France\n"); fprintf (stderr, "This software is libre/free software under CeCILL-C -- see the user's manual for more information\n"); return (0); default : errorPrint ("main: unprocessed option (\"%s\")", argv[i]); return (1); } } } for (i = 0; i < C_FILENBR; i ++) { /* For all file names */ if ((C_fileTab[i].name[0] != '-') || /* If not standard stream */ (C_fileTab[i].name[1] != '\0')) { if ((C_fileTab[i].pntr = fopen (C_fileTab[i].name, C_fileTab[i].mode)) == NULL) { /* Open the file */ errorPrint ("main: cannot open file (%d)", i); return (1); } } } SCOTCH_graphInit (&grafdat); graphLoadMM (&grafdat, C_filepntrgrfinp); SCOTCH_graphData (&grafdat, &baseval, &vertnbr, &verttab, &vendtab, NULL, NULL, &edgenbr, &edgetab, NULL); #ifdef SCOTCH_DEBUG_ALL if (vendtab != (verttab + 1)) { errorPrint ("main: graph should be compact"); return (1); } #endif /* SCOTCH_DEBUG_ALL */ if (memAllocGroup ((void **) &peritab, (size_t) (vertnbr * sizeof (SCOTCH_Num)), &permtab, (size_t) (vertnbr * sizeof (SCOTCH_Num)), NULL) == NULL) { errorPrint ("main: out of memory"); return (1); } SCOTCH_graphOrderInit (&grafdat, &ordedat, permtab, peritab, NULL, NULL, NULL); SCOTCH_graphOrderLoad (&grafdat, &ordedat, C_filepntrordinp); if (SCOTCH_graphOrderCheck (&grafdat, &ordedat) != 0) { errorPrint ("main: invalid ordering"); return (1); } factorView (baseval, vertnbr, verttab, edgenbr, edgetab, permtab, peritab, C_filepntrdatout); #ifdef SCOTCH_DEBUG_ALL memFree (peritab); SCOTCH_graphOrderExit (&grafdat, &ordedat); SCOTCH_graphExit (&grafdat); for (i = 0; i < C_FILENBR; i ++) { /* For all file names */ if ((C_fileTab[i].name[0] != '-') || /* If not standard stream */ (C_fileTab[i].name[1] != '\0')) { fclose (C_fileTab[i].pntr); /* Close the stream */ } } #endif /* SCOTCH_DEBUG_ALL */ return (0); }