Skip to content

Commit c178258

Browse files
author
Thomas Grützmacher
authored
Merge addition of CB-GMRES
This PR adds the Compressed Basis GMRES (CB-GMRES), which uses classical Gram-Schmidt GMRES with reorthogonalization where the basis can be stored in lower precision. The precision of the basis is decided by the user with a factory parameter. Related PR: #693
2 parents 555b8b2 + 4d722f1 commit c178258

58 files changed

Lines changed: 6736 additions & 300 deletions

Some content is hidden

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

BENCHMARKING.md

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ The benchmark suite can take a number of configuration parameters. Benchmarks
143143
can be run only for `sparse matrix vector products (spmv)`, for full solvers
144144
(with or without preconditioners), or for preconditioners only when supported.
145145
The benchmark suite also allows to target a sub-part of the SuiteSparse matrix
146-
collection. For details, see the [available benchmark options](### 5: Available
146+
collection. For details, see the [available benchmark options](### 6: Available
147147
benchmark options). Here are the most important options:
148148
* `BENCHMARK={spmv, solver, preconditioner}` - allows to select the type of
149149
benchmark to be ran.
@@ -295,17 +295,28 @@ The supported environment variables are described in the following list:
295295
library formats (cuSPARSE with `cusp_` prefix or hipSPARSE with `hipsp_`
296296
prefix) can be used as well. Multiple options can be passed. The default is
297297
`csr,coo,ell,hybrid,sellp`.
298-
* `SOLVERS={bicgstab,bicg,cg,cgs,fcg,gmres,lower_trs,upper_trs}` - the solvers
299-
which should be benchmarked. Multiple options can be passed. The default
300-
is `cg`. Note that `lower/upper_trs` by default don't use a preconditioner,
301-
as they are by default exact direct solvers.
298+
* `SOLVERS={bicgstab,bicg,cg,cgs,fcg,gmres,cb_gmres_{keep,reduce1,reduce2,integer,ireduce1,ireduce2},lower_trs,upper_trs}`
299+
- the solvers which should be benchmarked. Multiple options can be passed.
300+
The default is `bicgstab,cg,cgs,fcg,gmres,idr`. Note that `lower/upper_trs`
301+
by default don't use a preconditioner, as they are by default exact direct
302+
solvers.
302303
* `SOLVERS_PRECISION=<precision>` - the minimal residual reduction before which
303304
the solver should stop. The default is `1e-6`.
304305
* `SOLVERS_MAX_ITERATION=<number>` - the maximum number of iterations with which
305306
a solver should be ran. The default is `10000`.
306-
* `SOLVERS_RHS={unit, random}` - whether to use a vector of all ones or random
307-
values as the right-hand side in solver benchmarks. Default is `unit`.
307+
* `SOLVERS_RHS={1, random, sinus}` - whether to use a vector of all ones,
308+
random values or b = A * (s / |s|)$ with s(idx) = sin(idx) (for complex
309+
numbers, s(idx) = sin(2*idx) + i * sin(2*idx+1))
310+
as the right-hand side in solver benchmarks. Default is `1`.
311+
* `SOLVERS_INITIAL_GUESS={rhs,0,random}` - the initial guess generation of the
312+
solvers. `rhs` uses the right-hand side, `0` uses a zero vector and `random`
313+
generates a random vector as the initial guess.
308314
* `DETAILED={0,1}` - selects whether detailed benchmarks should be ran for the
309315
solver benchmarks, can be either `0` (off) or `1` (on). The default is `0`.
310316
* `GPU_TIMER={true, false}` - If set to `true`, use the gpu timer, which is
311317
valid for cuda/hip executor, to measure the timing. Default is `false`.
318+
* `SOLVERS_JACOBI_MAX_BS` - sets the maximum block size for the Jacobi
319+
preconditioner (if used, otherwise, it does nothing) in the solvers
320+
benchmark. The default is '32'.
321+
* `SOLVERS_GMRES_RESTART` - the maximum dimension of the Krylov space to use in
322+
GMRES. The default is `100`.

benchmark/run_all_benchmarks.sh

Lines changed: 53 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
# Environment variable detection
33

44
if [ ! "${BENCHMARK}" ]; then
5-
echo "BENCHMARK environment variable not set - assuming \"spmv\"" 1>&2
65
BENCHMARK="spmv"
6+
echo "BENCHMARK environment variable not set - assuming \"${BENCHMARK}\"" 1>&2
77
fi
88

99
if [ ! "${DRY_RUN}" ]; then
10-
echo "DRY_RUN environment variable not set - assuming \"false\"" 1>&2
1110
DRY_RUN="false"
11+
echo "DRY_RUN environment variable not set - assuming \"${DRY_RUN}\"" 1>&2
1212
fi
1313

1414
if [ ! "${EXECUTOR}" ]; then
15-
echo "EXECUTOR environment variable not set - assuming \"cuda\"" 1>&2
1615
EXECUTOR="cuda"
16+
echo "EXECUTOR environment variable not set - assuming \"${EXECUTOR}\"" 1>&2
1717
fi
1818

1919
if [ ! "${SEGMENTS}" ]; then
@@ -26,8 +26,8 @@ elif [ ! "${SEGMENT_ID}" ]; then
2626
fi
2727

2828
if [ ! "${PRECONDS}" ]; then
29-
echo "PRECONDS environment variable not set - assuming \"none\"" 1>&2
3029
PRECONDS="none"
30+
echo "PRECONDS environment variable not set - assuming \"${PRECONDS}\"" 1>&2
3131
fi
3232

3333
if [ ! "${FORMATS}" ]; then
@@ -36,33 +36,38 @@ if [ ! "${FORMATS}" ]; then
3636
fi
3737

3838
if [ ! "${SOLVERS}" ]; then
39-
echo "SOLVERS environment variable not set - assuming \"bicgstab,cg,cgs,fcg,gmres,idr\"" 1>&2
40-
SOLVERS="bicgstab,cg,cgs,fcg,gmres,idr"
39+
SOLVERS="bicgstab,cg,cgs,fcg,gmres,cb_gmres_reduce1,idr"
40+
echo "SOLVERS environment variable not set - assuming \"${SOLVERS}\"" 1>&2
4141
fi
4242

4343
if [ ! "${SOLVERS_PRECISION}" ]; then
44-
echo "SOLVERS_PRECISION environment variable not set - assuming \"1e-6\"" 1>&2
4544
SOLVERS_PRECISION=1e-6
45+
echo "SOLVERS_PRECISION environment variable not set - assuming \"${SOLVERS_PRECISION}\"" 1>&2
4646
fi
4747

4848
if [ ! "${SOLVERS_MAX_ITERATIONS}" ]; then
49-
echo "SOLVERS_MAX_ITERATIONS environment variable not set - assuming \"10000\"" 1>&2
5049
SOLVERS_MAX_ITERATIONS=10000
50+
echo "SOLVERS_MAX_ITERATIONS environment variable not set - assuming \"${SOLVERS_MAX_ITERATIONS}\"" 1>&2
51+
fi
52+
53+
if [ ! "${SOLVERS_GMRES_RESTART}" ]; then
54+
SOLVERS_GMRES_RESTART=100
55+
echo "SOLVERS_GMRES_RESTART environment variable not set - assuming \"${SOLVERS_GMRES_RESTART}\"" 1>&2
5156
fi
5257

5358
if [ ! "${SYSTEM_NAME}" ]; then
54-
echo "SYSTEM_MANE environment variable not set - assuming \"unknown\"" 1>&2
5559
SYSTEM_NAME="unknown"
60+
echo "SYSTEM_MANE environment variable not set - assuming \"${SYSTEM_NAME}\"" 1>&2
5661
fi
5762

5863
if [ ! "${DEVICE_ID}" ]; then
59-
echo "DEVICE_ID environment variable not set - assuming \"0\"" 1>&2
6064
DEVICE_ID="0"
65+
echo "DEVICE_ID environment variable not set - assuming \"${DEVICE_ID}\"" 1>&2
6166
fi
6267

63-
if [ ! "${SOLVERS_RHS}" ]; then
64-
echo "SOLVERS_RHS environment variable not set - assuming \"unit\"" 1>&2
65-
SOLVERS_RHS="unit"
68+
if [ ! "${SOLVERS_JACOBI_MAX_BS}" ]; then
69+
SOLVERS_JACOBI_MAX_BS="32"
70+
"SOLVERS_JACOBI_MAX_BS environment variable not set - assuming \"${SOLVERS_JACOBI_MAX_BS}\"" 1>&2
6671
fi
6772

6873
if [ ! "${BENCHMARK_PRECISION}" ]; then
@@ -84,15 +89,43 @@ else
8489
exit 1
8590
fi
8691

92+
if [ ! "${SOLVERS_RHS}" ]; then
93+
SOLVERS_RHS="1"
94+
echo "SOLVERS_RHS environment variable not set - assuming \"${SOLVERS_RHS}\"" 1>&2
95+
fi
96+
8797
if [ "${SOLVERS_RHS}" == "random" ]; then
88-
SOLVERS_RHS_FLAG="--random_rhs=true"
98+
SOLVERS_RHS_FLAG="--rhs_generation=random"
99+
elif [ "${SOLVERS_RHS}" == "1" ]; then
100+
SOLVERS_RHS_FLAG="--rhs_generation=1"
101+
elif [ "${SOLVERS_RHS}" == "sinus" ]; then
102+
SOLVERS_RHS_FLAG="--rhs_generation=sinus"
89103
else
90-
SOLVERS_RHS_FLAG="--random_rhs=false"
104+
echo "SOLVERS_RHS does not support the value \"${SOLVERS_RHS}\"." 1>&2
105+
echo "The following values are supported: \"1\", \"random\" and \"sinus\"" 1>&2
106+
exit 1
107+
fi
108+
109+
if [ ! "${SOLVERS_INITIAL_GUESS}" ]; then
110+
SOLVERS_INITIAL_GUESS="rhs"
111+
echo "SOLVERS_RHS environment variable not set - assuming \"${SOLVERS_INITIAL_GUESS}\"" 1>&2
112+
fi
113+
114+
if [ "${SOLVERS_INITIAL_GUESS}" == "random" ]; then
115+
SOLVERS_INITIAL_GUESS_FLAG="--initial_guess_generation=random"
116+
elif [ "${SOLVERS_INITIAL_GUESS}" == "0" ]; then
117+
SOLVERS_INITIAL_GUESS_FLAG="--initial_guess_generation=0"
118+
elif [ "${SOLVERS_INITIAL_GUESS}" == "rhs" ]; then
119+
SOLVERS_INITIAL_GUESS_FLAG="--initial_guess_generation=rhs"
120+
else
121+
echo "SOLVERS_RHS does not support the value \"${SOLVERS_RHS}\"." 1>&2
122+
echo "The following values are supported: \"0\", \"random\" and \"rhs\"" 1>&2
123+
exit 1
91124
fi
92125

93126
if [ ! "${GPU_TIMER}" ]; then
94-
echo "GPU_TIMER environment variable not set - assuming \"false\"" 1>&2
95127
GPU_TIMER="false"
128+
echo "GPU_TIMER environment variable not set - assuming \"${GPU_TIMER}\"" 1>&2
96129
fi
97130

98131
# Control whether to run detailed benchmarks or not.
@@ -202,7 +235,10 @@ run_solver_benchmarks() {
202235
--executor="${EXECUTOR}" --solvers="${SOLVERS}" \
203236
--preconditioners="${PRECONDS}" \
204237
--max_iters=${SOLVERS_MAX_ITERATIONS} --rel_res_goal=${SOLVERS_PRECISION} \
205-
${SOLVERS_RHS_FLAG} ${DETAILED_STR} --device_id="${DEVICE_ID}" --gpu_timer=${GPU_TIMER} \
238+
${SOLVERS_RHS_FLAG} ${DETAILED_STR} ${SOLVERS_INITIAL_GUESS_FLAG} \
239+
--gpu_timer=${GPU_TIMER} \
240+
--jacobi_max_block_size=${SOLVERS_JACOBI_MAX_BS} --device_id="${DEVICE_ID}" \
241+
--gmres_restart="${SOLVERS_GMRES_RESTART}" \
206242
<"$1.imd" 2>&1 >"$1"
207243
keep_latest "$1" "$1.bkp" "$1.bkp2" "$1.imd"
208244
}

0 commit comments

Comments
 (0)