Skip to content

Commit

Permalink
Rename MMP to MUMPS
Browse files Browse the repository at this point in the history
  • Loading branch information
cpmech committed Sep 21, 2023
1 parent 582394a commit 5c290b0
Show file tree
Hide file tree
Showing 12 changed files with 162 additions and 162 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

We wrap two direct sparse solvers: UMFPACK (aka **UMF**) and MUMPS (aka **MMP**). The default solver is UMF; however UMF may run out of memory for large matrices, whereas MMP still may work. The MMP 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 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.

## Tools

This crate includes a tool named `solve_matrix_market_build` to study the performance of the available sparse solvers (currently MMP 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 UMF). 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
2 changes: 1 addition & 1 deletion russell_sparse/build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fn main() {
.compile("c_code_interface_mumps");
println!("cargo:rustc-link-search=native=/usr/local/lib/mumps");
println!("cargo:rustc-link-lib=dylib=dmumps_cpmech");
println!("cargo:rustc-cfg=local_mmp");
println!("cargo:rustc-cfg=local_mumps");
} else {
cc::Build::new()
.file("c_code/interface_mumps.c")
Expand Down
36 changes: 18 additions & 18 deletions russell_sparse/c_code/interface_mumps.c
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#define INFOG(i) infog[(i)-1] // macro to make indices match documentation
#define INFO(i) info[(i)-1] // macro to make indices match documentation

static inline void set_mmp_verbose(DMUMPS_STRUC_C *data, int32_t verbose) {
static inline void set_mumps_verbose(DMUMPS_STRUC_C *data, int32_t verbose) {
if (verbose == C_TRUE) {
data->ICNTL(1) = 6; // standard output stream
data->ICNTL(2) = 0; // output stream
Expand All @@ -24,13 +24,13 @@ static inline void set_mmp_verbose(DMUMPS_STRUC_C *data, int32_t verbose) {
}
}

struct SolverMMP {
struct SolverMUMPS {
DMUMPS_STRUC_C data; // data structure
int32_t done_job_init; // job init successfully
};

struct SolverMMP *new_solver_mmp() {
struct SolverMMP *solver = (struct SolverMMP *)malloc(sizeof(struct SolverMMP));
struct SolverMUMPS *new_solver_mumps() {
struct SolverMUMPS *solver = (struct SolverMUMPS *)malloc(sizeof(struct SolverMUMPS));

if (solver == NULL) {
return NULL;
Expand All @@ -44,7 +44,7 @@ struct SolverMMP *new_solver_mmp() {
return solver;
}

void drop_solver_mmp(struct SolverMMP *solver) {
void drop_solver_mumps(struct SolverMUMPS *solver) {
if (solver == NULL) {
return;
}
Expand All @@ -63,15 +63,15 @@ void drop_solver_mmp(struct SolverMMP *solver) {
}

if (solver->done_job_init == C_TRUE) {
set_mmp_verbose(&solver->data, C_FALSE);
set_mumps_verbose(&solver->data, C_FALSE);
solver->data.job = MUMPS_JOB_TERMINATE;
dmumps_c(&solver->data);
}

free(solver);
}

int32_t solver_mmp_initialize(struct SolverMMP *solver,
int32_t solver_mumps_initialize(struct SolverMUMPS *solver,
int32_t n,
int32_t nnz,
int32_t symmetry,
Expand All @@ -87,9 +87,9 @@ int32_t solver_mmp_initialize(struct SolverMMP *solver,

solver->data.comm_fortran = MUMPS_IGNORED;
solver->data.par = MUMPS_PAR_HOST_ALSO_WORKS;
solver->data.sym = MMP_SYMMETRY[symmetry];
solver->data.sym = MUMPS_SYMMETRY[symmetry];

set_mmp_verbose(&solver->data, C_FALSE);
set_mumps_verbose(&solver->data, C_FALSE);
solver->data.job = MUMPS_JOB_INITIALIZE;
dmumps_c(&solver->data);
if (solver->data.INFOG(1) != 0) {
Expand Down Expand Up @@ -130,8 +130,8 @@ int32_t solver_mmp_initialize(struct SolverMMP *solver,

solver->data.ICNTL(5) = MUMPS_ICNTL5_ASSEMBLED_MATRIX;
solver->data.ICNTL(6) = MUMPS_ICNTL6_PERMUT_AUTO;
solver->data.ICNTL(7) = MMP_ORDERING[ordering];
solver->data.ICNTL(8) = MMP_SCALING[scaling];
solver->data.ICNTL(7) = MUMPS_ORDERING[ordering];
solver->data.ICNTL(8) = MUMPS_SCALING[scaling];
solver->data.ICNTL(14) = pct_inc_workspace;
solver->data.ICNTL(16) = openmp_num_threads;
solver->data.ICNTL(18) = MUMPS_ICNTL18_CENTRALIZED;
Expand All @@ -152,7 +152,7 @@ int32_t solver_mmp_initialize(struct SolverMMP *solver,
return 0; // success
}

int32_t solver_mmp_factorize(struct SolverMMP *solver,
int32_t solver_mumps_factorize(struct SolverMUMPS *solver,
int32_t const *indices_i,
int32_t const *indices_j,
double const *values_aij,
Expand All @@ -172,7 +172,7 @@ int32_t solver_mmp_factorize(struct SolverMMP *solver,
solver->data.a[p] = values_aij[p];
}

set_mmp_verbose(&solver->data, verbose);
set_mumps_verbose(&solver->data, verbose);
solver->data.job = MUMPS_JOB_ANALYZE;
dmumps_c(&solver->data);

Expand All @@ -183,7 +183,7 @@ int32_t solver_mmp_factorize(struct SolverMMP *solver,

// perform factorization

set_mmp_verbose(&solver->data, verbose);
set_mumps_verbose(&solver->data, verbose);
solver->data.job = MUMPS_JOB_FACTORIZE;
dmumps_c(&solver->data);

Expand All @@ -200,24 +200,24 @@ int32_t solver_mmp_factorize(struct SolverMMP *solver,
return solver->data.INFOG(1);
}

int32_t solver_mmp_solve(struct SolverMMP *solver, double *rhs, int32_t verbose) {
int32_t solver_mumps_solve(struct SolverMUMPS *solver, double *rhs, int32_t verbose) {
if (solver == NULL) {
return NULL_POINTER_ERROR;
}

solver->data.rhs = rhs;

set_mmp_verbose(&solver->data, verbose);
set_mumps_verbose(&solver->data, verbose);
solver->data.job = MUMPS_JOB_SOLVE;
dmumps_c(&solver->data);

return solver->data.INFOG(1);
}

int32_t solver_mmp_used_ordering(struct SolverMMP *solver) {
int32_t solver_mumps_used_ordering(struct SolverMUMPS *solver) {
return solver->data.INFOG(7);
}

int32_t solver_mmp_used_scaling(struct SolverMMP *solver) {
int32_t solver_mumps_used_scaling(struct SolverMUMPS *solver) {
return solver->data.INFOG(33);
}
6 changes: 3 additions & 3 deletions russell_sparse/c_code/interface_mumps.h
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ const MUMPS_INT MUMPS_ICNTL6_PERMUT_AUTO = 7; // section 5.3, page 32
const MUMPS_INT MUMPS_ICNTL28_SEQUENTIAL = 1; // section 5.4, page 33


const MUMPS_INT MMP_SYMMETRY[3] = {
const MUMPS_INT MUMPS_SYMMETRY[3] = {
0, // Unsymmetric
1, // Positive-definite symmetric
2, // General symmetric
};

const MUMPS_INT MMP_ORDERING[10] = {
const MUMPS_INT MUMPS_ORDERING[10] = {
0, // 0: Amd
2, // 1: Amf
7, // 2: Auto
Expand All @@ -36,7 +36,7 @@ const MUMPS_INT MMP_ORDERING[10] = {
3, // 9: Scotch
};

const MUMPS_INT MMP_SCALING[9] = {
const MUMPS_INT MUMPS_SCALING[9] = {
77, // 0: Auto
3, // 1: Column
1, // 2: Diagonal
Expand Down
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 @@ -3,7 +3,7 @@ use russell_sparse::prelude::*;

fn test_solver(name: LinSolKind) {
match name {
LinSolKind::Mmp => println!("Testing MMP solver\n"),
LinSolKind::Mumps => println!("Testing MUMPS solver\n"),
LinSolKind::Umf => println!("Testing UMF solver\n"),
}

Expand Down Expand Up @@ -73,7 +73,7 @@ fn test_solver(name: LinSolKind) {

fn test_solver_singular(name: LinSolKind) {
match name {
LinSolKind::Mmp => println!("Testing MMP solver\n"),
LinSolKind::Mumps => println!("Testing MUMPS solver\n"),
LinSolKind::Umf => println!("Testing UMF solver\n"),
}

Expand Down Expand Up @@ -105,9 +105,9 @@ fn test_solver_singular(name: LinSolKind) {

fn main() {
println!("Running Mem Check\n");
test_solver(LinSolKind::Mmp);
test_solver(LinSolKind::Mumps);
test_solver(LinSolKind::Umf);
test_solver_singular(LinSolKind::Mmp);
test_solver_singular(LinSolKind::Mumps);
test_solver_singular(LinSolKind::Umf);
println!("Done\n");
}
12 changes: 6 additions & 6 deletions russell_sparse/src/bin/solve_matrix_market_build.rs
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ struct Options {
/// Matrix-market file
matrix_market_file: String,

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

/// Ordering strategy
#[structopt(short = "o", long, default_value = "Auto")]
Expand Down Expand Up @@ -86,12 +86,12 @@ fn main() -> Result<(), StrError> {
}

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

// select the symmetric handling option
let handling = match name {
LinSolKind::Mmp => {
// MMP uses the lower-diagonal if symmetric.
LinSolKind::Mumps => {
// MUMPS uses the lower-diagonal if symmetric.
SymmetricHandling::LeaveAsLower
}
LinSolKind::Umf => {
Expand Down Expand Up @@ -189,7 +189,7 @@ fn main() -> Result<(), StrError> {

// check
if path.ends_with("bfwb62.mtx") {
let tolerance = if opt.mmp { 1e-10 } else { 1e-11 };
let tolerance = if opt.mumps { 1e-10 } else { 1e-11 };
let correct_x = get_bfwb62_correct_x();
for i in 0..nrow {
let diff = f64::abs(x.get(i) - correct_x.get(i));
Expand Down
26 changes: 13 additions & 13 deletions russell_sparse/src/config_solver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ pub struct ConfigSolver {
pub(crate) lin_sol_kind: LinSolKind, // linear solver kind
pub(crate) ordering: i32, // symmetric permutation (ordering)
pub(crate) scaling: i32, // scaling strategy
pub(crate) pct_inc_workspace: i32, // % increase in the estimated working space (MMP-only)
pub(crate) max_work_memory: i32, // max size of the working memory in mega bytes (MMP-only)
pub(crate) openmp_num_threads: i32, // number of OpenMP threads (MMP-only)
pub(crate) pct_inc_workspace: i32, // % increase in the estimated working space (MUMPS-only)
pub(crate) max_work_memory: i32, // max size of the working memory in mega bytes (MUMPS-only)
pub(crate) openmp_num_threads: i32, // number of OpenMP threads (MUMPS-only)
pub(crate) verbose: i32, // show lower-level messages
pub(crate) compute_determinant: i32, // compute determinant
}
Expand All @@ -21,9 +21,9 @@ impl ConfigSolver {
lin_sol_kind: LinSolKind::Umf,
ordering: Ordering::Auto as i32,
scaling: Scaling::Auto as i32,
pct_inc_workspace: 100, // (MMP-only)
max_work_memory: 0, // (MMP-only) 0 => Auto
openmp_num_threads: 1, // (MMP-only)
pct_inc_workspace: 100, // (MUMPS-only)
max_work_memory: 0, // (MUMPS-only) 0 => Auto
openmp_num_threads: 1, // (MUMPS-only)
verbose: 0,
compute_determinant: 0,
}
Expand All @@ -47,19 +47,19 @@ impl ConfigSolver {
self
}

/// Sets the percentage increase in the estimated working space (MMP-only)
/// Sets the percentage increase in the estimated working space (MUMPS-only)
pub fn pct_inc_workspace(&mut self, value: usize) -> &mut Self {
self.pct_inc_workspace = to_i32(value);
self
}

/// Sets the maximum size of the working memory in mega bytes (MMP-only)
/// Sets the maximum size of the working memory in mega bytes (MUMPS-only)
pub fn max_work_memory(&mut self, value: usize) -> &mut Self {
self.max_work_memory = to_i32(value);
self
}

/// Sets the number of OpenMP threads (MMP-only)
/// Sets the number of OpenMP threads (MUMPS-only)
pub fn openmp_num_threads(&mut self, value: usize) -> &mut Self {
self.openmp_num_threads = to_i32(value);
self
Expand Down Expand Up @@ -90,8 +90,8 @@ impl ConfigSolver {
/// Returns the name of the solver
pub fn str_solver(&self) -> String {
match self.lin_sol_kind {
LinSolKind::Mmp => {
if cfg!(local_mmp) {
LinSolKind::Mumps => {
if cfg!(local_mumps) {
"MUMPS-local".to_string()
} else {
"MUMPS".to_string()
Expand Down Expand Up @@ -133,10 +133,10 @@ mod tests {
#[test]
fn set_solver_works() {
let mut config = ConfigSolver::new();
for name in [LinSolKind::Mmp, LinSolKind::Umf] {
for name in [LinSolKind::Mumps, LinSolKind::Umf] {
config.lin_sol_kind(name);
match config.lin_sol_kind {
LinSolKind::Mmp => assert!(true),
LinSolKind::Mumps => assert!(true),
LinSolKind::Umf => assert!(true),
}
}
Expand Down
Loading

0 comments on commit 5c290b0

Please sign in to comment.