Skip to content

Commit 3889445

Browse files
chiao45xmjiao
andauthored
Chiao/dev (#3)
* changed to enable -NDEBUG in mmex for -O * Updated license * Added FGMRES solver for nullspace * Set rank for backsolve * Added PIPIT * updated reference to hifir * Removed unused codes * Updated CPP source directory * Added version and updated ijv2crs * Updated C++ kernels in HIFIR4M with new HIFIR * Updated examples using new APIs. * Updated using field name for params * Fixed authors * Fixed checking before recompilation * updated .gitignore * updated pipitHifir * Added download hifir script * Updated building script to use downloaded hifir * Removed submodule * Added option to use local C++ hifir * Updated building process * Updated ignore list for user hifir source * Changed to urlwrite * Updated varaible name * Fixed integer size for Octave * Added update and refactor * Fixed bugs in apply * Fixed bugs in create * Updated building script * Updated cite bibtex in readme * Fixed bug in hifir * Added version file and build * Added user HIF * Updated control parameters * Updated README * Updated to addparam * Updated installation * Added user-provided HIF * Added changelog Co-authored-by: Xiangmin Jiao <[email protected]>
1 parent 309c7e1 commit 3889445

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+1167
-1968
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,4 +7,7 @@
77
.DS_Store
88
.*swp
99
*.o
10+
*.bak
11+
*.asv
1012
.MATLABDriveTag
13+
hifir-*

.gitmodules

Lines changed: 0 additions & 3 deletions
This file was deleted.

CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Changelog #
2+
3+
All notable changes to this project will be documented in this file.
4+
5+
## [v0.1.0](https://github.com/hifirworks/hifir4m/releases/tag/v0.1.0) (2021-09-02) ##
6+
7+
This is the initial official release of the HIFIR4M package based on the C++ HIFIR [v0.1.0](https://github.com/hifirworks/hifir/releases/tag/v0.1.0).

README.md

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,20 +4,36 @@
44

55
## Installation ##
66

7-
Clone this project to your preferred location. Then start MATLAB or GNU Octave under the directory that contains `hifir4m`, or run the command
7+
Clone this project to your preferred location, i.e.,
8+
9+
```console
10+
git clone -b release https://github.com/hifirworks/hifir4m.git
11+
```
12+
13+
Use `git pull` to download any new changes that have been added since `git clone` or last `git pull`. Alternatively, use `git checkout v[GLOBAL].[MAJOR].[MINOR]` to download a specific version.
14+
15+
Then start MATLAB or GNU Octave under the directory that contains `hifir4m`, or run the command
816

917
```matlab
10-
>> run('/path/to/hifir4m/load_hifir')
18+
>> run('/path/to/hifir4m/startup_hifir')
1119
```
1220

1321
(and replace `/path/to/hifir4m/` to the directory that contains `hifir4m`) bo build `hifir4m` and load its path. It will build the *mex* kernels if needed by linking to MATLAB and Octave's built-in BLAS/LAPACK libraries for the low-level QRCP.
1422

23+
Note that for the first time, `hifir4m` will download C++ package [HIFIR](https://github.com/hifirworks/hifir) while building *mex* kernels. If you don't have access to network during building *mex* kernels, then you can obtain HIFIR beforehand and put its source in `hifir4m/hifir-[hifir-version]` folder; for instance, you can run the following command to download the C++ HIFIR package
24+
25+
```console
26+
cd /path/to/hifir4m
27+
wget -qO- https://github.com/hifirworks/hifir/archive/refs/tags/v`cat VERSION`.tar.gz|tar xzf -
28+
```
29+
1530
## Usage ##
1631

1732
The easiest way to use `hifir4m` is to call the `gmresHif` interface. For example,
1833
```matlab
1934
>> [x, flag, relres, iter, reshis, times] = gmresHif(A, b);
2035
```
36+
2137
where `A` is a MATLAB's built-in sparse matrix or a `MATLAB` `struct` containing the filds of `row_ptr`, `col_ind`, `vals` of a standard CRS storage format, and `b` is a right-hand-side vector (or RHS vectors with two columns).
2238

2339
To access the intermediate-level interfaces of `hifir4m`, please see `gmresHif.m` for the calling sequence of `hifCreate`, `hifApply`, and `hifDestroy`.
@@ -29,6 +45,7 @@ To access the intermediate-level interfaces of `hifir4m`, please see `gmresHif.m
2945
The software suite is released under a dual-license model. For academic users, individual users, or open-source software developers, you can use HIFIR under the GPLv3+ license free of charge for research and evaluation purpose. For commercial users, separate commercial licenses are available through the Stony Brook University. For inqueries regarding commercial licenses, please contact Prof. Xiangmin Jiao <[email protected]>.
3046

3147
## How to Cite `HIFIR` ##
48+
3249
If you use `HIFIR`, `hifir4m`, or `hifir4py` in your research for nonsingular systems, please cite the `HILUCSI` paper:
3350

3451
```bibtex
@@ -38,7 +55,6 @@ If you use `HIFIR`, `hifir4m`, or `hifir4py` in your research for nonsingular s
3855
large-scale saddle-point problems from {PDE}s},
3956
journal = {Numer. Linear Algebra Appl.},
4057
year = {2021},
41-
note = {To appear},
4258
doi = {10.1002/nla.2400},
4359
```
4460

@@ -47,20 +63,20 @@ If you use them to solve highly ill-conditioned of singular systems, please cite
4763
```bibtex
4864
@Article{jiao2020approximate,
4965
author = {Xiangmin Jiao and Qiao Chen},
50-
journal = {arxiv},
66+
journal = {SIAM J. Matrix Anal. Appl.},
5167
title = {Approximate Generalized Inverses with Iterative Refinement for
5268
$\epsilon$-Accurate Preconditioning of Singular Systems},
53-
year = {2020},
54-
note = {arXiv:2009.01673},
69+
year = {2021},
70+
note = {To appear},
5571
}
5672
5773
@Article{chen2021hifir,
58-
author = {Jiao, Xiangmin and Chen, Qiao},
74+
author = {Chen, Qiao and Jiao, Xiangmin},
5975
title = {{HIFIR}: Hybrid Incomplete Factorization with Iterative Refinement
6076
for Preconditioning Ill-conditioned and Singular Systems},
6177
journal = {arxiv},
6278
year = {2021},
63-
note = {arXiv:21...},
79+
note = {arXiv:2106.09877},
6480
}
6581
```
6682

VERSION

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
0.1.0

api/HifEnum.m

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,8 @@
88
DESTROY = int32(4);
99
FACTORIZE = int32(5);
1010
M_SOLVE = int32(6);
11-
KSP_SOLVE = int32(7);
12-
KSP_NULL = int32(8);
13-
EXPORT_DATA = int32(9);
14-
M_SOLVE2 = int32(10);
15-
M_MULTIPLY = int32(11);
16-
QUERY = int32(12);
11+
M_MULTIPLY = int32(7);
12+
EXPORT_DATA = int32(8);
13+
QUERY = int32(9);
1714
end
1815
end

api/HifParams.m

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
% verbose: 0
2222
% rf_par: 1
2323
% reorder: 1
24-
% saddle: 1
24+
% spd: 0
2525
% check: 1
2626
% pre_scale: 0
2727
% symm_pre_lvls: 1
@@ -54,33 +54,35 @@
5454
'verbose', 0, ...
5555
'rf_par', 1, ...
5656
'reorder', 1, ...
57-
'saddle', 1, ...
57+
'spd', 0, ...
5858
'check', 1, ...
5959
'pre_scale', 0, ...
6060
'symm_pre_lvls', 1, ...
6161
'threads', 0, ...
6262
'mumps_blr', 1, ...
6363
'fat_schur_1st', 0, ...
6464
'rrqr_cond', 0, ...
65-
'pivot', 0, ...
65+
'pivot', 2, ...
6666
'gamma', 1, ...
6767
'beta', 1e3, ...
6868
'is_symm', 0, ...
6969
'no_pre', 0, ...
70+
'nzp_thres', 0.65, ...
71+
'dense_thres', 2000, ...
7072
'is_mixed', 0, ...
7173
'is_complex', 0);
7274
fields = fieldnames(defaults);
7375
end
7476

7577
p = inputParser;
7678
positive_params = {'tau_L', 'tau_U', 'kappa_d', 'kappa', 'alpha_L', ...
77-
'alpha_U', 'rho', 'c_d', 'c_h'};
79+
'alpha_U', 'rho', 'c_d', 'c_h', 'nzp_thres', 'dense_thres'};
7880
for i = 1:numel(positive_params)
7981
addParameter(p, positive_params{i}, defaults.(positive_params{i}), ...
8082
@(x) isscalar(x) && x > 0);
8183
end
8284

83-
nonnegative_params = {'verbose', 'rf_par', 'reorder', 'saddle', 'check', ...
85+
nonnegative_params = {'verbose', 'rf_par', 'reorder', 'spd', 'check', ...
8486
'pre_scale', 'symm_pre_lvls', 'threads', 'mumps_blr', 'fat_schur_1st', ...
8587
'pivot', 'gamma', 'beta', 'is_symm', 'no_pre', 'is_mixed', 'is_complex'};
8688
for i = 1:numel(nonnegative_params)
@@ -91,6 +93,7 @@
9193
addParameter(p, 'N', defaults.N, @isscalar);
9294
addParameter(p, 'rrqr_cond', defaults.rrqr_cond, @isscalar);
9395

96+
p.KeepUnmatched = true; % This seems needed for Octave
9497
parse(p, varargin{:});
9598
sorted_opts = p.Results;
9699

api/Hifir.m

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,16 @@
3434
[varargout{1:nargout}] = hifApply(h, x, varargin{:});
3535
end
3636

37+
function update(h, A)
38+
% Update coefficient matrix used in iterative refinement
39+
h = hifUpdate(h, A);
40+
end
41+
42+
function varargout = refactorize(h, S, varargin)
43+
% Refactorization
44+
[varargout{1:nargout}] = hifRefactorize(h, S, varargin{:});
45+
end
46+
3747
function delete(h)
3848
% Destructor for handle
3949
if ~isempty(h.hdl)

api/hifApply.m

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
function [y, varargout] = hifApply(hif, x, op, rank, nirs)
1+
function varargout = hifApply(hif, x, op, rank, nirs)
22
% hifApply Applies a HIFIR preconditioner to solve or multiply.
33
%
44
% y = hifApply(hif, x [op, rank, nirs])
@@ -25,19 +25,20 @@
2525
assert(nargin <= 5, 'Solve accepts up to five arguments.');
2626
if nargin == 5 && nirs > 1
2727
% with iterative refinement
28-
[y, varargout{:}] = hifir4m_mex(HifEnum.M_SOLVE, hif.hdl, ...
29-
A.row_ptr, A.col_ind, A.val, x, nirs, ...
28+
assert(~isempty(hif.A), 'hif.A must not be empty.');
29+
[varargout{1:nargout}] = hifir4m_mex(HifEnum.M_SOLVE, hif.hdl, ...
30+
x, hif.A.row_ptr, hif.A.col_ind, hif.A.val, nirs, ...
3031
op(end) == 'H' || op(end) == 'T' || op(end) == 'h' || op(end) == 't', rank);
3132
else
32-
[y, varargout{1:nargout}] = hifir4m_mex(HifEnum.M_SOLVE, hif.hdl, x, ...
33+
[varargout{1:nargout}] = hifir4m_mex(HifEnum.M_SOLVE, hif.hdl, x, ...
3334
op(end) == 'H' || op(end) == 'T' || op(end) == 'h' || op(end) == 't', rank);
3435
end
3536
else
3637
assert(op(1) == 'M' || op(1) == 'm', ...
3738
'First character must be ''s'' or ''m''');
3839
assert(nargin <= 4, 'Multiply accepts up to four arguments.');
3940

40-
[y, varargout{1:nargout}] = hifir4m_mex(HifEnum.M_MULTIPLY, hif.hdl, x, ...
41+
[varargout{1:nargout}] = hifir4m_mex(HifEnum.M_MULTIPLY, hif.hdl, x, ...
4142
op(end) == 'H' || op(end) == 'T' || op(end) == 'h' || op(end) == 't', rank);
4243
end
4344

api/hifCreate.m

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -37,36 +37,37 @@
3737
if issparse(A)
3838
Astruct = hifir4m_sp2crs(A);
3939
else
40+
Astruct = A;
4041
if hifir4m_isint64
4142
if ~isa(A.row_ptr, 'int64')
4243
Astruct.row_ptr = int64(A.row_ptr);
4344
Astruct.col_ind = int64(A.col_ind);
4445
end
45-
elseif ~isint64
46+
else
4647
if ~isa(A.row_ptr, 'int32')
4748
Astruct.row_ptr = int32(A.row_ptr);
4849
Astruct.col_ind = int32(A.col_ind);
4950
end
5051
end
51-
Astruct.val = double(A.val);
5252
end
53-
Astruct.nrows = int32(numel(Astruct.row_ptr)-1);
5453

5554
if nargin <= 1 || isempty(S)
5655
Sstruct = Astruct;
56+
elseif issparse(S)
57+
Sstruct = hifir4m_sp2crs(S);
5758
else
58-
if hifir4m_isint64
59-
if ~isa(S.row_ptr, 'int64')
60-
Sstruct.row_ptr = int64(S.row_ptr);
61-
Sstruct.col_ind = int64(S.col_ind);
62-
end
63-
elseif ~isint64
64-
if ~isa(S.row_ptr, 'int32')
65-
Sstruct.row_ptr = int32(S.row_ptr);
66-
Sstruct.col_ind = int32(S.col_ind);
67-
end
59+
Sstruct = S;
60+
end
61+
if hifir4m_isint64
62+
if ~isa(Sstruct.row_ptr, 'int64')
63+
Sstruct.row_ptr = int64(Sstruct.row_ptr);
64+
Sstruct.col_ind = int64(Sstruct.col_ind);
65+
end
66+
else
67+
if ~isa(Sstruct.row_ptr, 'int32')
68+
Sstruct.row_ptr = int32(Sstruct.row_ptr);
69+
Sstruct.col_ind = int32(Sstruct.col_ind);
6870
end
69-
Sstruct.val = double(S.val);
7071
end
7172

7273
[varargout{1:nargout-1}] = hifir4m_mex(HifEnum.FACTORIZE, hif, ...

0 commit comments

Comments
 (0)