|
Lines 75-81
Link Here
|
| 75 |
#ifdef DUMP_GRAPH |
75 |
#ifdef DUMP_GRAPH |
| 76 |
#include <stdio.h> |
76 |
#include <stdio.h> |
| 77 |
/* After dumping the graph with this routine, run "onmetis metisgraph" */ |
77 |
/* After dumping the graph with this routine, run "onmetis metisgraph" */ |
| 78 |
static void dumpgraph (idxtype *Mp, idxtype *Mi, SuiteSparse_long n, |
78 |
static void dumpgraph (idx_t *Mp, idx_t *Mi, SuiteSparse_long n, |
| 79 |
cholmod_common *Common) |
79 |
cholmod_common *Common) |
| 80 |
{ |
80 |
{ |
| 81 |
SuiteSparse_long i, j, p, nz ; |
81 |
SuiteSparse_long i, j, p, nz ; |
|
Lines 161-167
Link Here
|
| 161 |
s = GUESS ((double) nz, (double) n) ; |
161 |
s = GUESS ((double) nz, (double) n) ; |
| 162 |
s *= Common->metis_memory ; |
162 |
s *= Common->metis_memory ; |
| 163 |
|
163 |
|
| 164 |
if (s * sizeof (idxtype) >= ((double) Size_max)) |
164 |
if (s * sizeof (idx_t) >= ((double) Size_max)) |
| 165 |
{ |
165 |
{ |
| 166 |
/* don't even attempt to malloc such a large block */ |
166 |
/* don't even attempt to malloc such a large block */ |
| 167 |
return (FALSE) ; |
167 |
return (FALSE) ; |
|
Lines 172-178
Link Here
|
| 172 |
metis_guard *= Common->metis_memory ; |
172 |
metis_guard *= Common->metis_memory ; |
| 173 |
|
173 |
|
| 174 |
/* attempt to malloc the block */ |
174 |
/* attempt to malloc the block */ |
| 175 |
p = CHOLMOD(malloc) (metis_guard, sizeof (idxtype), Common) ; |
175 |
p = CHOLMOD(malloc) (metis_guard, sizeof (idx_t), Common) ; |
| 176 |
if (p == NULL) |
176 |
if (p == NULL) |
| 177 |
{ |
177 |
{ |
| 178 |
/* failure - return out-of-memory condition */ |
178 |
/* failure - return out-of-memory condition */ |
|
Lines 180-186
Link Here
|
| 180 |
} |
180 |
} |
| 181 |
|
181 |
|
| 182 |
/* success - free the block */ |
182 |
/* success - free the block */ |
| 183 |
CHOLMOD(free) (metis_guard, sizeof (idxtype), p, Common) ; |
183 |
CHOLMOD(free) (metis_guard, sizeof (idx_t), p, Common) ; |
| 184 |
return (TRUE) ; |
184 |
return (TRUE) ; |
| 185 |
} |
185 |
} |
| 186 |
|
186 |
|
|
Lines 210-216
Link Here
|
| 210 |
) |
210 |
) |
| 211 |
{ |
211 |
{ |
| 212 |
Int *Ap, *Ai ; |
212 |
Int *Ap, *Ai ; |
| 213 |
idxtype *Mp, *Mi, *Mnw, *Mew, *Mpart ; |
213 |
idx_t *Mp, *Mi, *Mnw, *Mew, *Mpart ; |
| 214 |
Int n, nleft, nright, j, p, csep, total_weight, lightest, nz ; |
214 |
Int n, nleft, nright, j, p, csep, total_weight, lightest, nz ; |
| 215 |
int Opt [8], nn, csp ; |
215 |
int Opt [8], nn, csp ; |
| 216 |
size_t n1 ; |
216 |
size_t n1 ; |
|
Lines 259-265
Link Here
|
| 259 |
/* ---------------------------------------------------------------------- */ |
259 |
/* ---------------------------------------------------------------------- */ |
| 260 |
|
260 |
|
| 261 |
#ifdef LONG |
261 |
#ifdef LONG |
| 262 |
if (sizeof (Int) > sizeof (idxtype) && MAX (n,nz) > INT_MAX / sizeof (int)) |
262 |
if (sizeof (Int) > sizeof (idx_t) && MAX (n,nz) > INT_MAX / sizeof (int)) |
| 263 |
{ |
263 |
{ |
| 264 |
/* CHOLMOD's matrix is too large for METIS */ |
264 |
/* CHOLMOD's matrix is too large for METIS */ |
| 265 |
return (EMPTY) ; |
265 |
return (EMPTY) ; |
|
Lines 282-315
Link Here
|
| 282 |
DEBUG (for (j = 0 ; j < n ; j++) ASSERT (Anw [j] > 0)) ; |
282 |
DEBUG (for (j = 0 ; j < n ; j++) ASSERT (Anw [j] > 0)) ; |
| 283 |
|
283 |
|
| 284 |
/* ---------------------------------------------------------------------- */ |
284 |
/* ---------------------------------------------------------------------- */ |
| 285 |
/* copy Int to METIS idxtype, if necessary */ |
285 |
/* copy Int to METIS idx_t, if necessary */ |
| 286 |
/* ---------------------------------------------------------------------- */ |
286 |
/* ---------------------------------------------------------------------- */ |
| 287 |
|
287 |
|
| 288 |
DEBUG (for (j = 0 ; j < nz ; j++) ASSERT (Aew [j] > 0)) ; |
288 |
DEBUG (for (j = 0 ; j < nz ; j++) ASSERT (Aew [j] > 0)) ; |
| 289 |
if (sizeof (Int) == sizeof (idxtype)) |
289 |
if (sizeof (Int) == sizeof (idx_t)) |
| 290 |
{ |
290 |
{ |
| 291 |
/* this is the typical case */ |
291 |
/* this is the typical case */ |
| 292 |
Mi = (idxtype *) Ai ; |
292 |
Mi = (idx_t *) Ai ; |
| 293 |
Mew = (idxtype *) Aew ; |
293 |
Mew = (idx_t *) Aew ; |
| 294 |
Mp = (idxtype *) Ap ; |
294 |
Mp = (idx_t *) Ap ; |
| 295 |
Mnw = (idxtype *) Anw ; |
295 |
Mnw = (idx_t *) Anw ; |
| 296 |
Mpart = (idxtype *) Partition ; |
296 |
Mpart = (idx_t *) Partition ; |
| 297 |
} |
297 |
} |
| 298 |
else |
298 |
else |
| 299 |
{ |
299 |
{ |
| 300 |
/* idxtype and Int differ; copy the graph into the METIS idxtype */ |
300 |
/* idx_t and Int differ; copy the graph into the METIS idx_t */ |
| 301 |
Mi = CHOLMOD(malloc) (nz, sizeof (idxtype), Common) ; |
301 |
Mi = CHOLMOD(malloc) (nz, sizeof (idx_t), Common) ; |
| 302 |
Mew = CHOLMOD(malloc) (nz, sizeof (idxtype), Common) ; |
302 |
Mew = CHOLMOD(malloc) (nz, sizeof (idx_t), Common) ; |
| 303 |
Mp = CHOLMOD(malloc) (n1, sizeof (idxtype), Common) ; |
303 |
Mp = CHOLMOD(malloc) (n1, sizeof (idx_t), Common) ; |
| 304 |
Mnw = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ; |
304 |
Mnw = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ; |
| 305 |
Mpart = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ; |
305 |
Mpart = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ; |
| 306 |
if (Common->status < CHOLMOD_OK) |
306 |
if (Common->status < CHOLMOD_OK) |
| 307 |
{ |
307 |
{ |
| 308 |
CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ; |
308 |
CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ; |
| 309 |
CHOLMOD(free) (nz, sizeof (idxtype), Mew, Common) ; |
309 |
CHOLMOD(free) (nz, sizeof (idx_t), Mew, Common) ; |
| 310 |
CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ; |
310 |
CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ; |
| 311 |
CHOLMOD(free) (n, sizeof (idxtype), Mnw, Common) ; |
311 |
CHOLMOD(free) (n, sizeof (idx_t), Mnw, Common) ; |
| 312 |
CHOLMOD(free) (n, sizeof (idxtype), Mpart, Common) ; |
312 |
CHOLMOD(free) (n, sizeof (idx_t), Mpart, Common) ; |
| 313 |
return (EMPTY) ; |
313 |
return (EMPTY) ; |
| 314 |
} |
314 |
} |
| 315 |
for (p = 0 ; p < nz ; p++) |
315 |
for (p = 0 ; p < nz ; p++) |
|
Lines 337-349
Link Here
|
| 337 |
if (!metis_memory_ok (n, nz, Common)) |
337 |
if (!metis_memory_ok (n, nz, Common)) |
| 338 |
{ |
338 |
{ |
| 339 |
/* METIS might ask for too much memory and thus terminate the program */ |
339 |
/* METIS might ask for too much memory and thus terminate the program */ |
| 340 |
if (sizeof (Int) != sizeof (idxtype)) |
340 |
if (sizeof (Int) != sizeof (idx_t)) |
| 341 |
{ |
341 |
{ |
| 342 |
CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ; |
342 |
CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ; |
| 343 |
CHOLMOD(free) (nz, sizeof (idxtype), Mew, Common) ; |
343 |
CHOLMOD(free) (nz, sizeof (idx_t), Mew, Common) ; |
| 344 |
CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ; |
344 |
CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ; |
| 345 |
CHOLMOD(free) (n, sizeof (idxtype), Mnw, Common) ; |
345 |
CHOLMOD(free) (n, sizeof (idx_t), Mnw, Common) ; |
| 346 |
CHOLMOD(free) (n, sizeof (idxtype), Mpart, Common) ; |
346 |
CHOLMOD(free) (n, sizeof (idx_t), Mpart, Common) ; |
| 347 |
} |
347 |
} |
| 348 |
return (EMPTY) ; |
348 |
return (EMPTY) ; |
| 349 |
} |
349 |
} |
|
Lines 376-395
Link Here
|
| 376 |
PRINT1 (("METIS csep "ID"\n", csep)) ; |
376 |
PRINT1 (("METIS csep "ID"\n", csep)) ; |
| 377 |
|
377 |
|
| 378 |
/* ---------------------------------------------------------------------- */ |
378 |
/* ---------------------------------------------------------------------- */ |
| 379 |
/* copy the results back from idxtype, if required */ |
379 |
/* copy the results back from idx_t, if required */ |
| 380 |
/* ---------------------------------------------------------------------- */ |
380 |
/* ---------------------------------------------------------------------- */ |
| 381 |
|
381 |
|
| 382 |
if (sizeof (Int) != sizeof (idxtype)) |
382 |
if (sizeof (Int) != sizeof (idx_t)) |
| 383 |
{ |
383 |
{ |
| 384 |
for (j = 0 ; j < n ; j++) |
384 |
for (j = 0 ; j < n ; j++) |
| 385 |
{ |
385 |
{ |
| 386 |
Partition [j] = Mpart [j] ; |
386 |
Partition [j] = Mpart [j] ; |
| 387 |
} |
387 |
} |
| 388 |
CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ; |
388 |
CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ; |
| 389 |
CHOLMOD(free) (nz, sizeof (idxtype), Mew, Common) ; |
389 |
CHOLMOD(free) (nz, sizeof (idx_t), Mew, Common) ; |
| 390 |
CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ; |
390 |
CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ; |
| 391 |
CHOLMOD(free) (n, sizeof (idxtype), Mnw, Common) ; |
391 |
CHOLMOD(free) (n, sizeof (idx_t), Mnw, Common) ; |
| 392 |
CHOLMOD(free) (n, sizeof (idxtype), Mpart, Common) ; |
392 |
CHOLMOD(free) (n, sizeof (idx_t), Mpart, Common) ; |
| 393 |
} |
393 |
} |
| 394 |
|
394 |
|
| 395 |
/* ---------------------------------------------------------------------- */ |
395 |
/* ---------------------------------------------------------------------- */ |
|
Lines 507-513
Link Here
|
| 507 |
{ |
507 |
{ |
| 508 |
double d ; |
508 |
double d ; |
| 509 |
Int *Iperm, *Iwork, *Bp, *Bi ; |
509 |
Int *Iperm, *Iwork, *Bp, *Bi ; |
| 510 |
idxtype *Mp, *Mi, *Mperm, *Miperm ; |
510 |
idx_t *Mp, *Mi, *Mperm, *Miperm ; |
| 511 |
cholmod_sparse *B ; |
511 |
cholmod_sparse *B ; |
| 512 |
Int i, j, n, nz, p, identity, uncol ; |
512 |
Int i, j, n, nz, p, identity, uncol ; |
| 513 |
int Opt [8], nn, zero = 0 ; |
513 |
int Opt [8], nn, zero = 0 ; |
|
Lines 600-606
Link Here
|
| 600 |
/* ---------------------------------------------------------------------- */ |
600 |
/* ---------------------------------------------------------------------- */ |
| 601 |
|
601 |
|
| 602 |
#ifdef LONG |
602 |
#ifdef LONG |
| 603 |
if (sizeof (Int) > sizeof (idxtype) && MAX (n,nz) > INT_MAX / sizeof (int)) |
603 |
if (sizeof (Int) > sizeof (idx_t) && MAX (n,nz) > INT_MAX / sizeof (int)) |
| 604 |
{ |
604 |
{ |
| 605 |
/* CHOLMOD's matrix is too large for METIS */ |
605 |
/* CHOLMOD's matrix is too large for METIS */ |
| 606 |
CHOLMOD(free_sparse) (&B, Common) ; |
606 |
CHOLMOD(free_sparse) (&B, Common) ; |
|
Lines 629-657
Link Here
|
| 629 |
/* allocate the METIS input arrays, if needed */ |
629 |
/* allocate the METIS input arrays, if needed */ |
| 630 |
/* ---------------------------------------------------------------------- */ |
630 |
/* ---------------------------------------------------------------------- */ |
| 631 |
|
631 |
|
| 632 |
if (sizeof (Int) == sizeof (idxtype)) |
632 |
if (sizeof (Int) == sizeof (idx_t)) |
| 633 |
{ |
633 |
{ |
| 634 |
/* This is the typical case. */ |
634 |
/* This is the typical case. */ |
| 635 |
Miperm = (idxtype *) Iperm ; |
635 |
Miperm = (idx_t *) Iperm ; |
| 636 |
Mperm = (idxtype *) Perm ; |
636 |
Mperm = (idx_t *) Perm ; |
| 637 |
Mp = (idxtype *) Bp ; |
637 |
Mp = (idx_t *) Bp ; |
| 638 |
Mi = (idxtype *) Bi ; |
638 |
Mi = (idx_t *) Bi ; |
| 639 |
} |
639 |
} |
| 640 |
else |
640 |
else |
| 641 |
{ |
641 |
{ |
| 642 |
/* allocate graph for METIS only if Int and idxtype differ */ |
642 |
/* allocate graph for METIS only if Int and idx_t differ */ |
| 643 |
Miperm = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ; |
643 |
Miperm = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ; |
| 644 |
Mperm = CHOLMOD(malloc) (n, sizeof (idxtype), Common) ; |
644 |
Mperm = CHOLMOD(malloc) (n, sizeof (idx_t), Common) ; |
| 645 |
Mp = CHOLMOD(malloc) (n1, sizeof (idxtype), Common) ; |
645 |
Mp = CHOLMOD(malloc) (n1, sizeof (idx_t), Common) ; |
| 646 |
Mi = CHOLMOD(malloc) (nz, sizeof (idxtype), Common) ; |
646 |
Mi = CHOLMOD(malloc) (nz, sizeof (idx_t), Common) ; |
| 647 |
if (Common->status < CHOLMOD_OK) |
647 |
if (Common->status < CHOLMOD_OK) |
| 648 |
{ |
648 |
{ |
| 649 |
/* out of memory */ |
649 |
/* out of memory */ |
| 650 |
CHOLMOD(free_sparse) (&B, Common) ; |
650 |
CHOLMOD(free_sparse) (&B, Common) ; |
| 651 |
CHOLMOD(free) (n, sizeof (idxtype), Miperm, Common) ; |
651 |
CHOLMOD(free) (n, sizeof (idx_t), Miperm, Common) ; |
| 652 |
CHOLMOD(free) (n, sizeof (idxtype), Mperm, Common) ; |
652 |
CHOLMOD(free) (n, sizeof (idx_t), Mperm, Common) ; |
| 653 |
CHOLMOD(free) (n1, sizeof (idxtype), Mp, Common) ; |
653 |
CHOLMOD(free) (n1, sizeof (idx_t), Mp, Common) ; |
| 654 |
CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ; |
654 |
CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ; |
| 655 |
return (FALSE) ; |
655 |
return (FALSE) ; |
| 656 |
} |
656 |
} |
| 657 |
for (j = 0 ; j <= n ; j++) |
657 |
for (j = 0 ; j <= n ; j++) |
|
Lines 740-755
Link Here
|
| 740 |
/* free the METIS input arrays */ |
740 |
/* free the METIS input arrays */ |
| 741 |
/* ---------------------------------------------------------------------- */ |
741 |
/* ---------------------------------------------------------------------- */ |
| 742 |
|
742 |
|
| 743 |
if (sizeof (Int) != sizeof (idxtype)) |
743 |
if (sizeof (Int) != sizeof (idx_t)) |
| 744 |
{ |
744 |
{ |
| 745 |
for (i = 0 ; i < n ; i++) |
745 |
for (i = 0 ; i < n ; i++) |
| 746 |
{ |
746 |
{ |
| 747 |
Perm [i] = (Int) (Mperm [i]) ; |
747 |
Perm [i] = (Int) (Mperm [i]) ; |
| 748 |
} |
748 |
} |
| 749 |
CHOLMOD(free) (n, sizeof (idxtype), Miperm, Common) ; |
749 |
CHOLMOD(free) (n, sizeof (idx_t), Miperm, Common) ; |
| 750 |
CHOLMOD(free) (n, sizeof (idxtype), Mperm, Common) ; |
750 |
CHOLMOD(free) (n, sizeof (idx_t), Mperm, Common) ; |
| 751 |
CHOLMOD(free) (n+1, sizeof (idxtype), Mp, Common) ; |
751 |
CHOLMOD(free) (n+1, sizeof (idx_t), Mp, Common) ; |
| 752 |
CHOLMOD(free) (nz, sizeof (idxtype), Mi, Common) ; |
752 |
CHOLMOD(free) (nz, sizeof (idx_t), Mi, Common) ; |
| 753 |
} |
753 |
} |
| 754 |
|
754 |
|
| 755 |
CHOLMOD(free_sparse) (&B, Common) ; |
755 |
CHOLMOD(free_sparse) (&B, Common) ; |