Skip to content

Commit

Permalink
test coverage for int32 version of SPQR
Browse files Browse the repository at this point in the history
  • Loading branch information
DrTimothyAldenDavis committed Sep 4, 2023
1 parent 82f9081 commit 947b4c9
Show file tree
Hide file tree
Showing 21 changed files with 3,987 additions and 2,989 deletions.
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,9 @@ SPQR/Tcov/gpu_results.txt
SPQR/Tcov/gpuqrengine_demo
SPQR/Tcov/qrdemo_gpu
SPQR/Tcov/qrtest
SPQR/Tcov/qrtest32
SPQR/Tcov/qrtest_out.txt
SPQR/Tcov/qrtest_out32.txt
SPQR/Tcov/troll.m
SPQR/Tcov/cov.out

Expand Down
2 changes: 1 addition & 1 deletion CHOLMOD/Check/cholmod_check.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@
/* === printing definitions ================================================= */
/* ========================================================================== */

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
#define I8 "%8ld"
#define I_8 "%-8ld"
#else
Expand Down
2 changes: 1 addition & 1 deletion CHOLMOD/Cholesky/cholmod_amd.c
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ int CHOLMOD(amd)
Control [AMD_AGGRESSIVE] = Common->method [Common->current].aggressive ;
}

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
amd_l2 (n, C->p, C->i, Len, C->nzmax, cnz, Nv, Next, Perm, Head, Elen,
Degree, Wi, Control, Info) ;
#else
Expand Down
4 changes: 2 additions & 2 deletions CHOLMOD/Cholesky/cholmod_colamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ int CHOLMOD(colamd)
s = CHOLMOD(mult_size_t) (nrow, 4, &ok) ;
s = CHOLMOD(add_size_t) (s, ncol, &ok) ;

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
alen = colamd_l_recommended (A->nzmax, ncol, nrow) ;
colamd_l_set_defaults (knobs) ;
#else
Expand Down Expand Up @@ -151,7 +151,7 @@ int CHOLMOD(colamd)
Int stats [COLAMD_STATS] ;
Cp = C->p ;

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
colamd_l (ncol, nrow, alen, C->i, Cp, knobs, stats) ;
#else
colamd (ncol, nrow, alen, C->i, Cp, knobs, stats) ;
Expand Down
2 changes: 2 additions & 0 deletions CHOLMOD/Doc/ChangeLog
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ FIXME DATE, 2023: version 4.2.0
* bug fix: typecast was broken in cholmod_postorder.c
* minor fixes to debug scaffolding and test code: cholmod_internal.h,
cholmod_metis_wrapper.c, Tcov/memory.c.
* support for SPQR: minor changes to support SPQR v4.2.0 with 32-bit
integers; no change to user-visible API.

June 16, 2023: version 4.0.4

Expand Down
88 changes: 6 additions & 82 deletions CHOLMOD/Include/cholmod_internal.h
Original file line number Diff line number Diff line change
Expand Up @@ -133,45 +133,12 @@
/* === int/long and double/float definitions ================================ */
/* ========================================================================== */

/* CHOLMOD is designed for 3 types of integer variables:
*
* (1) all integers are int
* (2) most integers are int, some are int64_t
* (3) all integers are int64_t
*
* and two kinds of floating-point values:
*
* (1) double
* (2) float
*
* the complex types (ANSI-compatible complex, and MATLAB-compatable zomplex)
* are based on the double or float type, and are not selected here. They
* are typically selected via template routines.
*
* This gives 6 different modes in which CHOLMOD can be compiled (only the
* first two are currently supported):
*
* DINT double, int prefix: cholmod_
* DLONG double, int64_t prefix: cholmod_l_
* DMIX double, mixed int/int64_t prefix: cholmod_m_
* SINT float, int prefix: cholmod_si_
* SLONG float, int64_t prefix: cholmod_sl_
* SMIX float, mixed int/log prefix: cholmod_sm_
*
* These are selected with compile time flags (-DDLONG, for example). If no
* flag is selected, the default is DINT.
*
* All six versions use the same include files. The user-visible include files
* are completely independent of which int/long/double/float version is being
* used. The integer / real types in all data structures (sparse, triplet,
* dense, common, and triplet) are defined at run-time, not compile-time, so
* there is only one "cholmod_sparse" data type. Void pointers are used inside
* that data structure to point to arrays of the proper type. Each data
* structure has an itype and dtype field which determines the kind of basic
* types used. These are defined in Include/cholmod_core.h.
*
* FUTURE WORK: support all six types (float, and mixed int/long)
*/
#include "cholmod_types.h"

#ifndef DLONG
// GPU acceleration only available for the DLONG case (double, int64)
#undef SUITESPARSE_CUDA
#endif

/* -------------------------------------------------------------------------- */
/* routines for doing arithmetic on size_t, and checking for overflow */
Expand All @@ -182,49 +149,6 @@ size_t cholmod_mult_size_t (size_t a, size_t k, int *ok) ;
size_t cholmod_l_add_size_t (size_t a, size_t b, int *ok) ;
size_t cholmod_l_mult_size_t (size_t a, size_t k, int *ok) ;

/* -------------------------------------------------------------------------- */
/* double (also complex double), int64_t */
/* -------------------------------------------------------------------------- */

#ifdef DLONG
#define Real double
#define Int int64_t
#define UInt uint64_t
#define Int_max INT64_MAX
#define CHOLMOD(name) cholmod_l_ ## name
#define LONG
#define DOUBLE
#define ITYPE CHOLMOD_LONG
#define DTYPE CHOLMOD_DOUBLE
#define ID "%" PRId64

/* -------------------------------------------------------------------------- */
/* double (also complex double), int: this is the default */
/* -------------------------------------------------------------------------- */

#else

#ifndef DINT
#define DINT
#endif
#define INT
#define DOUBLE

#define Real double
#define Int int32_t
#define UInt uint32_t
#define Int_max INT32_MAX
#define CHOLMOD(name) cholmod_ ## name
#define ITYPE CHOLMOD_INT
#define DTYPE CHOLMOD_DOUBLE
#define ID "%d"

/* GPU acceleration is not available for the int version of CHOLMOD */
#undef SUITESPARSE_CUDA

#endif


/* ========================================================================== */
/* === Include/cholmod_complexity.h ========================================= */
/* ========================================================================== */
Expand Down
139 changes: 139 additions & 0 deletions CHOLMOD/Include/cholmod_types.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,139 @@
//------------------------------------------------------------------------------
// CHOLMOD/Include/cholmod_types.h
//------------------------------------------------------------------------------

// CHOLMOD/Include/cholmod_types.h. Copyright (C) 2005-2023,
// Timothy A. Davis. All Rights Reserved.
// SPDX-License-Identifier: Apache-2.0

//------------------------------------------------------------------------------

// CHOLMOD internal include file: defining integer and floating-point types.
// This file is suitable for inclusion in C and C++ codes. It can be
// #include'd more than once.

// The #include'ing file defines one of four macros (DINT, DLONG, SINT, or
// SLONG) before #include'ing this file.

/* ========================================================================== */
/* === int/long and double/float definitions ================================ */
/* ========================================================================== */

/* CHOLMOD is designed for 3 types of integer variables:
*
* (1) all integers are int
* (2) most integers are int, some are int64_t
* (3) all integers are int64_t
*
* and two kinds of floating-point values:
*
* (1) double
* (2) float
*
* the complex types (ANSI-compatible complex, and MATLAB-compatable zomplex)
* are based on the double or float type, and are not selected here. They
* are typically selected via template routines.
*
* This gives 6 different modes in which CHOLMOD can be compiled (only the
* first two are currently supported):
*
* DINT double, int prefix: cholmod_
* DLONG double, int64_t prefix: cholmod_l_
* DMIX double, mixed int/int64_t prefix: cholmod_m_
* SINT float, int prefix: cholmod_si_
* SLONG float, int64_t prefix: cholmod_sl_
* SMIX float, mixed int/log prefix: cholmod_sm_
*
* These are selected with compile time flags (-DDLONG, for example). If no
* flag is selected, the default is DINT.
*
* All six versions use the same include files. The user-visible include files
* are completely independent of which int/long/double/float version is being
* used. The integer / real types in all data structures (sparse, triplet,
* dense, common, and triplet) are defined at run-time, not compile-time, so
* there is only one "cholmod_sparse" data type. Void pointers are used inside
* that data structure to point to arrays of the proper type. Each data
* structure has an itype and dtype field which determines the kind of basic
* types used. These are defined in Include/cholmod_core.h.
*
* FUTURE WORK: support all six types (float, and mixed int/long)
* SINT and SLONG are in progress.
*/

// -----------------------------------------------------------------------------

#undef Real
#undef Int
#undef UInt
#undef Int_max
#undef CHOLMOD
#undef ITYPE
#undef DTYPE
#undef ID

#if defined ( SLONG )

//--------------------------------------------------------------------------
// SLONG: float (also complex float), int64_t
//--------------------------------------------------------------------------

#define Real float
#define Int int64_t
#define UInt uint64_t
#define Int_max INT64_MAX
#define CHOLMOD(name) cholmod_sl_ ## name
#define ITYPE CHOLMOD_LONG
#define DTYPE CHOLMOD_SINGLE
#define ID "%" PRId64

#elif defined ( SINT )

//--------------------------------------------------------------------------
// SINT: float (also complex float), int32_t
//--------------------------------------------------------------------------

#define Real float
#define Int int32_t
#define UInt uint32_t
#define Int_max INT32_MAX
#define CHOLMOD(name) cholmod_si_ ## name
#define ITYPE CHOLMOD_INT
#define DTYPE CHOLMOD_SINGLE
#define ID "%d"

#elif defined ( DLONG )

//--------------------------------------------------------------------------
// DLONG: double (also complex double), int64_t
//--------------------------------------------------------------------------

#define Real double
#define Int int64_t
#define UInt uint64_t
#define Int_max INT64_MAX
#define CHOLMOD(name) cholmod_l_ ## name
#define ITYPE CHOLMOD_LONG
#define DTYPE CHOLMOD_DOUBLE
#define ID "%" PRId64

#else

//--------------------------------------------------------------------------
// DINT: double (also complex double), int32
//--------------------------------------------------------------------------

#ifndef DINT
#define DINT
#endif

#define Real double
#define Int int32_t
#define UInt uint32_t
#define Int_max INT32_MAX
#define CHOLMOD(name) cholmod_ ## name
#define ITYPE CHOLMOD_INT
#define DTYPE CHOLMOD_DOUBLE
#define ID "%d"

#endif

2 changes: 1 addition & 1 deletion CHOLMOD/Partition/cholmod_camd.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,7 @@ int CHOLMOD(camd)
Control [CAMD_AGGRESSIVE] = Common->method [Common->current].aggressive;
}

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
/* DEBUG (camd_l_debug_init ("cholmod_l_camd")) ; */
camd_l2 (n, C->p, C->i, Len, C->nzmax, cnz, Nv, Next, Perm, Head, Elen,
Degree, Wi, Control, Info, Cmember, BucketSet) ;
Expand Down
6 changes: 3 additions & 3 deletions CHOLMOD/Partition/cholmod_ccolamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ static int ccolamd_interface
/* ---------------------------------------------------------------------- */

/* get parameters */
#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
ccolamd_l_set_defaults (knobs) ;
#else
ccolamd_set_defaults (knobs) ;
Expand All @@ -90,7 +90,7 @@ static int ccolamd_interface
if (ok)
{

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
ccolamd_l (ncol, nrow, alen, C->i, C->p, knobs, stats, Cmember) ;
#else
ccolamd (ncol, nrow, alen, C->i, C->p, knobs, stats, Cmember) ;
Expand Down Expand Up @@ -164,7 +164,7 @@ int CHOLMOD(ccolamd)
/* allocate workspace */
/* ---------------------------------------------------------------------- */

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
alen = ccolamd_l_recommended (A->nzmax, ncol, nrow) ;
#else
alen = ccolamd_recommended (A->nzmax, ncol, nrow) ;
Expand Down
4 changes: 2 additions & 2 deletions CHOLMOD/Partition/cholmod_csymamd.c
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ int CHOLMOD(csymamd)
perm = Common->Head ; /* size nrow+1 (i/l/l) */

/* get parameters */
#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
ccolamd_l_set_defaults (knobs) ;
#else
ccolamd_set_defaults (knobs) ;
Expand All @@ -103,7 +103,7 @@ int CHOLMOD(csymamd)
calloc_func = SuiteSparse_config_calloc_func_get ( ) ;
free_func = SuiteSparse_config_free_func_get ( ) ;

#ifdef LONG
#if ( ITYPE == CHOLMOD_LONG )
csymamd_l (nrow, A->i, A->p, perm, knobs, stats,
calloc_func,
free_func,
Expand Down
Loading

0 comments on commit 947b4c9

Please sign in to comment.