int main ( int argc, char * argv[]) { SCOTCH_Num e[3] = { 1, 1, 1 }; /* Mesh element dimensions */ SCOTCH_Num n[3]; /* Mesh node dimensions */ SCOTCH_Num c[3]; /* Vertex coordinates */ SCOTCH_Num velmnbr; /* First node number */ int flagval; /* Process flags */ int i; errorProg ("mmk_m3"); flagval = C_FLAGDEFAULT; /* Set default flags */ if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } fileBlockInit (C_fileTab, C_FILENBR); /* Set default stream pointers */ 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_paraNum < 3) { /* If number of parameters not reached */ if ((e[C_paraNum ++] = atoi (argv[i])) < 1) { /* Get the dimension */ errorPrint ("main: invalid dimension '%s'", argv[i]); return (1); } continue; /* Process the other parameters */ } if (C_fileNum < C_FILEARGNBR) /* A file name has been given */ fileBlockName (C_fileTab, C_fileNum ++) = argv[i]; else { errorPrint ("main: too many file names given"); return (1); } } else { /* If found an option name */ switch (argv[i][1]) { case 'G' : /* Output mesh geometry */ case 'g' : flagval |= C_FLAGGEOOUT; if (argv[i][2] != '\0') C_filenamegeoout = &argv[i][2]; break; case 'H' : /* Give program usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "mmk_m3, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2004,2007,2008,2010-2012,2014 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); default : errorPrint ("main: unprocessed option '%s'", argv[i]); return (1); } } } fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */ n[0] = e[0] + 1; n[1] = e[1] + 1; n[2] = e[2] + 1; velmnbr = e[0] * e[1] * e[2]; fprintf (C_filepntrmshout, "1\n" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n0\t" SCOTCH_NUMSTRING "\t000\n", /* Print mesh file header */ (SCOTCH_Num) velmnbr, (SCOTCH_Num) (n[0] * n[1] * n[2]), (SCOTCH_Num) ((velmnbr + (n[0] * n[1] * n[2]) - (n[0] * n[1] + n[0] * n[2] + n[1] * n[2]) + n[0] + n[1] + n[2] - 1) * 8), (SCOTCH_Num) velmnbr); for (c[2] = 0; c[2] < e[2]; c[2] ++) { /* Output element neighbor list */ for (c[1] = 0; c[1] < e[1]; c[1] ++) { for (c[0] = 0; c[0] < e[0]; c[0] ++) fprintf (C_filepntrmshout, "8\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n", /* Output neighbors of element */ (SCOTCH_Num) ((c[2] * n[1] + c[1]) * n[0] + c[0]), (SCOTCH_Num) ((c[2] * n[1] + c[1]) * n[0] + (c[0] + 1)), (SCOTCH_Num) ((c[2] * n[1] + (c[1] + 1)) * n[0] + c[0]), (SCOTCH_Num) ((c[2] * n[1] + (c[1] + 1)) * n[0] + (c[0] + 1)), (SCOTCH_Num) (((c[2] + 1) * n[1] + c[1]) * n[0] + c[0]), (SCOTCH_Num) (((c[2] + 1) * n[1] + c[1]) * n[0] + (c[0] + 1)), (SCOTCH_Num) (((c[2] + 1) * n[1] + (c[1] + 1)) * n[0] + c[0]), (SCOTCH_Num) (((c[2] + 1) * n[1] + (c[1] + 1)) * n[0] + (c[0] + 1))); } } for (c[2] = 0; c[2] < n[2]; c[2] ++) { /* Output node neighbor list */ for (c[1] = 0; c[1] < n[1]; c[1] ++) { for (c[0] = 0; c[0] < n[0]; c[0] ++) { fprintf (C_filepntrmshout, "%d", /* Output number of neighboring elements */ C_nghbTab[(((c[0] != 0) && (c[0] != e[0])) ? 0 : 1) + (((c[1] != 0) && (c[1] != e[1])) ? 0 : 1) + (((c[2] != 0) && (c[2] != e[2])) ? 0 : 1)]); if (c[2] != 0) { /* Output neighbors of nodes */ if (c[1] != 0) { if (c[0] != 0) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] - 1) * e[1] + (c[1] - 1)) * e[0] + (c[0] - 1))); if (c[0] != e[0]) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] - 1) * e[1] + (c[1] - 1)) * e[0] + c[0])); } if (c[1] != e[1]) { if (c[0] != 0) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] - 1) * e[1] + c[1]) * e[0] + (c[0] - 1))); if (c[0] != e[0]) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] - 1) * e[1] + c[1]) * e[0] + c[0])); } } if (c[2] != e[2]) { if (c[1] != 0) { if (c[0] != 0) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * e[1] + (c[1] - 1)) * e[0] + (c[0] - 1))); if (c[0] != e[0]) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * e[1] + (c[1] - 1)) * e[0] + c[0])); } if (c[1] != e[1]) { if (c[0] != 0) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * e[1] + c[1]) * e[0] + (c[0] - 1))); if (c[0] != e[0]) fprintf (C_filepntrmshout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * e[1] + c[1]) * e[0] + c[0])); } } fprintf (C_filepntrmshout, "\n"); } } } if (flagval & C_FLAGGEOOUT) { /* If geometry is wanted */ fprintf (C_filepntrgeoout, "3\n" SCOTCH_NUMSTRING "\n", /* Output geometry file header */ (SCOTCH_Num) (velmnbr + n[0] * n[1] * n[2])); for (c[2] = 0; c[2] < e[2]; c[2] ++) { /* Output element coordinates */ for (c[1] = 0; c[1] < e[1]; c[1] ++) { for (c[0] = 0; c[0] < e[0]; c[0] ++) fprintf (C_filepntrgeoout, SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING ".5\t" SCOTCH_NUMSTRING ".5\t" SCOTCH_NUMSTRING ".5\n", (SCOTCH_Num) (((c[2] * e[1]) + c[1]) * e[0] + c[0]), (SCOTCH_Num) c[0], (SCOTCH_Num) (e[1] - 1 - c[1]), (SCOTCH_Num) c[2]); } } for (c[2] = 0; c[2] <= e[2]; c[2] ++) { /* Output node coordinates */ for (c[1] = 0; c[1] <= e[1]; c[1] ++) { for (c[0] = 0; c[0] <= e[0]; c[0] ++) fprintf (C_filepntrgeoout, SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n", (SCOTCH_Num) (velmnbr + ((c[2] * n[1]) + c[1]) * n[0] + c[0]), (SCOTCH_Num) c[0], (SCOTCH_Num) (e[1] - c[1]), (SCOTCH_Num) c[2]); } } } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ #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_Num hdim = 1; /* Graph dimension */ SCOTCH_Num hnbr; /* Number of vertices */ SCOTCH_Num hbit; /* Most significant bit */ SCOTCH_Num hvrt; SCOTCH_Num hngb; int i; errorProg ("gmk_hy"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); exit (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_paraNum < 1) { /* If number of parameters not reached */ if ((hdim = atoi (argv[i])) < 1) { /* Get the dimension */ errorPrint ("main: invalid dimension '%s'", argv[i]); exit (1); } C_paraNum ++; continue; /* Process the other parameters */ } 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"); exit (1); } } else { /* If found an option name */ switch (argv[i][1]) { case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); exit (0); case 'V' : fprintf (stderr, "gmk_hy, 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]); exit (1); } } } fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */ hnbr = 1 << hdim; /* Compute number of vertices */ hbit = 1 << (hdim - 1); /* Compute highest bit value */ fprintf (C_filepntrsrcout, "0\n" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n0\t000\n", (SCOTCH_Num) hnbr, /* Print number of vertices */ (SCOTCH_Num) (hdim * hnbr)); /* Print number of edges (arcs) */ for (hvrt = 0; hvrt < hnbr; hvrt ++) { /* For all vertices */ fprintf (C_filepntrsrcout, "" SCOTCH_NUMSTRING "", (SCOTCH_Num) hdim); /* Output number of neighbors */ for (hngb = hbit; hngb > 0; hngb >>= 1) /* For all vertex bits */ fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, /* Write corresponding neighbor */ (SCOTCH_Num) (hvrt ^ hngb)); fprintf (C_filepntrsrcout, "\n"); } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ #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_Dgraph grafdat; int procglbnbr; int proclocnum; int protglbnum; /* Root process */ SCOTCH_Num vertnbr; SCOTCH_Num velomin; SCOTCH_Num velomax; SCOTCH_Num velosum; double veloavg; double velodlt; SCOTCH_Num degrmin; SCOTCH_Num degrmax; double degravg; double degrdlt; SCOTCH_Num edgenbr; SCOTCH_Num edlomin; SCOTCH_Num edlomax; SCOTCH_Num edlosum; double edloavg; double edlodlt; int flagval; int i; #ifdef SCOTCH_PTHREAD int thrdlvlreqval; int thrdlvlproval; #endif /* SCOTCH_PTHREAD */ errorProg ("dgtst"); #ifdef SCOTCH_PTHREAD thrdlvlreqval = MPI_THREAD_MULTIPLE; if (MPI_Init_thread (&argc, &argv, thrdlvlreqval, &thrdlvlproval) != MPI_SUCCESS) errorPrint ("main: Cannot initialize (1)"); if (thrdlvlreqval > thrdlvlproval) errorPrint ("main: MPI implementation is not thread-safe: recompile without SCOTCH_PTHREAD"); #else /* SCOTCH_PTHREAD */ if (MPI_Init (&argc, &argv) != MPI_SUCCESS) errorPrint ("main: Cannot initialize (2)"); #endif /* SCOTCH_PTHREAD */ MPI_Comm_size (MPI_COMM_WORLD, &procglbnbr); /* Get communicator data */ MPI_Comm_rank (MPI_COMM_WORLD, &proclocnum); protglbnum = 0; /* Assume root process is process 0 */ if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } flagval = C_FLAGNONE; 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"); } else { /* If found an option name */ switch (argv[i][1]) { #ifdef SCOTCH_DEBUG_ALL case 'D' : case 'd' : flagval |= C_FLAGDEBUG; break; #endif /* SCOTCH_DEBUG_ALL */ case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'R' : /* Root process (if necessary) */ case 'r' : protglbnum = atoi (&argv[i][2]); if ((protglbnum < 0) || (protglbnum >= procglbnbr) || ((protglbnum == 0) && (argv[i][2] != '0'))) errorPrint ("main: invalid root process number"); break; case 'V' : case 'v' : fprintf (stderr, "dgtst, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 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]); } } } #ifdef SCOTCH_DEBUG_ALL if ((flagval & C_FLAGDEBUG) != 0) { fprintf (stderr, "Proc %4d of %d, pid %d\n", proclocnum, procglbnbr, getpid ()); if (proclocnum == protglbnum) { /* Synchronize on keybord input */ char c; printf ("Waiting for key press...\n"); scanf ("%c", &c); } MPI_Barrier (MPI_COMM_WORLD); } #endif /* SCOTCH_DEBUG_ALL */ fileBlockOpenDist (C_fileTab, C_FILENBR, procglbnbr, proclocnum, protglbnum); /* Open all files */ SCOTCH_dgraphInit (&grafdat, MPI_COMM_WORLD); SCOTCH_dgraphLoad (&grafdat, C_filepntrsrcinp, -1, 0); SCOTCH_dgraphCheck (&grafdat); SCOTCH_dgraphSize (&grafdat, &vertnbr, NULL, &edgenbr, NULL); SCOTCH_dgraphStat (&grafdat, &velomin, &velomax, &velosum, &veloavg, &velodlt, °rmin, °rmax, °ravg, °rdlt, &edlomin, &edlomax, &edlosum, &edloavg, &edlodlt); if (C_filepntrdatout != NULL) { fprintf (C_filepntrdatout, "S\tVertex\tnbr=" SCOTCH_NUMSTRING "\n", (SCOTCH_Num) vertnbr); fprintf (C_filepntrdatout, "S\tVertex load\tmin=" SCOTCH_NUMSTRING "\tmax=" SCOTCH_NUMSTRING "\tsum=" SCOTCH_NUMSTRING "\tavg=%g\tdlt=%g\n", (SCOTCH_Num) velomin, (SCOTCH_Num) velomax, (SCOTCH_Num) velosum, veloavg, velodlt); fprintf (C_filepntrdatout, "S\tVertex degree\tmin=" SCOTCH_NUMSTRING "\tmax=" SCOTCH_NUMSTRING "\tsum=" SCOTCH_NUMSTRING "\tavg=%g\tdlt=%g\n", (SCOTCH_Num) degrmin, (SCOTCH_Num) degrmax, (SCOTCH_Num) edgenbr, degravg, degrdlt); fprintf (C_filepntrdatout, "S\tEdge\tnbr=" SCOTCH_NUMSTRING "\n", (SCOTCH_Num) (edgenbr / 2)); fprintf (C_filepntrdatout, "S\tEdge load\tmin=" SCOTCH_NUMSTRING "\tmax=" SCOTCH_NUMSTRING "\tsum=" SCOTCH_NUMSTRING "\tavg=%g\tdlt=%g\n", (SCOTCH_Num) edlomin, (SCOTCH_Num) edlomax, (SCOTCH_Num) edlosum, edloavg, edlodlt); } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ SCOTCH_dgraphExit (&grafdat); MPI_Finalize (); #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 ("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_Num hdim; /* Hypercube dimension */ SCOTCH_Num hnbr; /* Number of hypercube vertices */ SCOTCH_Num hmax; /* Number of domains */ SCOTCH_Num hv0, hv1; SCOTCH_Num i, j; errorProg ("amk_hy"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } hdim = 1; /* Preset hypercube dimension */ 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_paraNum < 1) { /* If number of parameters not reached */ if ((hdim = atoi (argv[i])) < 1) { /* Get the dimension */ errorPrint ("main: invalid dimension '%s'", argv[i]); return (1); } C_paraNum ++; continue; /* Process the other parameters */ } 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 the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "amk_hy, 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 */ hnbr = 1 << hdim; /* Compute number of terminals */ hmax = (1 << (hdim + 1)) - 1; /* Maximum terminal value */ fprintf (C_filepntrtgtout, "deco\n0\n" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n", /* Print the file header */ (SCOTCH_Num) hnbr, /* Print number of terminal domains */ (SCOTCH_Num) hmax); /* Print the biggest terminal value */ for (i = 0; i < hnbr; i ++) /* For all vertices */ fprintf (C_filepntrtgtout, SCOTCH_NUMSTRING "\t1\t" SCOTCH_NUMSTRING "\n", (SCOTCH_Num) i, /* Print terminal label */ (SCOTCH_Num) (hnbr + i)); /* Print terminal number */ for (hv0 = 1; hv0 < hnbr; hv0 ++) { /* For all vertices */ for (hv1 = 0; hv1 < hv0; hv1 ++) { for (i = hv0 ^ hv1, j = 0; i > 0; i >>=1) j += (i & 1); fprintf (C_filepntrtgtout, (hv1 == 0) ? SCOTCH_NUMSTRING : " " SCOTCH_NUMSTRING, (SCOTCH_Num) j); } fprintf (C_filepntrtgtout, "\n"); } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ #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[]) { int flagval; /* Process flags */ SCOTCH_Num baseval; /* Base value */ SCOTCH_Num d[3] = { 1, 1, 1 }; /* Mesh dimensions */ SCOTCH_Num c[3]; /* Vertex coordinates */ int i; errorProg ("gmk_m3"); flagval = C_FLAGDEFAULT; /* Set default flags */ baseval = 0; 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_paraNum < 3) { /* If number of parameters not reached */ if ((d[C_paraNum ++] = atoi (argv[i])) < 1) { /* Get the dimension */ errorPrint ("main: invalid dimension '%s'", argv[i]); return (1); } continue; /* Process the other parameters */ } 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 'B' : /* Set base value */ case 'b' : baseval = (SCOTCH_Num) atol (&argv[i][2]); if ((baseval < 0) || (baseval > 1)) { errorPrint ("main: invalid base value '" SCOTCH_NUMSTRING "'", (SCOTCH_Num) baseval); } break; case 'G' : /* Output the geometry */ case 'g' : flagval |= C_FLAGGEOOUT; if (argv[i][2] != '\0') C_filenamegeoout = &argv[i][2]; break; case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'T' : /* Build a torus */ case 't' : flagval |= C_FLAGTORUS; break; case 'V' : fprintf (stderr, "gmk_m3, 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 */ if (flagval & C_FLAGTORUS) { /* Build a torus */ fprintf (C_filepntrsrcout, "0\n" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n" SCOTCH_NUMSTRING "\t000\n", (SCOTCH_Num) (d[0] * d[1] * d[2]), /* Print number of vertices */ (SCOTCH_Num) ((6 * d[0] * d[1] * d[2]) - /* Print number of edges (arcs) */ ((d[0] < 3) ? (2 * d[1] * d[2]) : 0) - ((d[1] < 3) ? (2 * d[0] * d[2]) : 0) - ((d[2] < 3) ? (2 * d[0] * d[1]) : 0)), (SCOTCH_Num) baseval); for (c[2] = 0; c[2] < d[2]; c[2] ++) { /* Output neighbor list */ for (c[1] = 0; c[1] < d[1]; c[1] ++) { for (c[0] = 0; c[0] < d[0]; c[0] ++) { fprintf (C_filepntrsrcout, SCOTCH_NUMSTRING, (SCOTCH_Num) (((d[0] > 2) ? 3 : d[0]) + /* Output number of neighbors */ ((d[1] > 2) ? 3 : d[1]) + ((d[2] > 2) ? 3 : d[2]) - 3)); if (d[2] > 2) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, /* Output the neighbors */ (SCOTCH_Num) ((((c[2] + d[2] - 1) % d[2]) * d[1] + c[1]) * d[0] + c[0] + baseval)); if (d[1] > 2) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + ((c[1] + d[1] - 1) % d[1])) * d[0] + c[0] + baseval)); if (d[0] > 2) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] * d[1] + c[1]) * d[0] + (c[0] + d[0] - 1) % d[0])) + baseval); if (d[0] > 1) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + c[1]) * d[0] + ((c[0] + 1) % d[0]) + baseval)); if (d[1] > 1) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + ((c[1] + 1) % d[1])) * d[0] + c[0] + baseval)); if (d[2] > 1) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((((c[2] + 1) % d[2]) * d[1] + c[1]) * d[0] + c[0] + baseval)); fprintf (C_filepntrsrcout, "\n"); } } } } else { /* Build a mesh */ fprintf (C_filepntrsrcout, "0\n" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n" SCOTCH_NUMSTRING "\t000\n", (SCOTCH_Num) (d[0] * d[1] * d[2]), (SCOTCH_Num) ((d[0] * d[1] * d[2] * 3 - (d[0] * d[1] + d[0] * d[2] + d[1] * d[2])) * 2), (SCOTCH_Num) baseval); for (c[2] = 0; c[2] < d[2]; c[2] ++) { /* Output neighbor list */ for (c[1] = 0; c[1] < d[1]; c[1] ++) { for (c[0] = 0; c[0] < d[0]; c[0] ++) { fprintf (C_filepntrsrcout, "%d", ((c[0] == 0) ? 0 : 1) + /* Output number of neighbors */ ((c[0] == (d[0] - 1)) ? 0 : 1) + ((c[1] == 0) ? 0 : 1) + ((c[1] == (d[1] - 1)) ? 0 : 1) + ((c[2] == 0) ? 0 : 1) + ((c[2] == (d[2] - 1)) ? 0 : 1)); if (c[2] != 0) /* Output the neighbors */ fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] - 1) * d[1] + c[1]) * d[0] + c[0] + baseval)); if (c[1] != 0) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + c[1] - 1) * d[0] + c[0] + baseval)); if (c[0] != 0) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + c[1]) * d[0] + c[0] - 1 + baseval)); if (c[0] != (d[0] - 1)) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + c[1]) * d[0] + c[0] + 1 + baseval)); if (c[1] != (d[1] - 1)) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) ((c[2] * d[1] + c[1] + 1) * d[0] + c[0] + baseval)); if (c[2] != (d[2] - 1)) fprintf (C_filepntrsrcout, "\t" SCOTCH_NUMSTRING, (SCOTCH_Num) (((c[2] + 1) * d[1] + c[1]) * d[0] + c[0] + baseval)); fprintf (C_filepntrsrcout, "\n"); } } } } if (flagval & C_FLAGGEOOUT) { /* If geometry is wanted */ fprintf (C_filepntrgeoout, "3\n" SCOTCH_NUMSTRING "\n", /* Output geometry file header */ (SCOTCH_Num) (d[0] * d[1] * d[2])); for (c[2] = 0; c[2] < d[2]; c[2] ++) { /* Output mesh coordinates */ for (c[1] = 0; c[1] < d[1]; c[1] ++) { for (c[0] = 0; c[0] < d[0]; c[0] ++) fprintf (C_filepntrgeoout, SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n", (SCOTCH_Num) ((c[2] * d[1] + c[1]) * d[0] + c[0] + baseval), (SCOTCH_Num) c[0], (SCOTCH_Num) (d[1] - 1 - c[1]), (SCOTCH_Num) c[2]); } } } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ #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_Geom geomdat; int i, j; errorProg ("gcv"); 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 'I' : /* Select input file type */ case 'i' : for (j = 0; C_inpFormatTab[j].code != '\0'; j ++) { /* Find proper format code */ if (C_inpFormatTab[j].code == argv[i][2]) { C_inpFormatType = j; C_inpFormatData = &argv[i][3]; break; } } if (C_inpFormatTab[j].code == '\0') { errorPrint ("main: unprocessed option (\"%s\")", argv[i]); return (1); } break; case 'O' : /* Select input file type */ case 'o' : for (j = 0; C_outFormatTab[j].code != '\0'; j ++) { /* Find proper format code */ if (C_outFormatTab[j].code == argv[i][2]) { C_outFormatType = j; C_outFormatData = &argv[i][3]; break; } } if (C_inpFormatTab[j].code == '\0') { errorPrint ("main: unprocessed option (\"%s\")", argv[i]); return (1); } break; case 'V' : fprintf (stderr, "gcv, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2004,2007,2008,2010 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_geomInit (&geomdat); C_inpFormatTab[C_inpFormatType].func (&grafdat, &geomdat, C_filepntrsrcinp, NULL, C_inpFormatData); #ifdef SCOTCH_DEBUG_ALL if (SCOTCH_graphCheck (&grafdat) != 0) { errorPrint ("main: bad graph structure"); return (1); } #endif /* SCOTCH_DEBUG_ALL */ C_outFormatTab[C_outFormatType].func (&grafdat, &geomdat, C_filepntrsrcout, C_filepntrgeoout, C_outFormatData); fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ SCOTCH_geomExit (&geomdat); 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_Num vnodnbr; /* Number of nodes */ SCOTCH_Mesh meshdat; /* 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 ("mord"); intRandInit (); 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"); return (1); } } 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); if ((SCOTCH_stratMeshOrder (&stradat, straptr)) != 0) { errorPrint ("main: invalid ordering strategy"); return (1); } break; case 'V' : fprintf (stderr, "mord, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2004,2007,2008,2010 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); break; 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]); return (1); } } break; default : errorPrint ("main: unprocessed option (\"%s\")", argv[i]); return (1); } } } fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */ clockInit (&runtime[0]); clockStart (&runtime[0]); SCOTCH_meshInit (&meshdat); /* Create mesh structure */ SCOTCH_meshLoad (&meshdat, C_filepntrsrcinp, -1); /* Read source mesh */ SCOTCH_meshSize (&meshdat, NULL, &vnodnbr, NULL); /* Get number of nodes */ if (straval != 0) { if (straptr != NULL) errorPrint ("main: options '-c' and '-o' are exclusive"); SCOTCH_stratMeshOrderBuild (&stradat, straval, 0.1); } clockStop (&runtime[0]); /* Get input time */ clockInit (&runtime[1]); clockStart (&runtime[1]); if ((permtab = (SCOTCH_Num *) memAlloc (vnodnbr * sizeof (SCOTCH_Num))) == NULL) { errorPrint ("main: out of memory"); return (1); } SCOTCH_meshOrderInit (&meshdat, &ordedat, permtab, NULL, NULL, NULL, NULL); /* Create ordering */ SCOTCH_meshOrderCompute (&meshdat, &ordedat, &stradat); /* Perform ordering */ clockStop (&runtime[1]); /* Get ordering time */ #ifdef SCOTCH_DEBUG_ALL if (SCOTCH_meshOrderCheck (&meshdat, &ordedat) != 0) return (1); #endif /* SCOTCH_DEBUG_ALL */ clockStart (&runtime[0]); SCOTCH_meshOrderSave (&meshdat, &ordedat, C_filepntrordout); /* Write ordering */ if (flagval & C_FLAGMAPOUT) /* If mapping wanted */ SCOTCH_meshOrderSaveMap (&meshdat, &ordedat, C_filepntrmapout); /* Write mapping */ 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_meshOrderExit (&meshdat, &ordedat); SCOTCH_stratExit (&stradat); SCOTCH_meshExit (&meshdat); 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[]) { int wght[2] = {1, 1}; /* Vertex weights */ int i; errorProg ("amk_p2"); 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_paraNum < 2) { /* If number of parameters not reached */ if ((wght[C_paraNum ++] = atoi (argv[i])) < 1) { /* Get vertex weights */ errorPrint ("main: invalid weight '%s'", argv[i]); return (1); } continue; /* Process remaining parameters */ } 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 the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "amk_p2, 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 */ fprintf (C_filepntrtgtout, "cmpltw\t2\t" SCOTCH_NUMSTRING "\t" SCOTCH_NUMSTRING "\n", /* Print target description */ (SCOTCH_Num) wght[0], (SCOTCH_Num) wght[1]); fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ #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; /* Source graph */ int baseval; int i; errorProg ("gbase"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); exit (0); } fileBlockInit (C_fileTab, C_FILENBR); /* Set default stream pointers */ 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_paraNum < 1) { /* If number of parameters not reached */ C_paraNum ++; /* One more parameter */ baseval = atoi (argv[i]); /* Get the base value */ if ((baseval < 0) || (baseval > 1)) { errorPrint ("main: invalid base value '%s'", argv[i]); return (1); } continue; /* Process the other parameters */ } if (C_fileNum < C_FILEARGNBR) /* A file name has been given */ fileBlockName (C_fileTab, C_fileNum ++) = argv[i]; else { errorPrint ("main: too many file names given"); exit (1); } } else { /* If found an option name */ switch (argv[i][1]) { case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); exit (0); case 'V' : fprintf (stderr, "gbase, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2007,2008,2010-2012,2014,2018 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); default : errorPrint ("main: unprocessed option '%s'", argv[i]); exit (1); } } } fileBlockOpen (C_fileTab, C_FILENBR); /* Open all files */ SCOTCH_graphInit (&grafdat); SCOTCH_graphLoad (&grafdat, C_filepntrsrcinp, (SCOTCH_Num) baseval, 0); SCOTCH_graphSave (&grafdat, C_filepntrsrcout); fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ SCOTCH_graphExit (&grafdat); return (0); }
int main ( int argc, char * argv[]) { FILE * fileptr; FILE * stream; Wgraph wgrfdat; Strat * straptr; double clktime[2]; double runtime; struct timespec tp; Gnum partnbr; Gnum partval; Gnum vertnum; Gnum comploadsum; Gnum comploadavg; Gnum comploadmax; Gnum comploadmin; int i; char c; const Gnum * restrict vlbltax; errorProg (argv[0]); if (argc != 5) { errorPrint ("main: usage is \"%s <nparts> <input source graph file> <output mapping file> <strategy>\"\n", argv[0]); exit (1); } fprintf (stderr, "pid %d\n", getpid ()); printf ("Waiting for key press...\n"); scanf ("%c", &c); if (graphInit (&wgrfdat.s) != 0) { /* Initialize source graph */ errorPrint ("main: cannot initialize graph"); return (1); } if ((partnbr = atoi (argv[1])) < 1) { errorPrint ("main: invalid number of parts (\"%s\")", argv[1]); return (1); } fileptr = NULL; if ((fileptr = fopen (argv[2], "r")) == NULL) { errorPrint ("main: cannot open graph file"); return (1); } if (graphLoad (&wgrfdat.s, fileptr, -1, 0) != 0) { errorPrint ("main: cannot load graph file"); return (1); } if (fileptr != NULL) fclose (fileptr); wgraphInit (&wgrfdat, &wgrfdat.s, partnbr); /* wgraphZero (&wgrfdat); TODO to clean? */ if ((straptr = stratInit (&wgraphpartststratab, argv[4])) == NULL) { errorPrint ("main: cannot initialize strategy"); return (1); } /* Init clock. */ clktime[0] = clktime[1] = runtime = 0; /* Start clock. */ clock_gettime (CLOCK_REALTIME, &tp); /* Elapsed time */ clktime[0] = ((double) tp.tv_sec + (double) tp.tv_nsec * 1.0e-9L); wgraphPartSt (&wgrfdat, straptr); /* Stop clock. */ clock_gettime (CLOCK_REALTIME, &tp); /* Elapsed time */ clktime[1] = ((double) tp.tv_sec + (double) tp.tv_nsec * 1.0e-9L); runtime += (clktime[1] - clktime[0]); comploadsum = comploadavg = comploadmax = 0; comploadmin = GNUMMAX; for (i = 0; i < partnbr; i ++) { comploadsum += wgrfdat.compload[i]; if (wgrfdat.compload[i] > comploadmax) comploadmax = wgrfdat.compload[i]; if (wgrfdat.compload[i] < comploadmin) comploadmin = wgrfdat.compload[i]; } comploadavg = comploadsum / wgrfdat.partnbr; for (partval = 0; partval < wgrfdat.partnbr; partval ++) /* for each part */ printf("\033[0;33mcompload[%d] %d %d\033[0m\n", partval, wgrfdat.compload[partval], wgrfdat.compsize[partval]); printf ("\033[0;32mCompLoad(max/avg)=%g,\t(min/avg)=%g\n", ((double) comploadmax / (double) comploadavg), ((double) comploadmin / (double) comploadavg)); printf ("\033[0;32mFronLoad=%ld\n", (long) wgrfdat.fronload); printf ("\033[0;32mTime=%f\n", runtime); stream = NULL; if ((stream = fopen (argv[3], "w")) == NULL) { errorPrint ("main: cannot open graph file"); return (1); } vlbltax = (wgrfdat.s.vlbltax != NULL) ? (wgrfdat.s.vlbltax) : NULL; if (fprintf (stream, "%ld\n", (long) wgrfdat.s.vertnbr) == EOF) { errorPrint ("main: bad output (1)"); return (1); } for (vertnum = wgrfdat.s.baseval; vertnum < wgrfdat.s.vertnnd; vertnum ++) { if (fprintf (stream, "%ld\t%ld\n", (long) ((vlbltax != NULL) ? vlbltax[vertnum] : vertnum), (long) wgrfdat.parttax[vertnum]) == EOF) { errorPrint ("main: bad output (2)"); return (1); } } if (stream != NULL) fclose (stream); wgrfdat.parttax = NULL; /* Do not free parttax as grouped with frontab */ wgraphExit (&wgrfdat); stratExit (straptr); exit (0); }
int main ( int argc, char * argv[]) { SCOTCH_Graph * cgrfptr; SCOTCH_Graph cgrfdat; SCOTCH_Dgraph dgrfdat; int procglbnbr; int proclocnum; int protglbnum; /* Root process */ int flagval; int i; int reduloctab[2]; int reduglbtab[2]; #ifdef SCOTCH_PTHREAD int thrdlvlreqval; int thrdlvlproval; #endif /* SCOTCH_PTHREAD */ errorProg ("dggath"); #ifdef SCOTCH_PTHREAD thrdlvlreqval = MPI_THREAD_MULTIPLE; if (MPI_Init_thread (&argc, &argv, thrdlvlreqval, &thrdlvlproval) != MPI_SUCCESS) errorPrint ("main: Cannot initialize (1)"); if (thrdlvlreqval > thrdlvlproval) errorPrint ("main: MPI implementation is not thread-safe: recompile without SCOTCH_PTHREAD"); #else /* SCOTCH_PTHREAD */ if (MPI_Init (&argc, &argv) != MPI_SUCCESS) errorPrint ("main: Cannot initialize (2)"); #endif /* SCOTCH_PTHREAD */ MPI_Comm_size (MPI_COMM_WORLD, &procglbnbr); /* Get communicator data */ MPI_Comm_rank (MPI_COMM_WORLD, &proclocnum); protglbnum = 0; /* Assume root process is process 0 */ if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } flagval = C_FLAGNONE; 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' : flagval |= C_FLAGCHECK; break; #ifdef SCOTCH_DEBUG_ALL case 'D' : case 'd' : flagval |= C_FLAGDEBUG; break; #endif /* SCOTCH_DEBUG_ALL */ case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'R' : /* Root process (if necessary) */ case 'r' : protglbnum = atoi (&argv[i][2]); if ((protglbnum < 0) || (protglbnum >= procglbnbr) || ((protglbnum == 0) && (argv[i][2] != '0'))) { errorPrint ("main: invalid root process number"); } break; case 'V' : case 'v' : fprintf (stderr, "dggath, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2008,2010 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]); } } } #ifdef SCOTCH_DEBUG_ALL if ((flagval & C_FLAGDEBUG) != 0) { fprintf (stderr, "Proc %4d of %d, pid %d\n", proclocnum, procglbnbr, getpid ()); if (proclocnum == protglbnum) { /* Synchronize on keybord input */ char c; printf ("Waiting for key press...\n"); scanf ("%c", &c); } MPI_Barrier (MPI_COMM_WORLD); } #endif /* SCOTCH_DEBUG_ALL */ fileBlockOpenDist (C_fileTab, C_FILENBR, procglbnbr, proclocnum, protglbnum); /* Open all files */ if (C_filepntrsrcout == NULL) { cgrfptr = NULL; reduloctab[0] = reduloctab[1] = 0; } else { cgrfptr = &cgrfdat; reduloctab[0] = 1; reduloctab[1] = proclocnum; } if (MPI_Allreduce (reduloctab, reduglbtab, 2, MPI_INT, MPI_SUM, MPI_COMM_WORLD) != MPI_SUCCESS) errorPrint ("main: communication error"); if (reduglbtab[0] != 1) errorPrint ("main: should have only one root"); if (reduglbtab[1] != protglbnum) errorPrint ("main: root process mismatch"); SCOTCH_dgraphInit (&dgrfdat, MPI_COMM_WORLD); SCOTCH_dgraphLoad (&dgrfdat, C_filepntrsrcinp, -1, 0); if ((flagval & C_FLAGCHECK) != 0) SCOTCH_dgraphCheck (&dgrfdat); SCOTCH_graphInit (&cgrfdat); SCOTCH_dgraphGather (&dgrfdat, cgrfptr); if (cgrfptr != NULL) SCOTCH_graphSave (cgrfptr, C_filepntrsrcout); fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ SCOTCH_graphExit (&cgrfdat); SCOTCH_dgraphExit (&dgrfdat); MPI_Finalize (); #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[]) { MPI_Comm proccomm; int procglbnbr; /* Number of processes sharing graph data */ int proclocnum; /* Number of this process */ SCOTCH_Num vertglbnbr; SCOTCH_Num vertlocnbr; SCOTCH_Num baseval; SCOTCH_Dgraph grafdat; SCOTCH_Dgraph coargrafdat; SCOTCH_Num coarvertglbnbr; SCOTCH_Num coarvertlocnbr; double coarrat; FILE * file; #ifdef SCOTCH_PTHREAD int thrdlvlreqval; int thrdlvlproval; #endif /* SCOTCH_PTHREAD */ int i; errorProg (argv[0]); #ifdef SCOTCH_PTHREAD thrdlvlreqval = MPI_THREAD_MULTIPLE; if (MPI_Init_thread (&argc, &argv, thrdlvlreqval, &thrdlvlproval) != MPI_SUCCESS) errorPrint ("main: Cannot initialize (1)"); if (thrdlvlreqval > thrdlvlproval) errorPrint ("main: MPI implementation is not thread-safe: recompile without SCOTCH_PTHREAD"); #else /* SCOTCH_PTHREAD */ if (MPI_Init (&argc, &argv) != MPI_SUCCESS) errorPrint ("main: Cannot initialize (2)"); #endif /* SCOTCH_PTHREAD */ if (argc != 2) { errorPrint ("main: invalid number of parameters"); exit (1); } proccomm = MPI_COMM_WORLD; MPI_Comm_size (proccomm, &procglbnbr); /* Get communicator data */ MPI_Comm_rank (proccomm, &proclocnum); fprintf (stderr, "Proc %2d of %2d, pid %d\n", proclocnum, procglbnbr, getpid ()); #ifndef SCOTCH_CHECK_AUTO if (proclocnum == 0) { /* Synchronize on keybord input */ char c; printf ("Waiting for key press...\n"); scanf ("%c", &c); } #endif /* SCOTCH_CHECK_AUTO */ if (MPI_Barrier (proccomm) != MPI_SUCCESS) { /* Synchronize for debug */ errorPrint ("main: cannot communicate"); return (1); } if (SCOTCH_dgraphInit (&grafdat, proccomm) != 0) { /* Initialize source graph */ errorPrint ("main: cannot initialize graph (1)"); return (1); } file = NULL; if ((proclocnum == 0) && ((file = fopen (argv[1], "r")) == NULL)) { errorPrint ("main: cannot open graph file"); return (1); } if (SCOTCH_dgraphLoad (&grafdat, file, 0, 0) != 0) { errorPrint ("main: cannot load graph"); return (1); } if (file != NULL) fclose (file); if (MPI_Barrier (proccomm) != MPI_SUCCESS) { /* Synchronize for debug */ errorPrint ("main: cannot communicate"); return (1); } SCOTCH_dgraphData (&grafdat, NULL, &vertglbnbr, &vertlocnbr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); coarrat = 0.8; /* Lazy coarsening ratio */ for (i = 0; i < 3; i ++) { /* For all test cases */ SCOTCH_Num * multloctab; SCOTCH_Num multlocsiz; SCOTCH_Num foldval; char * foldstr; char * coarstr; int procnum; int o; switch (i) { case 0 : multlocsiz = vertlocnbr; foldval = SCOTCH_COARSENNONE; foldstr = "Plain coarsening"; break; case 1 : multlocsiz = (SCOTCH_Num) (((double) vertglbnbr * coarrat) / (double) (procglbnbr / 2)) + 1; foldval = SCOTCH_COARSENFOLD; foldstr = "Folding"; break; case 2 : multlocsiz = (SCOTCH_Num) (((double) vertglbnbr * coarrat) / (double) (procglbnbr / 2)) + 1; foldval = SCOTCH_COARSENFOLDDUP; foldstr = "Folding with duplication"; break; } if (proclocnum == 0) printf ("%s\n", foldstr); if ((multloctab = malloc (multlocsiz * 2 * sizeof (SCOTCH_Num))) == NULL) { errorPrint ("main: cannot allocate multinode array"); return (1); } if (SCOTCH_dgraphInit (&coargrafdat, proccomm) != 0) { /* Initialize band graph */ errorPrint ("main: cannot initialize graph (2)"); return (1); } o = SCOTCH_dgraphCoarsen (&grafdat, 0, coarrat, foldval, &coargrafdat, multloctab); SCOTCH_dgraphData (&coargrafdat, NULL, &coarvertglbnbr, &coarvertlocnbr, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL); for (procnum = 0; procnum < procglbnbr; procnum ++) { switch (o) { case 0 : coarstr = "coarse graph created"; break; case 1 : coarstr = "graph could not be coarsened"; break; case 2 : coarstr = "folded graph not created here"; break; case 3 : coarstr = "cannot create coarse graph"; break; } if (procnum == proclocnum) printf ("%d: %s (%ld / %ld / %ld)\n", procnum, coarstr, (long) multlocsiz, (long) coarvertlocnbr, (long) vertlocnbr); MPI_Barrier (proccomm); } if (coarvertlocnbr > multlocsiz) { errorPrint ("main: invalid local multinode array size"); return (1); } SCOTCH_dgraphExit (&coargrafdat); free (multloctab); } SCOTCH_dgraphExit (&grafdat); MPI_Finalize (); exit (0); }
int main ( int argc, char * argv[]) { SCOTCH_Strat bipastrat; /* Bipartitioning strategy */ SCOTCH_Arch archdat; /* Target (terminal) architecture */ SCOTCH_Graph grafdat; /* Source graph to turn into architecture */ SCOTCH_Num vertnbr; /* Number of vertices in graph */ SCOTCH_Num * vlbltab; /* Pointer to vertex label array, if present */ SCOTCH_Num listnbr; /* Size of list array */ SCOTCH_Num * listtab; /* Pointer to list array */ C_VertSort * sorttab; /* Vertex label sort area */ SCOTCH_Num baseval; int flagval; /* Process flags */ int i; errorProg ("amk_grf"); intRandInit (); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } flagval = C_FLAGNONE; SCOTCH_stratInit (&bipastrat); 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 'B' : /* Bipartitioning strategy */ case 'b' : SCOTCH_stratExit (&bipastrat); SCOTCH_stratInit (&bipastrat); if ((SCOTCH_stratGraphBipart (&bipastrat, &argv[i][2])) != 0) { errorPrint ("main: invalid bipartitioning strategy"); return (1); } break; case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'L' : /* Input vertex list */ case 'l' : flagval |= C_FLAGVRTINP; if (argv[i][2] != '\0') C_filenamevrtinp = &argv[i][2]; break; case 'V' : fprintf (stderr, "amk_grf, 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); /* Create graph structure */ SCOTCH_graphLoad (&grafdat, C_filepntrgrfinp, -1, 0); /* Load source graph */ SCOTCH_graphData (&grafdat, &baseval, &vertnbr, NULL, NULL, NULL, /* Get graph data */ &vlbltab, NULL, NULL, NULL); listnbr = 0; /* Initialize vertex list */ listtab = NULL; if (flagval & C_FLAGVRTINP) { /* If list of vertices provided */ SCOTCH_Num listnum; if ((intLoad (C_filepntrvrtinp, &listnbr) != 1) || /* Read list size */ (listnbr < 0) || (listnbr > vertnbr)) { errorPrint ("main: bad list input (1)"); return (1); } if ((listtab = (SCOTCH_Num *) memAlloc (listnbr * sizeof (SCOTCH_Num) + 1)) == NULL) { errorPrint ("main: out of memory (1)"); return (1); } for (listnum = 0; listnum < listnbr; listnum ++) { /* Read list data */ if (intLoad (C_filepntrvrtinp, &listtab[listnum]) != 1) { errorPrint ("main: bad list input (2)"); return (1); } } intSort1asc1 (listtab, listnbr); for (listnum = 0; listnum < listnbr - 1; listnum ++) { /* Search for duplicates */ if (listtab[listnum] == listtab[listnum + 1]) { errorPrint ("main: duplicate list labels"); memFree (listtab); return (1); } } if (vlbltab != NULL) { /* If graph has vertex labels */ SCOTCH_Num vertnum; if ((sorttab = (C_VertSort *) memAlloc (vertnbr * sizeof (C_VertSort))) == NULL) { errorPrint ("main: out of memory (2)"); memFree (listtab); return (1); } for (vertnum = 0; vertnum < vertnbr; vertnum ++) { /* Initialize sort area */ sorttab[vertnum].vlblnum = vlbltab[vertnum]; sorttab[vertnum].vertnum = vertnum; } intSort2asc1 (sorttab, vertnbr); /* Sort by ascending labels */ for (listnum = 0, vertnum = 0; listnum < listnbr; listnum ++) { /* For all labels in list */ while ((vertnum < vertnbr) && (sorttab[vertnum].vlblnum < listtab[listnum])) vertnum ++; /* Search vertex graph with corresponding label */ if ((vertnum >= vertnbr) || /* If label not found */ (sorttab[vertnum].vlblnum > listtab[listnum])) { errorPrint ("main: list label '" SCOTCH_NUMSTRING "' not in graph", (SCOTCH_Num) listtab[listnum]); memFree (sorttab); memFree (listtab); return (1); } listtab[listnum] = sorttab[vertnum ++].vertnum; /* Replace label by number */ } memFree (sorttab); /* Free sort area */ } } SCOTCH_archInit (&archdat); /* Initialize target architecture */ SCOTCH_archBuild (&archdat, &grafdat, listnbr, listtab, &bipastrat); /* Compute architecture */ SCOTCH_archSave (&archdat, C_filepntrtgtout); /* Write target architecture */ fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end potential (un)compression tasks */ SCOTCH_graphExit (&grafdat); /* Free target graph */ SCOTCH_archExit (&archdat); /* Free target architecture */ SCOTCH_stratExit (&bipastrat); /* Free strategy string */ if (listtab != NULL) /* If vertex list provided */ memFree (listtab); /* Free it */ #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); }
int main ( int argc, char * argv[]) { SCOTCH_Num p[1] = { 1 }; /* Number of parts */ int i; errorProg ("gscat"); 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 = 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_paraNum < 1) { /* If number of parameters not reached */ if ((p[C_paraNum ++] = atoi (argv[i])) < 1) { /* Get number of parts */ errorPrint ("main: invalid number of parts '%s'", argv[i]); return (1); } continue; /* Process the other parameters */ } 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 the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "gscat, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2009-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, 1); /* Open input graph file */ C_graphScat (C_filepntrsrcinp, p[0], C_filenamesrcout); fileBlockClose (C_fileTab, 1); /* Always close explicitely to end eventual (un)compression tasks */ #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[]) { ArchMesh2 arch; /* Mesh dimensions */ ArchMesh2Dom dom; /* Initial domain */ C_MethType methtype; /* Bipartitioning method */ unsigned int termnbr; /* Number of terminal domains */ unsigned int termmax; /* Maximum terminal number */ unsigned int * termtab; /* Terminal numbers table */ unsigned int x0, y0, x1, y1; int i; errorProg ("amk_m2"); if ((argc >= 2) && (argv[1][0] == '?')) { /* If need for help */ usagePrint (stdout, C_usageList); return (0); } methtype = C_METHNESTED; arch.c[0] = /* Preset mesh dimensions */ arch.c[1] = 1; 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_paraNum < 2) { /* If number of parameters not reached */ if ((arch.c[C_paraNum ++] = atoi (argv[i])) < 1) { /* Get the dimension */ errorPrint ("main: invalid dimension (\"%s\")", argv[i]); return (1); } continue; /* Process the other parameters */ } 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 'M' : /* Use a built-in method */ case 'm' : switch (argv[i][2]) { case 'N' : /* Nested dissection */ case 'n' : methtype = C_METHNESTED; break; case 'O' : /* One-way dissection */ case 'o' : methtype = C_METHONEWAY; break; default : errorPrint ("main: unprocessed option (\"%s\")", argv[i]); return (1); } break; case 'H' : /* Give the usage message */ case 'h' : usagePrint (stdout, C_usageList); return (0); case 'V' : fprintf (stderr, "amk_m2, version " SCOTCH_VERSION_STRING "\n"); fprintf (stderr, "Copyright 2004,2007,2008,2010 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 */ dom.c[0][0] = 0; /* Set the initial domain */ dom.c[0][1] = arch.c[0] - 1; dom.c[1][0] = 0; dom.c[1][1] = arch.c[1] - 1; termnbr = arch.c[0] * arch.c[1]; /* Compute number of terminals */ termmax = 0; /* Maximum terminal value not known yet */ if ((termtab = (unsigned int *) memAlloc (termnbr * sizeof (unsigned int))) == NULL) { /* Allocate terminal array */ errorPrint ("main: out of memory"); return (1); } memset (termtab, -1, termnbr * sizeof (unsigned int)); /* Initilize mapping table */ C_termBipart (&arch, &dom, 1, termtab, &termmax, /* Compute terminal numbers */ (methtype == C_METHNESTED) ? archMesh2DomBipart : C_methBipartOne); fprintf (C_filepntrarcout, "deco\n0\n%u\t%u\n", /* Print file header */ termnbr, /* Print number of terminal domains */ termmax); /* Print biggest terminal value */ for (i = 0; i < termnbr; i ++) /* For all terminals */ fprintf (C_filepntrarcout, "%u\t1\t%u\n", /* Print terminal data */ i, termtab[i]); for (y0 = 0; y0 < arch.c[1]; y0 ++) { /* For all vertices */ for (x0 = 0; x0 < arch.c[0]; x0 ++) { for (y1 = 0; y1 <= y0; y1 ++) { /* Compute distance to smaller vertices */ for (x1 = 0; (x1 < arch.c[0]) && ((y1 < y0) || (x1 < x0)); x1 ++) fprintf (C_filepntrarcout, ((x1 == 0) && (y1 == 0)) ? "%u" : " %u", C_termDist (x0, y0, x1, y1)); } fprintf (C_filepntrarcout, "\n"); } } fileBlockClose (C_fileTab, C_FILENBR); /* Always close explicitely to end eventual (un)compression tasks */ memFree (termtab); /* Free terminal number array */ #ifdef COMMON_PTHREAD pthread_exit ((void *) 0); /* Allow potential (un)compression tasks to complete */ #endif /* COMMON_PTHREAD */ return (0); }