Ejemplo n.º 1
0
/* !!! FONCTION INUTILISEE !!! */
void CscVerifUpdown(const UpDownVector *updovct, const SymbolMatrix *symbmtx,
		    const PASTIX_FLOAT *rhs2)
{
  PASTIX_INT itercblk;
  PASTIX_INT itercol;
  PASTIX_INT itersm2x;

#ifdef CSC_LOG
  fprintf(stdout, "-> CscVerifUpdown \n");
#endif

  for (itercblk=0; itercblk<symbmtx->cblknbr; itercblk++)
    {
      itersm2x = updovct->cblktab[itercblk].sm2xind;

      for (itercol=symbmtx->cblktab[itercblk].fcolnum;
	   itercol<symbmtx->cblktab[itercblk].lcolnum+1;
	   itercol++)
	{
#ifdef CPLX
	  errorPrint( "%ld (%10e,%10e) (%10e,%10e)\n",
		  (long)itercol, creal(rhs2[itercol]), cimag(rhs2[itercol]), creal(updovct->sm2xtab[itersm2x]), cimag(updovct->sm2xtab[itersm2x]));
#else
	  errorPrint( "%ld %10e %10e\n",
		  (long)itercol, rhs2[itercol], updovct->sm2xtab[itersm2x]);
#endif
	  itersm2x++;
	}
    }

#ifdef CSC_LOG
  fprintf(stdout, "<- CscVerifUpdown \n");
#endif
}
Ejemplo n.º 2
0
int
SCOTCH_graphMapInit (
const SCOTCH_Graph * const  grafptr,              /*+ Graph to map                    +*/
SCOTCH_Mapping * const      mappptr,              /*+ Mapping structure to initialize +*/
const SCOTCH_Arch * const   archptr,              /*+ Target architecture used to map +*/
SCOTCH_Num * const          parttab)              /*+ Mapping array                   +*/
{
  LibMapping * restrict lmapptr;

#ifdef SCOTCH_DEBUG_LIBRARY1
  if (sizeof (SCOTCH_Mapping) < sizeof (LibMapping)) {
    errorPrint ("SCOTCH_graphMapInit: internal error");
    return     (1);
  }
#endif /* SCOTCH_DEBUG_LIBRARY1 */

  lmapptr = (LibMapping *) mappptr;

  lmapptr->grafptr = (Graph *) grafptr;
  lmapptr->archptr = (Arch *)  archptr;
  lmapptr->flagval = LIBMAPPINGNONE;              /* No options set */
  if (parttab == NULL) {
    if ((lmapptr->parttab = (Gnum *) memAlloc (lmapptr->grafptr->vertnbr * sizeof (Gnum))) == NULL) {
      errorPrint ("SCOTCH_graphMapInit: out of memory");
      return     (1);
    }
    memSet (lmapptr->parttab, 0, lmapptr->grafptr->vertnbr * sizeof (Anum)); /* All vertices mapped to first domain    */
    lmapptr->flagval |= LIBMAPPINGFREEPART;       /* The user did not provided the partition array, so we will free it */
  }
  else
    lmapptr->parttab = (Gnum *) parttab;

  return (0);
}
Ejemplo n.º 3
0
/*
 * Funktion liesst Kataloge aus
 */
int loadCatalogs(){

	// BROWSE_CMD - Kataloge auflisten
	if(write(stdinPipe[1], BROWSE_CMD, strlen(BROWSE_CMD)) < strlen(BROWSE_CMD)){
		errorPrint("Senden der Nachricht über Pipe fehlgeschlagen: ");
		return 1;
	}

	// Zeilenumbruch
	if(write(stdinPipe[1], "\n", 1) < 1){
		errorPrint("Senden der Nachricht über Pipe fehlgeschlagen: ");
		return 2;
	}

	// Katalogname
	char* catalogname;
	// Zaehlvariable fuer Anzahl Kataloge
	int i = 0;
	int err = 0;

	while(err > -1){
		// Daten aus dem Leseende von stdoutPipe lesen
		catalogname = readLine(stdoutPipe[0]);
		// pruefe ob Zeilenumbruch
		err = strcmp(catalogname, "\n");
		if(err > -1){
			// Katalog hinzufuegen
			addCatalog(catalogname, i);
			i++;
		}
	}
	infoPrint("Kataloge eingelesen: %i", i);
	return 0;
}
Ejemplo n.º 4
0
int
dgraphAllreduceMaxSum2 (
Gnum *                      reduloctab,           /* Pointer to array of local Gnum data   */
Gnum *                      reduglbtab,           /* Pointer to array of reduced Gnum data */
int                         redumaxsumnbr,        /* Number of max + sum Gnum operations   */
MPI_User_function *         redufuncptr,          /* Pointer to operator function          */
MPI_Comm                    proccomm)             /* Communicator to be used for reduction */
{
  MPI_Datatype      redutypedat;                  /* Data type for finding best separator              */
  MPI_Op            reduoperdat;                  /* Handle of MPI operator for finding best separator */

  if ((MPI_Type_contiguous (redumaxsumnbr, GNUM_MPI, &redutypedat) != MPI_SUCCESS) ||
      (MPI_Type_commit (&redutypedat)                              != MPI_SUCCESS) ||
      (MPI_Op_create (redufuncptr, 1, &reduoperdat)                != MPI_SUCCESS)) {
    errorPrint ("dgraphAllreduceMaxSum: communication error (1)");
    return     (1);
  }

  if (MPI_Allreduce (reduloctab, reduglbtab, 1, redutypedat, reduoperdat, proccomm) != MPI_SUCCESS) {
    errorPrint ("dgraphAllreduceMaxSum: communication error (2)");
    return     (1);
  }

  if ((MPI_Op_free   (&reduoperdat) != MPI_SUCCESS) ||
      (MPI_Type_free (&redutypedat) != MPI_SUCCESS)) {
    errorPrint ("dgraphAllreduceMaxSum: communication error (3)");
    return     (1);
  }

  return (0);
}
Ejemplo n.º 5
0
int
main (
int                         argc,
char *                      argv[])
{
  SCOTCH_Arch         arch;                       /* Architecture read and written */
  int                 i;

  errorProg ("acpl");

  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_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 'H' :                                /* Give the usage message */
        case 'h' :
          usagePrint (stdout, C_usageList);
          return     (0);
        case 'V' :
          fprintf (stderr, "acpl, version " SCOTCH_VERSION_STRING "\n");
          fprintf (stderr, "Copyright 2004,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]);
          return     (1);
      }
    }
  }

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

  SCOTCH_archInit (&arch);                        /* Initialize architecture structure */
  SCOTCH_archLoad (&arch, C_filepntrtgtinp);      /* Load architecture                 */
  if (strcmp (SCOTCH_archName (&arch), "deco") != 0) { /* If not a decomposition       */
    errorPrint ("main: architecture is not decomposition-defined");
    return     (1);
  }
  SCOTCH_archSave (&arch, C_filepntrtgtout);      /* Save the compiled architecture */

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

  SCOTCH_archExit (&arch);

  return (0);
}
Ejemplo n.º 6
0
int
SCOTCH_graphMapCompute (
SCOTCH_Graph * const        grafptr,              /*+ Graph to order     +*/
SCOTCH_Mapping * const      mappptr,              /*+ Mapping to compute +*/
SCOTCH_Strat * const        stratptr)             /*+ Mapping strategy   +*/
{
  Kgraph                mapgrafdat;               /* Effective mapping graph     */
  const Strat *         mapstratptr;              /* Pointer to mapping strategy */
  LibMapping * restrict lmapptr;
  int                   o;

#ifdef SCOTCH_DEBUG_GRAPH2
  if (graphCheck ((Graph *) grafptr) != 0) {
    errorPrint ("SCOTCH_graphMapCompute: invalid input graph");
    return     (1);
  }
#endif /* SCOTCH_DEBUG_GRAPH2 */

  lmapptr = (LibMapping *) mappptr;
  if (*((Strat **) stratptr) == NULL) {           /* Set default mapping strategy if necessary */
    ArchDom             archdomnorg;

    archDomFrst (&lmapptr->m.archdat, &archdomnorg);
    if (archVar (&lmapptr->m.archdat))
      SCOTCH_stratGraphClusterBuild (stratptr, 0, 1, 0.0, 0.05);
    else
      SCOTCH_stratGraphMapBuild (stratptr, 0, archDomSize (&lmapptr->m.archdat, &archdomnorg), 0.05);
  }

  mapstratptr = *((Strat **) stratptr);
  if (mapstratptr->tabl != &kgraphmapststratab) {
    errorPrint ("SCOTCH_graphMapCompute: not a graph mapping strategy");
    return     (1);
  }

  if (kgraphInit (&mapgrafdat, (Graph *) grafptr, &lmapptr->m) != 0)
    return (1);
  o = kgraphMapSt (&mapgrafdat, mapstratptr);     /* Perform mapping */

  lmapptr->m.domnmax = mapgrafdat.m.domnmax;      /* Do not free the mapping, as it has been cloned */
  lmapptr->m.domnnbr = mapgrafdat.m.domnnbr;
  lmapptr->m.domntab = mapgrafdat.m.domntab;      /* Update pointer to domntab in case it has changed */

  mapgrafdat.m.parttax = NULL;                    /* Prevent mapping arrays from being freed by graph */
  mapgrafdat.m.domntab = NULL;
  kgraphExit (&mapgrafdat);

  if (lmapptr->parttax != NULL) {                 /* Propagate mapping data to user partition array */
    Gnum                vertnum;
    Gnum                vertnnd;

    for (vertnum = lmapptr->m.baseval, vertnnd = vertnum + lmapptr->m.vertnbr;
         vertnum < vertnnd; vertnum ++)
      lmapptr->parttax[vertnum] = archDomNum (&lmapptr->m.archdat, &lmapptr->m.domntab[lmapptr->m.parttax[vertnum]]);
  }

  return (o);
}
Ejemplo n.º 7
0
int
orderLoad (
Order * const               ordeptr,
FILE * const                stream)
{
  PASTIX_INT               versval;                      /* Version number */
  PASTIX_INT               cblknbr;
  PASTIX_INT               cblknum;
  PASTIX_INT               vertnbr;
  PASTIX_INT               vertnum;
  PASTIX_INT               vertnnd;
  PASTIX_INT *             permtax;
  PASTIX_INT *             peritax;
  int               i;

  if ((intLoad (stream, &versval) +
       intLoad (stream, &cblknbr) +
       intLoad (stream, &vertnbr) != 3) ||
      (versval != 0)                    ||
      (cblknbr > vertnbr)) {
    errorPrint ("orderLoad: bad input (1)");
    return     (1);
  }

  if (((ordeptr->rangtab = (PASTIX_INT *) memAlloc ((cblknbr + 1) * sizeof (PASTIX_INT))) == NULL) ||
      ((ordeptr->permtab = (PASTIX_INT *) memAlloc (vertnbr       * sizeof (PASTIX_INT))) == NULL) ||
      ((ordeptr->peritab = (PASTIX_INT *) memAlloc (vertnbr       * sizeof (PASTIX_INT))) == NULL)) {
    errorPrint ("orderLoad: out of memory");
    orderExit  (ordeptr);
    orderInit  (ordeptr);
    return     (1);
  }
  ordeptr->cblknbr = cblknbr;

  for (cblknum = 0, i = 1; (i == 1) && (cblknum <= cblknbr); cblknum ++) /* Read column-block data */
    i = intLoad (stream, &ordeptr->rangtab[cblknum]);

  for (vertnum = 0; (i == 1) && (vertnum < vertnbr); vertnum ++) /* Read direct permutation */
    i = intLoad (stream, &ordeptr->permtab[vertnum]);

  if (i != 1) {
    errorPrint ("orderLoad: bad input (2)");
    orderExit  (ordeptr);
    orderInit  (ordeptr);
    return     (1);
  }

  permtax = ordeptr->permtab - ordeptr->rangtab[0];
  peritax = ordeptr->peritab - ordeptr->rangtab[0];
  for (vertnum = ordeptr->rangtab[0], vertnnd = vertnum + vertnbr; /* Build inverse permutation */
       vertnum < vertnnd; vertnum ++)
    peritax[permtax[vertnum]] = vertnum;

  return (0);
}
Ejemplo n.º 8
0
int
fileBlockOpenDist (
File * const                filetab,
const int                   filenbr,
const int                   procglbnbr,
const int                   proclocnum,
const int                   protglbnum)
{
  int                i, j;

  for (i = 0; i < filenbr; i ++) {                /* For all file names */
    if (fileNameDistExpand (&filetab[i].name, procglbnbr, proclocnum, protglbnum) != 0) { /* If cannot allocate new name */
      errorPrint ("fileBlockOpenDist: cannot create file name (%d)", i);
      return     (1);
    }
    if (filetab[i].name == NULL)                  /* If inexisting stream because not root process and centralized stream */
      filetab[i].pntr = NULL;
    if (filetab[i].pntr == NULL)                  /* If unwanted stream, do nothing */
      continue;

    for (j = 0; j < i; j ++) {
      if ((filetab[i].mode[0] == filetab[j].mode[0]) && /* If very same name with same opening mode */
          (filetab[j].name != NULL)                  &&
          (strcmp (filetab[i].name, filetab[j].name) == 0)) {
        filetab[i].pntr = filetab[j].pntr;        /* Share pointer to already processed stream */
        filetab[i].name = NULL;                   /* Do not close this stream multiple times   */
        break;
      }
    }
    if (j == i) {                                 /* If original stream                */
      int                 compval;                /* Compression type                  */
      FILE *              compptr;                /* Processed ((un)compressed) stream */

      if (filetab[i].name[0] != '-') {            /* If not standard stream, open it                 */
        if ((filetab[i].pntr = fopen (filetab[i].name, filetab[i].mode)) == NULL) { /* Open the file */
          errorPrint ("fileBlockOpenDist: cannot open file (%d)", i);
          return     (1);
        }
      }
      compval = (filetab[i].mode[0] == 'r') ? fileUncompressType (filetab[i].name) : fileCompressType (filetab[i].name);
      if (compval < 0) {
        errorPrint ("fileBlockOpenDist: (un)compression type not implemented");
        return     (1);
      }
      compptr = (filetab[i].mode[0] == 'r') ? fileUncompress (filetab[i].pntr, compval) : fileCompress (filetab[i].pntr, compval);
      if (compptr == NULL) {
        errorPrint ("fileBlockOpenDist: cannot create (un)compression subprocess");
        return     (1);
      }
      filetab[i].pntr = compptr;                  /* Use processed stream instead of original stream */
    }
  }

  return (0);
}
Ejemplo n.º 9
0
static bool
execInternal(const char *stmt, int mode)
{
    bool notfound = false;

    newStatement();
    if(!prepareInternal(stmt))
	return false;		/* error */

    if(!rv_numRets) {
	if(!(mode & 1)) {
	    showStatement();
	    errorPrint("2SQL select statement returns no values");
	}
	notfound = true;
    } else {			/* end no return values */
	if(!(mode & 2)) {
	    showStatement();
	    errorPrint("2SQL statement returns %d values", rv_numRets);
	}
    }

    if(!openfirst)
	rc = SQLExecute(hstmt);

    if(!rc) {			/* statement succeeded */
	/* fetch the data, or get a count of the rows affected */
	if(rv_numRets) {
	    stmt_text = "fetch";
	    debugStatement();
	    rc = SQLFetchScroll(hstmt, (ushort) SQL_FD_FETCH_NEXT, 1);
	    if(rc == SQL_NO_DATA) {
		rc = SQL_SUCCESS;
		notfound = true;
	    } else
		everything_null = false;
	} else {
	    rc = SQLRowCount(hstmt, &rv_lastNrows);
	    if(sql_debug)
		appendFile(sql_debuglog, "%d rows affected", rv_lastNrows);
	    if(sql_debug2)
		printf("%d rows affected\n", rv_lastNrows);
	}
    }

    if(errorTrap(0))
	return false;

    if(!rv_numRets)
	return true;
    return !notfound;
}				/* execInternal */
int
SCOTCH_dgraphGather (
const SCOTCH_Dgraph * const dgrfptr,
SCOTCH_Graph * const        cgrfptr)
{
  Dgraph * restrict   srcdgrfptr;
  Gnum                reduloctab[3];
  Gnum                reduglbtab[3];

  srcdgrfptr = (Dgraph *) dgrfptr;

  if ((cgrfptr != NULL) && (((void *) cgrfptr) != ((void *) dgrfptr))) { /* If centralized graph provided */
    reduloctab[0] = 1;                            /* Process is a potential root                          */
    reduloctab[1] = (Gnum) srcdgrfptr->proclocnum;
  }
  else {                                          /* Process is not a root */
    reduloctab[0] = 0;
    reduloctab[1] = 0;
  }

  if (srcdgrfptr->edloloctax == NULL)             /* Compute sum of edge loads for access to low-level routines */
    reduloctab[2] = srcdgrfptr->edgelocnbr;
  else {
    Gnum                vertlocnum;
    Gnum                edlolocsum;

    for (vertlocnum = srcdgrfptr->baseval, edlolocsum = 0;
         vertlocnum < srcdgrfptr->vertlocnnd; vertlocnum ++) {
      Gnum                edgelocnum;
      Gnum                edgelocnnd;

      for (edgelocnum = srcdgrfptr->vertloctax[vertlocnum],
           edgelocnnd = srcdgrfptr->vendloctax[vertlocnum];
           edgelocnum < edgelocnnd; edgelocnum ++)
        edlolocsum += srcdgrfptr->edloloctax[edgelocnum];
    }
    reduloctab[2] = edlolocsum;
  }

  if (MPI_Allreduce (reduloctab, reduglbtab, 3, GNUM_MPI, MPI_SUM, srcdgrfptr->proccomm) != MPI_SUCCESS) {
    errorPrint ("SCOTCH_dgraphGather: communication error");
    return     (1);
  }
  if (reduglbtab[0] == 1)                         /* If only one single root */
    return (dgraphGatherAll2 (srcdgrfptr, (Graph *) cgrfptr, reduglbtab[2], (int) reduglbtab[1]));
  else if (reduglbtab[0] == srcdgrfptr->procglbnbr) /* If all processes are roots */
    return (dgraphGatherAll2 (srcdgrfptr, (Graph *) cgrfptr, reduglbtab[2], -1));

  errorPrint ("SCOTCH_dgraphGather: invalid number of roots");
  return     (1);
}
Ejemplo n.º 11
0
int
SCOTCH_dgraphBuild (
SCOTCH_Dgraph * const       grafptr,              /* Distributed graph structure to fill  */
const Gnum                  baseval,              /* Base for indexing                    */
const Gnum                  vertlocnbr,           /* Number of local vertices             */
const Gnum                  vertlocmax,           /* Maximum number of local vertices     */
Gnum * const                vertloctab,           /* Local vertex begin array             */
Gnum * const                vendloctab,           /* Local vertex end array               */
Gnum * const                veloloctab,           /* Local vertex load array (if any)     */
Gnum * const                vlblloctab,           /* Local vertex label array (if any)    */
const Gnum                  edgelocnbr,           /* Number of local edges                */
const Gnum                  edgelocsiz,           /* Size of local edge array             */
Gnum * const                edgeloctab,           /* Local edge array                     */
Gnum * const                edgegsttab,           /* Ghost edge array (if any); not const */
Gnum * const                edloloctab)           /* Local edge load array (if any)       */
{
  Dgraph *                    srcgrafptr;         /* Pointer to source graph structure */
  Gnum *                      vertloctax;
  Gnum *                      vendloctax;
  Gnum *                      veloloctax;
  Gnum *                      vlblloctax;
  Gnum *                      edgeloctax;
  Gnum *                      edgegsttax;
  Gnum *                      edloloctax;

#ifdef SCOTCH_DEBUG_LIBRARY1
  if (sizeof (SCOTCH_Dgraph) < sizeof (Dgraph)) {
    errorPrint (STRINGIFY (SCOTCH_dgraphBuild) ": internal error");
    return     (1);
  }
#endif /* SCOTCH_DEBUG_LIBRARY1 */
  if ((baseval < 0) || (baseval > 1)) {
    errorPrint (STRINGIFY (SCOTCH_dgraphBuild) ": invalid base parameter");
    return     (1);
  }

  srcgrafptr = (Dgraph *) grafptr;                /* Use structure as source graph */
  
  vertloctax = (Gnum *) vertloctab - baseval;
  vendloctax = ((vendloctab == NULL) || (vendloctab == vertloctab + 1)) ? vertloctax + 1 : (Gnum *) vendloctab - baseval;
  veloloctax = ((veloloctab == NULL) || (veloloctab == vertloctab)) ? NULL : (Gnum *) veloloctab - baseval;
  vlblloctax = ((vlblloctab == NULL) || (vlblloctab == vertloctab)) ? NULL : (Gnum *) vlblloctab - baseval;
  edgeloctax = (Gnum *) edgeloctab - baseval;
  edgegsttax = ((edgegsttab == NULL) || (edgegsttab == edgeloctab)) ? NULL : (Gnum *) edgegsttab - baseval;
  edloloctax = ((edloloctab == NULL) || (edloloctab == edgeloctab)) ? NULL : (Gnum *) edloloctab - baseval;

  return (dgraphBuild (srcgrafptr, baseval,
                       vertlocnbr, vertlocmax, vertloctax, vendloctax, veloloctax, NULL, vlblloctax,
                       edgelocnbr, edgelocsiz, edgeloctax, edgegsttax, edloloctax));
}
Ejemplo n.º 12
0
/* dereference an existing cursor */
static struct OCURS *
findCursor(int cid)
{
    struct OCURS *o;
    if(cid < 6000 || cid >= 6000 + NUMCURSORS)
	errorPrint("2cursor number %d is out of range", cid);
    cid -= 6000;
    o = ocurs + cid;
    if(o->flag == CURSOR_NONE)
	errorPrint("2cursor %d is not currently active", cid + 6000);
    rv_numRets = o->numrets;
    memcpy(rv_type, o->rv_type, NUMRETS);
    return o;
}				/* findCursor */
Ejemplo n.º 13
0
void connect_socket_client(int *sock, char serv_addr[], char port[]){
 
	struct addrinfo *addr_info, *p, hints;
	int ret;
	/**Set the socket at the beginning to -1 and change value if connection works!*/
		
	memset(&hints, 0, sizeof(hints));
	hints.ai_family = AF_UNSPEC;
	hints.ai_socktype = SOCK_STREAM;
	hints.ai_protocol = IPPROTO_TCP;
	hints.ai_flags = 0 /** | AI_ADDRCONFIG */;
	
	
		/**RTFM: getaddrinfo */
        ret = getaddrinfo(serv_addr, port, &hints, &addr_info);
        if (ret){
			errorPrint("getaddrinfo: %s", gai_strerror(ret));
			exit(1);
		}

        p = addr_info;
        while (p){
			
			char dst[INET6_ADDRSTRLEN];

			/**Create socket for found family */		
                        *sock = socket(p->ai_family, p->ai_socktype, 0);

			/**RTFM: getnameinfo */
			getnameinfo(p->ai_addr,
			p->ai_addrlen,
			dst,
			sizeof(dst),
			NULL,
			0,
			NI_NUMERICHOST);

			/**Try to connect */
                        if (connect(*sock, p->ai_addr, p->ai_addrlen) == 0){
                                infoPrint("Connected");
                                break;
				
			}else{
				errorPrint("Error, while trying %s",dst);
			}
			p = p->ai_next;		
		}
        freeaddrinfo(addr_info);
}
Ejemplo n.º 14
0
int
SCOTCH_geomInit (
SCOTCH_Geom * const         geomptr)
{
  if (sizeof (SCOTCH_Num) != sizeof (Gnum)) {
    errorPrint (STRINGIFY (SCOTCH_geomInit) ": internal error (1)");
    return     (1);
  }
  if (sizeof (SCOTCH_Geom) < sizeof (Geom)) {
    errorPrint (STRINGIFY (SCOTCH_geomInit) ": internal error (2)");
    return     (1);
  }

  return (geomInit ((Geom *) geomptr));
}
Ejemplo n.º 15
0
int
orderSave (
const Order * const         ordeptr,
FILE * const                stream)
{
  PASTIX_INT               vertnbr;
  PASTIX_INT               vertnum;
  PASTIX_INT               cblknum;
  int               o;

  if (ordeptr->rangtab == NULL) {
    errorPrint ("orderSave: cannot save ordering without column block data");
    return     (1);
  }
  if (ordeptr->permtab == NULL) {
    errorPrint ("orderSave: cannot save ordering without direct permutation data");
    return     (1);
  }

  vertnbr = ordeptr->rangtab[ordeptr->cblknbr] -  /* Get number of nodes */
            ordeptr->rangtab[0];

  if (fprintf (stream, "0\n%ld\t%ld\n",
               (long) ordeptr->cblknbr,
               (long) vertnbr) == EOF) {
    errorPrint ("orderSave: bad output (1)");
    return     (1);
  }

  for (cblknum = 0, o = 1; (o == 1) && (cblknum < ordeptr->cblknbr); cblknum ++) { /* Save column-block range array */
    o = intSave (stream, ordeptr->rangtab[cblknum]);
    putc (((cblknum & 7) == 7) ? '\n' : '\t', stream);
  }
  o = intSave (stream, ordeptr->rangtab[cblknum]);
  putc ('\n', stream);

  for (vertnum = 0; (o == 1) && (vertnum < (vertnbr - 1)); vertnum ++) { /* Save direct permutation */
    o = intSave (stream, ordeptr->permtab[vertnum]);
    putc (((vertnum & 7) == 7) ? '\n' : '\t', stream);
  }
  o = intSave (stream, ordeptr->permtab[vertnum]);
  putc ('\n', stream);

  if (o != 1)
    errorPrint ("orderSave: bad output (2)");

  return (1 - o);
}
Ejemplo n.º 16
0
//------------------------------------------------------------
// initList()
//------------------------------------------------------------
int initList(char *name)
{
    try {
        createdL68 = false;
        listFile = fopen(name, "w");
        if (!listFile) {
            sprintf(buffer,"Unable to create listing file");
            // TODO: (GUI) Send error to GUI
            errorPrint(buffer);
            return MILD_ERROR;
        }
        
        // Current time as a string for use in timestamp for listfile.
        time_t now = time(NULL);
        char *timeStr = ctime(&now);
        
        // Reserve room for starting address
        fprintf(listFile, "00000000 Starting Address\n");
        
        // Assembler Info and Timestamp
        fprintf(listFile, "Assembler used: %s\n", TITLE);
        fprintf(listFile, "Created On: %s\n\n", timeStr);
        
        createdL68 = true;
        return NORMAL;
    }
    catch( ... ) {
        sprintf(buffer, "ERROR: An exception occurred in routine 'initList'. \n");
        printError(NULL, EXCEPTION, 0);
        return MILD_ERROR;
    }
}
Ejemplo n.º 17
0
//------------------------------------------------------------
// listObj
//------------------------------------------------------------
int listObj(int data, int size)
{
    if (!CEXflag && (listPtr - listData + size > 31)) {
        strcpy(listData + ((size == WORD_SIZE) ? 26 : 28), "...");
        return NORMAL;
    }
    if (CEXflag && (listPtr - listData + size > 31)) {
        listLine(line);
        strcpy(listData, "          ");
        listPtr = listData + 10;
        continuation = true;
    }
    switch (size) {
        case BYTE_SIZE_M: sprintf(listPtr, "%02X ", data & 0xFF);
            listPtr += 3;
            break;
        case WORD_SIZE: sprintf(listPtr, "%04X ", data & 0xFFFF);
            listPtr += 5;
            break;
            // TODO: (WORKAROUND) Make sure casting data as (unsigned long) isn't a bad workaround 
            // NOTE: IT WAS!
        case LONG_SIZE: sprintf(listPtr, "%08lX ", data);
            listPtr += 9;
            break;
        default: sprintf(buffer,"LISTOBJ: INVALID SIZE CODE!\n");
            // TODO: (GUI) Send error message to document window
            errorPrint(buffer);
            return MILD_ERROR;
    }
    
    return NORMAL;
}
Ejemplo n.º 18
0
static void
newStatement(void)
{
    rc = SQLAllocStmt(hdbc, &hstmt);
    if(rc)
	errorPrint("@could not alloc singleton ODBC statement handle");
}				/* newStatement */
Ejemplo n.º 19
0
void sopalin_launch_comm(int nbthrdcomm, void * (*comm_routine)(void *), void *data)
{
  int ret, i;
  pthread_t        *calltab = NULL;
  sopthread_data_t *d       = NULL;

  MALLOC_INTERN(calltab, nbthrdcomm, pthread_t);
  MALLOC_INTERN(d,       nbthrdcomm, sopthread_data_t);

  for (i=0;i<nbthrdcomm;i++)
    {

      pthread_attr_t attr;
      pthread_attr_init(&attr);

      d[i].me   = -1-i;
      d[i].data = data;

      ret = pthread_create(&calltab[i],&attr,comm_routine,(void *)&d[i]);
      if (ret) {errorPrint("thread create."); EXIT(MOD_SOPALIN,THREAD_ERR);}

    }

  for (i=0; i<nbthrdcomm; i++)
    pthread_detach(calltab[i]);

  memFree_null(calltab);
  /* memFree_null(d);*/

}
Ejemplo n.º 20
0
void
gainTablAddLin (
GainTabl * const            tablptr,              /*+ Pointer to gain table   +*/
GainLink * const            linkptr,              /*+ Pointer to entry to add +*/
const INT                   gain)                 /*+ Gain value              +*/
{
  GainEntr *          entrptr;                    /* Pointer to gain entry   */
  GainLink *          headptr;                    /* Pointer to head of list */

#ifdef SCOTCH_DEBUG_GAIN2
  if (tablptr->tablAdd != gainTablAddLin) {
    errorPrint ("gainTablAddLin: table type mismatch");
    return;
  }
#endif /* SCOTCH_DEBUG_GAIN2 */

  entrptr = tablptr->tabl + gain;
  if (entrptr < tablptr->tabk)
    entrptr = tablptr->tabk;
  else if (entrptr > tablptr->tend)
    entrptr = tablptr->tend;

  if (entrptr < tablptr->tmin)
    tablptr->tmin = entrptr;
  if (entrptr > tablptr->tmax)
    tablptr->tmax = entrptr;

  headptr = (GainLink *) entrptr;                 /* TRICK: assume gain entry is a link */
  linkptr->tabl       = entrptr;                  /* Set table position                 */
  headptr->next->prev = linkptr;                  /* Link vertex in gain list: TRICK    */
  linkptr->prev       = headptr;
  linkptr->next       = headptr->next;
  headptr->next       = linkptr;
}
Ejemplo n.º 21
0
/*
 *  Function: PASTIX_potrf
 *
 *  Factorization LLt BLAS2 3 terms
 *
 * > A = LL^T
 *
 * Parameters:
 *    A       - Matrix to factorize
 *    n       - Size of A
 *    stride  - Stide between 2 columns of the matrix
 *    nbpivot - IN/OUT pivot number.
 *    critere - Pivoting threshold.
 *
 */
void
PASTIX_potrf (PASTIX_FLOAT * A, PASTIX_INT n, PASTIX_INT stride, PASTIX_INT *nbpivot, double critere)
{
  PASTIX_INT k;
  PASTIX_FLOAT *tmp,*tmp1;

  for (k=0;k<n;k++)
    {
      tmp=A+k* (stride+1);
#ifdef USE_CSC
      if (ABS_FLOAT(*tmp)<critere)
        {
          (*tmp) = (PASTIX_FLOAT)critere;
          (*nbpivot)++;
        }
#endif
#ifdef TYPE_COMPLEX
      *tmp = (PASTIX_FLOAT)csqrt(*tmp);
#else
      *tmp = (PASTIX_FLOAT)sqrt(*tmp);
      if (*tmp < 0)
        {
          errorPrint ("Negative diagonal term\n");
          EXIT (MOD_SOPALIN, INTERNAL_ERR);
        }
#endif
      tmp1=tmp+1;
      SOPALIN_SCAL (n-k-1,(fun/(*tmp)),tmp1,iun);
      SOPALIN_SYR ("L",n-k-1,-fun,tmp1,iun,tmp1+stride,stride);
    }
}
/*
 * Function: updo_trsm_starpu_common
 *
 * Parameters:
 *   buffers    - Data handlers :
 *     1            - L column block
 *     2            - Right-hand-side block facing the column block.
 *   _args      - Codelet arguments:
 *     sopalin_data - global PaStiX internal data.
 *     cblknum      - Current column block index.
 */
static inline
void updo_trsm_starpu_common(void * buffers[], void * _args, int arch)
{
  starpu_updo_trsm_data_t * args         = (starpu_updo_trsm_data_t*)_args;
  Sopalin_Data_t          * sopalin_data = args->sopalin_data;
  SolverMatrix            * datacode     = sopalin_data->datacode;
  PASTIX_FLOAT                   * L            = (PASTIX_FLOAT*)STARPU_MATRIX_GET_PTR(buffers[0]);
  PASTIX_FLOAT                   * RHS          = (PASTIX_FLOAT*)STARPU_MATRIX_GET_PTR(buffers[1]);
  PASTIX_INT                       stride       = STARPU_MATRIX_GET_LD(buffers[0]);
  PASTIX_INT                       rhsnbr       = STARPU_MATRIX_GET_NY(buffers[1]);
  PASTIX_INT                       rhssze       = STARPU_MATRIX_GET_LD(buffers[1]);
  PASTIX_INT                       cblknum      = args->cblknum;
  char                    * transpose    = &(args->transpose);
  char                    * diag         = &(args->diag);
  PASTIX_INT                       colnbr       = CBLK_COLNBR(cblknum);
  PASTIX_FLOAT                     fun          = 1.0;

  ASSERTDBG(UPDOWN_SM2XNBR == rhsnbr, MOD_SOPALIN);
  ASSERTDBG(UPDOWN_SM2XSZE == rhssze, MOD_SOPALIN);
  switch(arch) {
  case ARCH_CPU:
    SOPALIN_TRSM("L","L",transpose,diag,colnbr,rhsnbr,fun,L,stride,RHS,rhssze);
    break;
  case ARCH_CUDA:
  default:
    errorPrint("Unknown Architecture");
    assert(0);
    break;
  }
}
Ejemplo n.º 23
0
int
SCOTCH_graphOrderInit (
const SCOTCH_Graph * const  grafptr,              /*+ Graph to order                     +*/
SCOTCH_Ordering * const     ordeptr,              /*+ Ordering structure to initialize   +*/
SCOTCH_Num * const          permtab,              /*+ Direct permutation array           +*/
SCOTCH_Num * const          peritab,              /*+ Inverse permutation array          +*/
SCOTCH_Num * const          cblkptr,              /*+ Pointer to number of column blocks +*/
SCOTCH_Num * const          rangtab,              /*+ Column block range array           +*/
SCOTCH_Num * const          treetab)              /*+ Separator tree array               +*/
{
  Graph *             srcgrafptr;
  LibOrder *          libordeptr;

#ifdef SCOTCH_DEBUG_LIBRARY1
  if (sizeof (SCOTCH_Ordering) < sizeof (LibOrder)) {
    errorPrint ("SCOTCH_graphOrderInit: internal error");
    return     (1);
  }
#endif /* SCOTCH_DEBUG_LIBRARY1 */

  srcgrafptr = (Graph *) grafptr;                 /* Use structure as source graph */
  libordeptr = (LibOrder *) ordeptr;
  libordeptr->permtab = ((permtab == NULL) || ((void *) permtab == (void *) grafptr)) ? NULL : (Gnum *) permtab;
  libordeptr->peritab = ((peritab == NULL) || ((void *) peritab == (void *) grafptr)) ? NULL : (Gnum *) peritab;
  libordeptr->cblkptr = ((cblkptr == NULL) || ((void *) cblkptr == (void *) grafptr)) ? NULL : (Gnum *) cblkptr;
  libordeptr->rangtab = ((rangtab == NULL) || ((void *) rangtab == (void *) grafptr)) ? NULL : (Gnum *) rangtab;
  libordeptr->treetab = ((treetab == NULL) || ((void *) treetab == (void *) grafptr)) ? NULL : (Gnum *) treetab;

  return (orderInit (&libordeptr->o, srcgrafptr->baseval, srcgrafptr->vertnbr, libordeptr->peritab));
}
Ejemplo n.º 24
0
bool IniParser::parse(FILE *f) {

	in = f;

	if (in==0) {
		errorPrint("%s: %s", filename, strerror( errno ));
		return false;
	}
	
	nextToken();
	while (!feof(in)) {
				
		if (strcmp(buffer, "[") ==0) {
			if (!readNextSection()) {
				printError("failed to read section");
				fclose(in);
				in=0;				
				return false;
			}
		} else {
			printError("expecting '['");
			fclose(in);
			in=0;				
			return false;
		}
	}

	fclose(in);
	in=0;
	return true;
}
Ejemplo n.º 25
0
void IniParser::printError(const char *err) {
	errorPrint("%s:%d:%d (%s) %s\n",
		filename,
		line,
		col,
		buffer,
		err);
}
Ejemplo n.º 26
0
int
SCOTCH_dgraphMapCompute (
SCOTCH_Dgraph * const       grafptr,              /*+ Graph to map       +*/
SCOTCH_Dmapping * const     mappptr,              /*+ Mapping to compute +*/
SCOTCH_Strat * const        stratptr)             /*+ Mapping strategy   +*/
{
  Kdgraph                 mapgrafdat;             /* Effective mapping graph     */
  Kdmapping               mapmappdat;             /* Initial mapping domain      */
  const Strat *           mapstratptr;            /* Pointer to mapping strategy */
  LibDmapping * restrict  srcmappptr;
  Dgraph *                srcgrafptr;
  int                     o;

  srcgrafptr = (Dgraph *) grafptr;
  srcmappptr = (LibDmapping *) mappptr;

#ifdef SCOTCH_DEBUG_DGRAPH2
  if (dgraphCheck (srcgrafptr) != 0) {
    errorPrint ("SCOTCH_dgraphMapCompute: invalid input graph");
    return     (1);
  }
#endif /* SCOTCH_DEBUG_DGRAPH2 */

  if (*((Strat **) stratptr) == NULL) {           /* Set default mapping strategy if necessary */
    ArchDom             archdomnorg;

    archDomFrst (&srcmappptr->m.archdat, &archdomnorg);
    SCOTCH_stratDgraphMapBuild (stratptr, SCOTCH_STRATQUALITY, srcgrafptr->procglbnbr, archDomSize (&srcmappptr->m.archdat, &archdomnorg), 0.01);
  }
  mapstratptr = *((Strat **) stratptr);
  if (mapstratptr->tabl != &kdgraphmapststratab) {
    errorPrint ("SCOTCH_dgraphMapCompute: not a parallel graph mapping strategy");
    return     (1);
  }

  if (kdgraphInit (&mapgrafdat, srcgrafptr, &srcmappptr->m) != 0)
    return (1);
  mapmappdat.mappptr = &srcmappptr->m;

  if (((o = kdgraphMapSt (&mapgrafdat, &mapmappdat, mapstratptr)) == 0) && /* Perform mapping */
      (srcmappptr->termloctab != NULL))
    o = dmapTerm (&srcmappptr->m, &mapgrafdat.s, srcmappptr->termloctab); /* Use "&mapgrafdat.s" to take advantage of ghost arrays */
  kdgraphExit (&mapgrafdat);

  return (o);
}
Ejemplo n.º 27
0
Archivo: mord.c Proyecto: Hartorn/AN304
SCOTCH_Num
_SCOTCHTdomWght (
const void * const          arch,
const void * const          dom)
{
  errorPrint ("T_domWghtMord: internal error");
  return     (1);
}
Ejemplo n.º 28
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);
}
Ejemplo n.º 29
0
int sparse_gemm_cpu( char * transa, char * transb,
                     int m, int n, int k,
                     PASTIX_FLOAT alpha,
                     const PASTIX_FLOAT * a, int lda,
                     const PASTIX_FLOAT * b, int ldb,
                     PASTIX_FLOAT beta,
                     PASTIX_FLOAT       * c, unsigned int ldc,
                     int blocknbr,  const int * blocktab,
                     int fblocknbr, const int * fblocktab,
                     PASTIX_FLOAT *work, int worksize)
{
    int col;
    int   C_index = 0;
    int   W_index = 0;
    const int * fblock;
    const int * lfblock = &(fblocktab[2*(fblocknbr-1)]);
    const int * block;
    const int * lblock  = &(blocktab[2*(blocknbr-1)]);
    (void)worksize;

    SOPALIN_GEMM( transa, transb,
                  m, n, k,
                  alpha,
                  a, lda,
                  b, ldb,
                  0.,
                  work, m);

    for (block = blocktab, fblock = fblocktab;
            block <= lblock;
            W_index += block[1]-block[0]+1, block+=2)
    {
        int size;
        while ((!(block[0] >= fblock[0] && block[1] <= fblock[1])) &&
                lfblock >= fblock)
        {
            C_index += fblock[1]-fblock[0]+1;
            fblock+=2;
        }
        if (lfblock < fblock)
        {
            errorPrint("block [%d, %d] not found in facing column.",
                       block[0], block[1]);
            return BADPARAMETER_ERR;
        }

        size = block[1]-block[0]+1;
        /* fprintf(stdout, "%d %d %d %g %d\n", C_index, block[0], fblock[0], work[W_index], size); */
        /* fprintf(stdout, "%g\n", c[C_index + block[0]-fblock[0]]); */
        for (col = 0; col < n; col++)
            SOPALIN_SCAL(size, beta, &(c[C_index + block[0]-fblock[0] + col*ldc]), 1);
        SOPALIN_GEAM("N", "N", size, n, 1.0,
                     &(work[W_index]), m,
                     &(c[C_index + block[0]-fblock[0]]),  ldc);
        /* fprintf(stdout, "%g\n", c[C_index + block[0]-fblock[0]]); */
    }
    return NO_ERR;
}
Ejemplo n.º 30
0
Archivo: mord.c Proyecto: Hartorn/AN304
SCOTCH_Num
_SCOTCHTdomDist (
const void * const          arch,
const void * const          dom0,
const void * const          dom1)
{
  errorPrint ("T_domDistMord: internal error");
  return     (1);
}