Skip to content

Commit

Permalink
Rename UMFPACK
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmech committed Sep 21, 2023
1 parent 5c290b0 commit a94e172
Show file tree
Hide file tree
Showing 9 changed files with 122 additions and 122 deletions.
4 changes: 2 additions & 2 deletions russell_sparse/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,11 +119,11 @@ fn main() -> Result<(), StrError> {

## Sparse solvers

`russell_sparse` wraps two direct sparse solvers, namely, UMFPACK and MUMPS. The default solver is UMF; however UMF may run out of memory for large matrices, whereas MUMPS still may work. On the other hand, the MUMPS solver is **not** thread-safe and thus must be used in single-threaded applications.
`russell_sparse` wraps two direct sparse solvers, namely, UMFPACK and MUMPS. The default solver is UMFPACK; however UMFPACK may run out of memory for large matrices, whereas MUMPS still may work. On the other hand, the MUMPS solver is **not** thread-safe and thus must be used in single-threaded applications.

## Tools

This crate includes a tool named `solve_matrix_market_build` to study the performance of the available sparse solvers (currently MUMPS and UMF). The `_build` suffix is to disable the coverage tool.
This crate includes a tool named `solve_matrix_market_build` to study the performance of the available sparse solvers (currently MUMPS and UMFPACK). The `_build` suffix is to disable the coverage tool.

`solve_matrix_market_build` reads a [Matrix Market file](https://math.nist.gov/MatrixMarket/formats.html) and solves the linear system:

Expand Down
36 changes: 18 additions & 18 deletions russell_sparse/c_code/interface_umfpack.c
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
#include "constants.h"
#include "interface_umfpack.h"

struct SolverUMF {
struct SolverUMFPACK {
double control[UMFPACK_CONTROL];
double info[UMFPACK_INFO];
int n;
Expand All @@ -15,16 +15,16 @@ struct SolverUMF {
void *numeric;
};

static inline void set_umf_verbose(struct SolverUMF *solver, int32_t verbose) {
static inline void set_umfpack_verbose(struct SolverUMFPACK *solver, int32_t verbose) {
if (verbose == C_TRUE) {
solver->control[UMFPACK_PRL] = UMF_PRINT_LEVEL_VERBOSE;
solver->control[UMFPACK_PRL] = UMFPACK_PRINT_LEVEL_VERBOSE;
} else {
solver->control[UMFPACK_PRL] = UMF_PRINT_LEVEL_SILENT;
solver->control[UMFPACK_PRL] = UMFPACK_PRINT_LEVEL_SILENT;
}
}

struct SolverUMF *new_solver_umf() {
struct SolverUMF *solver = (struct SolverUMF *)malloc(sizeof(struct SolverUMF));
struct SolverUMFPACK *new_solver_umfpack() {
struct SolverUMFPACK *solver = (struct SolverUMFPACK *)malloc(sizeof(struct SolverUMFPACK));

if (solver == NULL) {
return NULL;
Expand All @@ -42,7 +42,7 @@ struct SolverUMF *new_solver_umf() {
return solver;
}

void drop_solver_umf(struct SolverUMF *solver) {
void drop_solver_umfpack(struct SolverUMFPACK *solver) {
if (solver == NULL) {
return;
}
Expand All @@ -69,7 +69,7 @@ void drop_solver_umf(struct SolverUMF *solver) {
free(solver);
}

int32_t solver_umf_initialize(struct SolverUMF *solver,
int32_t solver_umfpack_initialize(struct SolverUMFPACK *solver,
int32_t n,
int32_t nnz,
int32_t symmetry,
Expand All @@ -81,7 +81,7 @@ int32_t solver_umf_initialize(struct SolverUMF *solver,
}

umfpack_di_defaults(solver->control);
solver->control[UMFPACK_STRATEGY] = UMF_SYMMETRY[symmetry];
solver->control[UMFPACK_STRATEGY] = UMFPACK_OPTION_SYMMETRY[symmetry];

solver->ap = (int *)malloc((n + 1) * sizeof(int));
if (solver->ap == NULL) {
Expand All @@ -104,15 +104,15 @@ int32_t solver_umf_initialize(struct SolverUMF *solver,
solver->n = n;
solver->nnz = nnz;

solver->control[UMFPACK_ORDERING] = UMF_ORDERING[ordering];
solver->control[UMFPACK_SCALE] = UMF_SCALING[scaling];
solver->control[UMFPACK_ORDERING] = UMFPACK_OPTION_ORDERING[ordering];
solver->control[UMFPACK_SCALE] = UMFPACK_OPTION_SCALING[scaling];

set_umf_verbose(solver, verbose);
set_umfpack_verbose(solver, verbose);

return UMFPACK_OK;
}

int32_t solver_umf_factorize(struct SolverUMF *solver,
int32_t solver_umfpack_factorize(struct SolverUMFPACK *solver,
int32_t const *indices_i,
int32_t const *indices_j,
double const *values_aij,
Expand All @@ -121,7 +121,7 @@ int32_t solver_umf_factorize(struct SolverUMF *solver,
return NULL_POINTER_ERROR;
}

set_umf_verbose(solver, verbose);
set_umfpack_verbose(solver, verbose);

// convert triplet to compressed column (must be done for every factorization)

Expand Down Expand Up @@ -153,12 +153,12 @@ int32_t solver_umf_factorize(struct SolverUMF *solver,
return code;
}

int32_t solver_umf_solve(struct SolverUMF *solver, double *x, const double *rhs, int32_t verbose) {
int32_t solver_umfpack_solve(struct SolverUMFPACK *solver, double *x, const double *rhs, int32_t verbose) {
if (solver == NULL) {
return NULL_POINTER_ERROR;
}

set_umf_verbose(solver, verbose);
set_umfpack_verbose(solver, verbose);

int code = umfpack_di_solve(UMFPACK_A, solver->ap, solver->ai, solver->ax,
x, rhs, solver->numeric, solver->control, solver->info);
Expand All @@ -170,10 +170,10 @@ int32_t solver_umf_solve(struct SolverUMF *solver, double *x, const double *rhs,
return code;
}

int32_t solver_umf_used_ordering(struct SolverUMF const *solver) {
int32_t solver_umfpack_used_ordering(struct SolverUMFPACK const *solver) {
return solver->info[UMFPACK_ORDERING_USED];
}

int32_t solver_umf_used_scaling(struct SolverUMF const *solver) {
int32_t solver_umfpack_used_scaling(struct SolverUMFPACK const *solver) {
return solver->control[UMFPACK_SCALE];
}
10 changes: 5 additions & 5 deletions russell_sparse/c_code/interface_umfpack.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,12 @@

#include "umfpack.h"

const double UMF_SYMMETRY[2] = {
const double UMFPACK_OPTION_SYMMETRY[2] = {
UMFPACK_STRATEGY_UNSYMMETRIC, // Unsymmetric
UMFPACK_STRATEGY_SYMMETRIC, // General symmetric
};

const double UMF_ORDERING[10] = {
const double UMFPACK_OPTION_ORDERING[10] = {
UMFPACK_ORDERING_AMD, // Amd
UMFPACK_DEFAULT_ORDERING, // Amf => Auto
UMFPACK_DEFAULT_ORDERING, // Auto
Expand All @@ -20,7 +20,7 @@ const double UMF_ORDERING[10] = {
UMFPACK_DEFAULT_ORDERING, // Scotch => Auto
};

const double UMF_SCALING[9] = {
const double UMFPACK_OPTION_SCALING[9] = {
UMFPACK_DEFAULT_SCALE, // Auto
UMFPACK_DEFAULT_SCALE, // Column => Auto
UMFPACK_DEFAULT_SCALE, // Diagonal => Auto
Expand All @@ -32,5 +32,5 @@ const double UMF_SCALING[9] = {
UMFPACK_SCALE_SUM, // Sum
};

const double UMF_PRINT_LEVEL_SILENT = 0.0; // page 116
const double UMF_PRINT_LEVEL_VERBOSE = 2.0; // page 116
const double UMFPACK_PRINT_LEVEL_SILENT = 0.0; // page 116
const double UMFPACK_PRINT_LEVEL_VERBOSE = 2.0; // page 116
8 changes: 4 additions & 4 deletions russell_sparse/src/bin/mem_check_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ use russell_sparse::prelude::*;
fn test_solver(name: LinSolKind) {
match name {
LinSolKind::Mumps => println!("Testing MUMPS solver\n"),
LinSolKind::Umf => println!("Testing UMF solver\n"),
LinSolKind::Umfpack => println!("Testing UMFPACK solver\n"),
}

let (nrow, ncol, nnz) = (5, 5, 13);
Expand Down Expand Up @@ -74,7 +74,7 @@ fn test_solver(name: LinSolKind) {
fn test_solver_singular(name: LinSolKind) {
match name {
LinSolKind::Mumps => println!("Testing MUMPS solver\n"),
LinSolKind::Umf => println!("Testing UMF solver\n"),
LinSolKind::Umfpack => println!("Testing UMFPACK solver\n"),
}

let (nrow, ncol, nnz) = (2, 2, 2);
Expand Down Expand Up @@ -106,8 +106,8 @@ fn test_solver_singular(name: LinSolKind) {
fn main() {
println!("Running Mem Check\n");
test_solver(LinSolKind::Mumps);
test_solver(LinSolKind::Umf);
test_solver(LinSolKind::Umfpack);
test_solver_singular(LinSolKind::Mumps);
test_solver_singular(LinSolKind::Umf);
test_solver_singular(LinSolKind::Umfpack);
println!("Done\n");
}
8 changes: 4 additions & 4 deletions russell_sparse/src/bin/solve_matrix_market_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ struct Options {
/// Matrix-market file
matrix_market_file: String,

/// Use MUMPS solver instead of UMF
/// Use MUMPS solver instead of UMFPACK
#[structopt(short, long)]
mumps: bool,

Expand Down Expand Up @@ -86,16 +86,16 @@ fn main() -> Result<(), StrError> {
}

// select linear solver
let name = if opt.mumps { LinSolKind::Mumps } else { LinSolKind::Umf };
let name = if opt.mumps { LinSolKind::Mumps } else { LinSolKind::Umfpack };

// select the symmetric handling option
let handling = match name {
LinSolKind::Mumps => {
// MUMPS uses the lower-diagonal if symmetric.
SymmetricHandling::LeaveAsLower
}
LinSolKind::Umf => {
// UMF uses the full matrix, if symmetric or not
LinSolKind::Umfpack => {
// UMFPACK uses the full matrix, if symmetric or not
SymmetricHandling::MakeItFull
}
};
Expand Down
10 changes: 5 additions & 5 deletions russell_sparse/src/config_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ impl ConfigSolver {
/// Returns a default configuration
pub fn new() -> Self {
ConfigSolver {
lin_sol_kind: LinSolKind::Umf,
lin_sol_kind: LinSolKind::Umfpack,
ordering: Ordering::Auto as i32,
scaling: Scaling::Auto as i32,
pct_inc_workspace: 100, // (MUMPS-only)
Expand Down Expand Up @@ -97,7 +97,7 @@ impl ConfigSolver {
"MUMPS".to_string()
}
}
LinSolKind::Umf => "UMFPACK".to_string(),
LinSolKind::Umfpack => "UMFPACK".to_string(),
}
}
}
Expand All @@ -110,7 +110,7 @@ mod tests {

#[test]
fn clone_copy_and_debug_work() {
let correct = "ConfigSolver { lin_sol_kind: Umf, ordering: 2, scaling: 0, pct_inc_workspace: 100, max_work_memory: 0, openmp_num_threads: 1, verbose: 0, compute_determinant: 0 }";
let correct = "ConfigSolver { lin_sol_kind: Umfpack, ordering: 2, scaling: 0, pct_inc_workspace: 100, max_work_memory: 0, openmp_num_threads: 1, verbose: 0, compute_determinant: 0 }";
let config = ConfigSolver::new();
let copy = config;
let clone = config.clone();
Expand All @@ -133,11 +133,11 @@ mod tests {
#[test]
fn set_solver_works() {
let mut config = ConfigSolver::new();
for name in [LinSolKind::Mumps, LinSolKind::Umf] {
for name in [LinSolKind::Mumps, LinSolKind::Umfpack] {
config.lin_sol_kind(name);
match config.lin_sol_kind {
LinSolKind::Mumps => assert!(true),
LinSolKind::Umf => assert!(true),
LinSolKind::Umfpack => assert!(true),
}
}
}
Expand Down
Loading

0 comments on commit a94e172

Please sign in to comment.