Skip to content

Instantly share code, notes, and snippets.

@staticfloat
Created July 12, 2012 23:38
Show Gist options
  • Save staticfloat/3101831 to your computer and use it in GitHub Desktop.
Save staticfloat/3101831 to your computer and use it in GitHub Desktop.
Suite-Sparse 4.0.1 patch
diff -ur ../SuiteSparse.orig/CHOLMOD/Partition/cholmod_metis.c ./CHOLMOD/Partition/cholmod_metis.c
--- ../SuiteSparse.orig/CHOLMOD/Partition/cholmod_metis.c 2007-05-04 11:47:17.000000000 -0500
+++ ./CHOLMOD/Partition/cholmod_metis.c 2011-10-21 18:21:54.000000000 -0500
@@ -76,7 +76,7 @@
#ifdef DUMP_GRAPH
#include <stdio.h>
/* After dumping the graph with this routine, run "onmetis metisgraph" */
-static void dumpgraph (idxtype *Mp, idxtype *Mi, SuiteSparse_long n,
+static void dumpgraph (idx_t *Mp, idx_t *Mi, SuiteSparse_long n,
cholmod_common *Common)
{
UF_long i, j, p, nz ;
@@ -162,7 +162,7 @@
s = GUESS ((double) nz, (double) n) ;
s *= Common->metis_memory ;
- if (s * sizeof (idxtype) >= ((double) Size_max))
+ if (s * sizeof (idx_t) >= ((double) Size_max))
{
/* don't even attempt to malloc such a large block */
return (FALSE) ;
@@ -173,7 +173,7 @@
metis_guard *= Common->metis_memory ;
/* attempt to malloc the block */
- p = CHOLMOD(malloc) (metis_guard, sizeof (idxtype), Common) ;
+ p = CHOLMOD(malloc) (metis_guard, sizeof (idx_t), Common) ;
if (p == NULL)
{
/* failure - return out-of-memory condition */
@@ -181,7 +181,7 @@
}
/* success - free the block */
- CHOLMOD(free) (metis_guard, sizeof (idxtype), p, Common) ;
+ CHOLMOD(free) (metis_guard, sizeof (idx_t), p, Common) ;
return (TRUE) ;
}
@@ -211,7 +211,7 @@
)
{
Int *Ap, *Ai ;
- idxtype *Mp, *Mi, *Mnw, *Mew, *Mpart ;
+ idx_t *Mp, *Mi, *Mnw, *Mew, *Mpart ;
Int n, nleft, nright, j, p, csep, total_weight, lightest, nz ;
int Opt [8], nn, csp ;
size_t n1 ;
@@ -260,7 +260,7 @@
/* ---------------------------------------------------------------------- */
#ifdef LONG
- if (sizeof (Int) > sizeof (idxtype) && MAX (n,nz) > INT_MAX / sizeof (int))
+ if (sizeof (Int) > sizeof (idx_t) && MAX (n,nz) > INT_MAX / sizeof (int))
{
/* CHOLMOD's matrix is too large for METIS */
return (EMPTY) ;
@@ -283,34 +283,34 @@
DEBUG (for (j = 0 ; j < n ; j++) ASSERT (Anw [j] > 0)) ;
/* ---------------------------------------------------------------------- */
- /* copy Int to METIS idxtype, if necessary */
+ /* copy Int to METIS idx_t, if necessary */
/* ---------------------------------------------------------------------- */
DEBUG (for (j = 0 ; j < nz ; j++) ASSERT (Aew [j] > 0)) ;
- if (sizeof (Int) == sizeof (idxtype))
+ if (sizeof (Int) == sizeof (idx_t))
{
/* this is the typical case */
- Mi = (idxtype *) Ai ;
- Mew = (idxtype *) Aew ;
- Mp = (idxtype *) Ap ;
- Mnw = (idxtype *) Anw ;
- Mpart = (idxtype *) Partition ;
+ Mi = (idx_t *) Ai ;
+ Mew = (idx_t *) Aew ;
+ Mp = (idx_t *) Ap ;
+ Mnw = (idx_t *) Anw ;
+ Mpart = (idx_t *) Partition ;
}
else
{
- /* idxtype and Int differ; copy the graph into the METIS idxtype */
- Mi = CHOLMOD(malloc) (nz, sizeof (idxtype), Common) ;
- Mew = CHOLMOD(malloc) (nz, sizeof (idxtype), Common) ;
- Mp = CHOLMOD(malloc) (n1, sizeof (idxtype), Common) ;
- Mnw = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ;
- Mpart = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ;
+ /* idx_t and Int differ; copy the graph into the METIS idx_t */
+ Mi = CHOLMOD(malloc) (nz, sizeof (idx_t), Common) ;
+ Mew = CHOLMOD(malloc) (nz, sizeof (idx_t), Common) ;
+ Mp = CHOLMOD(malloc) (n1, sizeof (idx_t), Common) ;
+ Mnw = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ;
+ Mpart = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ;
if (Common->status < CHOLMOD_OK)
{
- CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ;
- CHOLMOD(free) (nz, sizeof (idxtype), Mew, Common) ;
- CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mnw, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mpart, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mew, Common) ;
+ CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mnw, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mpart, Common) ;
return (EMPTY) ;
}
for (p = 0 ; p < nz ; p++)
@@ -338,13 +338,13 @@
if (!metis_memory_ok (n, nz, Common))
{
/* METIS might ask for too much memory and thus terminate the program */
- if (sizeof (Int) != sizeof (idxtype))
+ if (sizeof (Int) != sizeof (idx_t))
{
- CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ;
- CHOLMOD(free) (nz, sizeof (idxtype), Mew, Common) ;
- CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mnw, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mpart, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mew, Common) ;
+ CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mnw, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mpart, Common) ;
}
return (EMPTY) ;
}
@@ -370,27 +370,27 @@
#endif
nn = n ;
- METIS_NodeComputeSeparator (&nn, Mp, Mi, Mnw, Mew, Opt, &csp, Mpart) ;
+ METIS_ComputeVertexSeparator (&nn, Mp, Mi, Mnw, Opt, &csp, Mpart) ;
n = nn ;
csep = csp ;
PRINT1 (("METIS csep "ID"\n", csep)) ;
/* ---------------------------------------------------------------------- */
- /* copy the results back from idxtype, if required */
+ /* copy the results back from idx_t, if required */
/* ---------------------------------------------------------------------- */
- if (sizeof (Int) != sizeof (idxtype))
+ if (sizeof (Int) != sizeof (idx_t))
{
for (j = 0 ; j < n ; j++)
{
Partition [j] = Mpart [j] ;
}
- CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ;
- CHOLMOD(free) (nz, sizeof (idxtype), Mew, Common) ;
- CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mnw, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mpart, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mew, Common) ;
+ CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mnw, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mpart, Common) ;
}
/* ---------------------------------------------------------------------- */
@@ -508,7 +508,7 @@
{
double d ;
Int *Iperm, *Iwork, *Bp, *Bi ;
- idxtype *Mp, *Mi, *Mperm, *Miperm ;
+ idx_t *Mp, *Mi, *Mperm, *Miperm ;
cholmod_sparse *B ;
Int i, j, n, nz, p, identity, uncol ;
int Opt [8], nn, zero = 0 ;
@@ -601,7 +601,7 @@
/* ---------------------------------------------------------------------- */
#ifdef LONG
- if (sizeof (Int) > sizeof (idxtype) && MAX (n,nz) > INT_MAX / sizeof (int))
+ if (sizeof (Int) > sizeof (idx_t) && MAX (n,nz) > INT_MAX / sizeof (int))
{
/* CHOLMOD's matrix is too large for METIS */
CHOLMOD(free_sparse) (&B, Common) ;
@@ -630,29 +630,29 @@
/* allocate the METIS input arrays, if needed */
/* ---------------------------------------------------------------------- */
- if (sizeof (Int) == sizeof (idxtype))
+ if (sizeof (Int) == sizeof (idx_t))
{
/* This is the typical case. */
- Miperm = (idxtype *) Iperm ;
- Mperm = (idxtype *) Perm ;
- Mp = (idxtype *) Bp ;
- Mi = (idxtype *) Bi ;
+ Miperm = (idx_t *) Iperm ;
+ Mperm = (idx_t *) Perm ;
+ Mp = (idx_t *) Bp ;
+ Mi = (idx_t *) Bi ;
}
else
{
- /* allocate graph for METIS only if Int and idxtype differ */
- Miperm = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ;
- Mperm = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ;
- Mp = CHOLMOD(malloc) (n1, sizeof (idxtype), Common) ;
- Mi = CHOLMOD(malloc) (nz, sizeof (idxtype), Common) ;
+ /* allocate graph for METIS only if Int and idx_t differ */
+ Miperm = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ;
+ Mperm = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ;
+ Mp = CHOLMOD(malloc) (n1, sizeof (idx_t), Common) ;
+ Mi = CHOLMOD(malloc) (nz, sizeof (idx_t), Common) ;
if (Common->status < CHOLMOD_OK)
{
/* out of memory */
CHOLMOD(free_sparse) (&B, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Miperm, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mperm, Common) ;
- CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ;
- CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Miperm, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mperm, Common) ;
+ CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ;
return (FALSE) ;
}
for (j = 0 ; j <= n ; j++)
@@ -741,16 +741,16 @@
/* free the METIS input arrays */
/* ---------------------------------------------------------------------- */
- if (sizeof (Int) != sizeof (idxtype))
+ if (sizeof (Int) != sizeof (idx_t))
{
for (i = 0 ; i < n ; i++)
{
Perm [i] = (Int) (Mperm [i]) ;
}
- CHOLMOD(free) (n, sizeof (idxtype), Miperm, Common) ;
- CHOLMOD(free) (n, sizeof (idxtype), Mperm, Common) ;
- CHOLMOD(free) (n+1, sizeof (idxtype), Mp, Common) ;
- CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Miperm, Common) ;
+ CHOLMOD(free) (n, sizeof (idx_t), Mperm, Common) ;
+ CHOLMOD(free) (n+1, sizeof (idx_t), Mp, Common) ;
+ CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ;
}
CHOLMOD(free_sparse) (&B, Common) ;
Only in .: metis.patch
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment