Example #1
0
int
dofGraph (
Dof * const                 deofptr,              /*+ DOF index array to build [based]            +*/
const SCOTCH_Graph * const         grafptr,              /*+ Matrix adjacency structure [based]          +*/
const PASTIX_INT                   deofval,              /*+ DOFs per node if no graph vertex load array +*/
const PASTIX_INT * const           peritab)              /*+ Inverse vertex->node permutation array      +*/
{
  PASTIX_INT                 baseval;
  PASTIX_INT                 vertnbr;
  PASTIX_INT *               velotab;
  PASTIX_INT                 edgenbr;
  (void)peritab;

  SCOTCH_graphData (grafptr,
                    (SCOTCH_Num *) &baseval,
                    (SCOTCH_Num *) &vertnbr,
                    NULL, NULL,
                    (SCOTCH_Num **)&velotab,
                    NULL,
                    (SCOTCH_Num *) &edgenbr,
                    NULL,
                    NULL);

  deofptr->baseval = baseval;
  deofptr->nodenbr = vertnbr;
  if (velotab == NULL) {                          /* If no vertex weight (i.e. DOF) array */
    deofptr->noddtab = NULL;                      /* No DOF array                         */
    deofptr->noddval = deofval;                   /* Get node DOF value                   */
  }
  else {                                          /* Vertex load array present */
#ifdef DOF_CONSTANT
    deofptr->noddtab = NULL;                      /* No DOF array */
    deofptr->noddval = deofval;
#else /* DOF_CONSTANT */
    const PASTIX_INT * restrict  velotax;                /* Based access to grafptr->velotab  */
    PASTIX_INT                   nodenum;                /* Number of current node            */
    PASTIX_INT *                 noddtnd;                /* Pointer to end of DOF index array */
    PASTIX_INT *                 noddptr;                /* Pointer to current DOF index      */
    const PASTIX_INT *           periptr;

    deofptr->noddval = 0;                         /* DOF values are not constant */
    if ((deofptr->noddtab = (PASTIX_INT *) memAlloc ((vertnbr + 1) * sizeof (PASTIX_INT))) == NULL) {
      errorPrint ("dofGraph: out of memory");
      return     (1);
    }
    for (noddptr = deofptr->noddtab, noddtnd = noddptr + vertnbr,
         periptr = peritab, nodenum = baseval,
         velotax = grafptr->velotab - baseval;
         noddptr < noddtnd; noddptr ++, periptr ++) {
      *noddptr = nodenum;                         /* Set index to DOF array        */
      nodenum += velotax[*periptr];               /* Add number of DOFs for vertex */
    }
    *noddptr = nodenum;                           /* Set end of DOF array */
#endif /* DOF_CONSTANT */
  }

  return (0);
}
int
symbolFaxGraph (SymbolMatrix       * const symbptr,
		const SCOTCH_Graph * const grafptr,
		const Order        * const ordeptr)
{
  PASTIX_INT                   baseval;
  PASTIX_INT                   vertnbr;
  PASTIX_INT *                 verttab;
  const PASTIX_INT * restrict  verttax;
  PASTIX_INT                   edgenbr;
  PASTIX_INT                   edgenum;
  PASTIX_INT *                 edgetab;
  const PASTIX_INT * restrict  edgetax;

  SCOTCH_graphData (grafptr, 
		    (SCOTCH_Num *)&baseval, 
		    (SCOTCH_Num *)&vertnbr, 
		    (SCOTCH_Num **)&verttab, 
		    NULL, NULL, NULL, 
		    (SCOTCH_Num *)&edgenbr, 
		    (SCOTCH_Num **)&edgetab, 
		    NULL);

  verttax = verttab - baseval;
  edgetax = edgetab - baseval;

#define SYMBOL_FAX_ITERATOR(ngbdptr, vertnum, vertend)	\
  for (edgenum = verttax[vertnum];			\
       edgenum < verttax[vertnum + 1];			\
       edgenum ++) {					\
    vertend = edgetax[edgenum];

#define SYMBOL_FAX_VERTEX_DEGREE(ngbdptr, vertnum)	\
  (verttax[(vertnum) + 1] - verttax[(vertnum)])
  
  {
#define SYMBOL_FAX_INCLUDED
#include "symbol_fax.c"
  }
}
int
main (
int                 argc,
char *              argv[])
{
  SCOTCH_Graph          grafdat;
  SCOTCH_Strat          stradat;
  SCOTCH_Num            baseval;
  SCOTCH_Num            partnbr;
  SCOTCH_Num            partnum;
  SCOTCH_Num * restrict parttax;
  SCOTCH_Num            vertnbr;
  SCOTCH_Num            vertnum;
  SCOTCH_Num *          verttab;
  SCOTCH_Num *          vendtab;
  SCOTCH_Num *          velotab;
  SCOTCH_Num *          vlbltab;
  SCOTCH_Num *          edgetax;
  SCOTCH_Num * restrict flagtab;
  SCOTCH_Num * restrict loadtab;
  SCOTCH_Num            loadmin;
  SCOTCH_Num            loadmax;
  SCOTCH_Num            loadsum;
  double                loadavg;
  FILE *                fileptr;

  SCOTCH_errorProg (argv[0]);

  if ((argc < 4) || (argc > 5)) {
    SCOTCH_errorPrint ("usage: %s nparts input_source_graph_file output_mapping_file [strategy]", argv[0]);
    exit (EXIT_FAILURE);
  }

  if ((partnbr = (SCOTCH_Num) atoi (argv[1])) < 1) {
    SCOTCH_errorPrint ("main: invalid number of parts (\"%s\")", argv[1]);
    exit (EXIT_FAILURE);
  }

  if (SCOTCH_stratInit (&stradat) != 0) {
    SCOTCH_errorPrint ("main: cannot initialize strategy");
    exit (EXIT_FAILURE);
  }
  if (argc == 5) {
    if (SCOTCH_stratGraphPartOvl (&stradat, argv[4]) != 0) {
      SCOTCH_errorPrint ("main: invalid user-provided strategy");
      exit (EXIT_FAILURE);
    }
  }

  if (SCOTCH_graphInit (&grafdat) != 0) {
    SCOTCH_errorPrint ("main: cannot initialize graph");
    exit (EXIT_FAILURE);
  }

  if ((fileptr = fopen (argv[2], "r")) == NULL) {
    SCOTCH_errorPrint ("main: cannot open file (1)");
    exit (EXIT_FAILURE);
  }

  if (SCOTCH_graphLoad (&grafdat, fileptr, -1, 0) != 0) {
    SCOTCH_errorPrint ("main: cannot load graph");
    exit (EXIT_FAILURE);
  }

  fclose (fileptr);

  SCOTCH_graphData (&grafdat, &baseval, &vertnbr, &verttab, &vendtab, &velotab, &vlbltab, NULL, &edgetax, NULL);

  if (((parttax = malloc (vertnbr * sizeof (SCOTCH_Num))) == NULL) ||
      ((flagtab = malloc (partnbr * sizeof (SCOTCH_Num))) == NULL) ||
      ((loadtab = malloc (partnbr * sizeof (SCOTCH_Num))) == NULL)) {
    SCOTCH_errorPrint ("main: out of memory");
    exit (EXIT_FAILURE);
  }

  if (SCOTCH_graphPartOvl (&grafdat, partnbr, &stradat, parttax) != 0) { /* Parttax is not based yet */
    SCOTCH_errorPrint ("main: cannot compute mapping");
    exit (EXIT_FAILURE);
  }

  edgetax -= baseval;
  parttax -= baseval;

  memset (loadtab,  0, partnbr * sizeof (SCOTCH_Num)); /* Part loads set to 0                */
  memset (flagtab, ~0, partnbr * sizeof (SCOTCH_Num)); /* Flags set to invalid vertex number */

  for (vertnum = 0; vertnum < vertnbr; vertnum ++) {
    SCOTCH_Num          veloval;
    SCOTCH_Num          partval;

    veloval = (velotab == NULL) ? 1 : velotab[vertnum];
    partval = parttax[vertnum + baseval];         /* vertnum is not based               */
    if (partval >= 0)                             /* If vertex belongs to one part only */
      loadtab[partval] += veloval;                /* Add vertex load to this part       */
    else {                                        /* Vertex belongs to several parts    */
      SCOTCH_Num          edgenum;

      for (edgenum = verttab[vertnum]; edgenum < vendtab[vertnum]; edgenum ++) {
        SCOTCH_Num          vertend;
        SCOTCH_Num          partend;

        vertend = edgetax[edgenum];
        partend = parttax[vertend];               /* vertend is based                     */
        if (partend < 0)                          /* If neighbor has no identifiable part */
          continue;
        if (flagtab[partend] == vertnum)          /* If neighbor part already accounted for, skip it */
          continue;

        loadtab[partend] += veloval;              /* Vertex load contributes to this part */
        flagtab[partend]  = vertnum;              /* Record a contribution has been made  */
      }
    }
  }

  loadsum =
  loadmax = 0;
  loadmin = SCOTCH_NUMMAX;
  for (partnum = 0; partnum < partnbr; partnum ++) {
    loadsum += loadtab[partnum];
    if (loadtab[partnum] > loadmax)
      loadmax = loadtab[partnum];
    if (loadtab[partnum] < loadmin)
      loadmin = loadtab[partnum];

    printf ("M\tCompload[%02ld]\t%ld\n",
            (long) partnum,
            (long) loadtab[partnum]);
  }

  loadavg = (double) loadsum / (double) partnbr;
  printf ("M\tCompLoadAvg\t%g\n",
	  (double) loadavg);
  printf ("M\tCompLoadMax/Avg\t%g\n",
	  (double) loadmax / loadavg);

  if ((fileptr = fopen (argv[3], "w")) == NULL) {
    SCOTCH_errorPrint ("main: cannot open file (2)");
    exit (EXIT_FAILURE);
  }

  if (fprintf (fileptr, "%ld\n", (long) vertnbr) == EOF) {
    SCOTCH_errorPrint ("main: bad output (1)");
    exit (EXIT_FAILURE);
  }

  for (vertnum = 0; vertnum < vertnbr; vertnum ++) {
    if (fprintf (fileptr, "%ld\t%ld\n",
                 (long) ((vlbltab == NULL) ? vertnum : vlbltab[vertnum]),
                 (long) parttax[vertnum + baseval]) == EOF) {
      SCOTCH_errorPrint ("main: bad output (2)");
      exit (EXIT_FAILURE);
    }
  }

  fclose (fileptr);

  free (loadtab);
  free (flagtab);
  free (parttax + baseval);

  SCOTCH_stratExit (&stradat);
  SCOTCH_graphExit (&grafdat);

  exit (EXIT_SUCCESS);
}
Example #4
0
int
main (
int                         argc,
char *                      argv[])
{
  C_Graph            grafdat;                     /* Source graph   */
  C_Geometry         geo;                         /* Graph geometry */
  C_Mapping          map;                         /* Result mapping */
  int                i, j;

  errorProg ("gout");

  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");
    }
    else {                                        /* If found an option name */
      switch (argv[i][1]) {
        case 'G' :                                /* Geometry parameters */
        case 'g' :
          if ((j = C_geoParse (&argv[i][2])) != 0)
            errorPrint ("main: error in geometry option string '%d'", j);
          break;
        case 'H' :                                /* Give the usage message */
        case 'h' :
          usagePrint (stdout, C_usageList);
          return     (0);
        case 'M' :                                /* No-mapping flag */
        case 'm' :
          if (((argv[i][2] != 'N') && (argv[i][2] != 'n')) || (argv[i][3] != '\0'))
            errorPrint ("main: error in mapping option string '%s'", &argv[i][2]);
          C_filenamemapinp = "-";                 /* Default name to avoid opening   */
          C_filepntrmapinp = NULL;                /* NULL file pointer means no file */
          break;
        case 'O' :                                /* Output parameters */
        case 'o' :
          if ((j = outDrawParse (&argv[i][2])) != 0)
            errorPrint ("main: error in output option string (%d)", j);
          break;
        case 'V' :
          fprintf (stderr, "gout, 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);
        default :
          errorPrint ("main: Unprocessed option '%s'", argv[i]);
      }
    }
  }

  fileBlockOpen (C_fileTab, C_FILENBR);           /* Open all files */

  SCOTCH_graphInit (&grafdat.grafdat);            /* Create graph structure         */
  SCOTCH_graphLoad (&grafdat.grafdat, C_filepntrsrcinp, 0, 3); /* Read source graph */
  SCOTCH_graphData (&grafdat.grafdat, &grafdat.baseval,
                    &grafdat.vertnbr, &grafdat.verttab, &grafdat.vendtab, NULL, &grafdat.vlbltab,
                    &grafdat.edgenbr, &grafdat.edgetab, NULL);

  C_geoInit (&geo, &grafdat);                     /* Create geometry structure */
  if (C_geoFlag & C_GEOFLAGUSE)                   /* If geometry is wanted     */
    C_geoLoad (&geo, C_filepntrgeoinp);           /* Read graph geometry       */

  C_mapInit (&map, &grafdat);                     /* Create mapping structure */
  C_mapLoad (&map, C_filepntrmapinp);             /* Read result mapping      */

  outDraw (&grafdat, &geo, &map, C_filepntrdatout); /* Build and write the output */

  fileBlockClose (C_fileTab, C_FILENBR);          /* Always close explicitely to end eventual (un)compression tasks */

  C_mapExit        (&map);                        /* Free data structures */
  C_geoExit        (&geo);
  SCOTCH_graphExit (&grafdat.grafdat);

#ifdef COMMON_PTHREAD
  pthread_exit ((void *) 0);                      /* Allow potential (un)compression tasks to complete */
#endif /* COMMON_PTHREAD */
  return (0);
}
Example #5
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");

  if ((argc >= 2) && (argv[1][0] == '?')) {       /* If need for help */
    usagePrint (stdout, C_usageList);
    return     (0);
  }

  flagval = C_FLAGNONE;
  SCOTCH_stratInit (&bipastrat);

  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_fileNum < C_FILEARGNBR)               /* 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 '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-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 */

  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[])
{
    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);
}
Example #7
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);
}
Example #8
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);
}