-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This PR adds file config example which configures solvers entirely from the config. Moreover, the configs are mapped to the existing examples. Related PR: #1662
- Loading branch information
Showing
49 changed files
with
588 additions
and
32 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
cmake_minimum_required(VERSION 3.16) | ||
project(file-config-solver) | ||
|
||
# We only need to find Ginkgo/nlohmann_json if we build this example stand-alone | ||
if (NOT GINKGO_BUILD_EXAMPLES) | ||
find_package(Ginkgo 1.9.0 REQUIRED) | ||
find_package(nlohmann_json 3.9.1 REQUIRED) | ||
endif() | ||
|
||
add_executable(file-config-solver file-config-solver.cpp) | ||
target_link_libraries(file-config-solver Ginkgo::ginkgo nlohmann_json::nlohmann_json) | ||
|
||
# Copy the data files to the execution directory | ||
configure_file(data/A.mtx data/A.mtx COPYONLY) | ||
# Copy the config files to the execution directory | ||
file(GLOB config_list RELATIVE "${CMAKE_CURRENT_SOURCE_DIR}" config/*.json) | ||
foreach(config IN LISTS config_list) | ||
configure_file("${config}" "${config}" COPYONLY) | ||
endforeach() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#!/bin/bash | ||
|
||
# set up script | ||
if [ $# -ne 1 ]; then | ||
echo -e "Usage: $0 GINKGO_BUILD_DIRECTORY" | ||
exit 1 | ||
fi | ||
BUILD_DIR=$1 | ||
THIS_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" &>/dev/null && pwd ) | ||
|
||
source ${THIS_DIR}/../build-setup.sh | ||
|
||
# build | ||
${CXX} -std=c++17 -o ${THIS_DIR}/file-config-solver ${THIS_DIR}/file-config-solver.cpp \ | ||
-I${THIS_DIR}/../../include -I${BUILD_DIR}/include \ | ||
-L${THIS_DIR} ${LINK_FLAGS} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"type": "solver::Cg", | ||
"preconditioner": { | ||
"type": "preconditioner::Jacobi", | ||
"max_block_size": 8 | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 20 | ||
}, | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-7 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"type": "solver::Cg", | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 20 | ||
}, | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-7 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
{ | ||
"type": "solver::Ir", | ||
"solver": { | ||
"type": "solver::Cg", | ||
"criteria": [ | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-2 | ||
} | ||
] | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 10000 | ||
}, | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-12 | ||
} | ||
] | ||
} |
84 changes: 84 additions & 0 deletions
84
examples/file-config-solver/config/mixed-pgm-multigrid-cg.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,84 @@ | ||
{ | ||
"type": "solver::Cg", | ||
"preconditioner": { | ||
"type": "solver::Multigrid", | ||
"max_levels": 10, | ||
"min_coarse_rows": 2, | ||
"pre_smoother": [ | ||
{ | ||
"type": "solver::Ir", | ||
"relaxation_factor": 0.9, | ||
"solver": { | ||
"type": "preconditioner::Jacobi", | ||
"max_block_size": 1 | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 1 | ||
} | ||
] | ||
}, | ||
{ | ||
"type": "solver::Ir", | ||
"value_type": "float32", | ||
"relaxation_factor": 0.9, | ||
"solver": { | ||
"type": "preconditioner::Jacobi", | ||
"max_block_size": 1 | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 1 | ||
} | ||
] | ||
} | ||
], | ||
"post_uses_pre": true, | ||
"mg_level": [ | ||
{ | ||
"type": "multigrid::Pgm", | ||
"deterministic": true | ||
}, | ||
{ | ||
"type": "multigrid::Pgm", | ||
"value_type": "float32", | ||
"deterministic": true | ||
} | ||
], | ||
"coarsest_solver": { | ||
"type": "solver::Ir", | ||
"value_type": "float32", | ||
"relaxation_factor": 0.9, | ||
"solver": { | ||
"type": "preconditioner::Jacobi", | ||
"max_block_size": 1 | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 4 | ||
} | ||
] | ||
}, | ||
"default_initial_guess": "zero", | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 1 | ||
} | ||
] | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 100 | ||
}, | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-8, | ||
"baseline": "absolute" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
{ | ||
"type": "solver::Gmres", | ||
"preconditioner": { | ||
"type": "preconditioner::Ilu", | ||
"l_solver_type": "solver::LowerTrs", | ||
"reverse_apply": false, | ||
"factorization": { | ||
"type": "factorization::ParIlu" | ||
} | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 1000 | ||
}, | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-7 | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
{ | ||
"type": "solver::Cg", | ||
"preconditioner": { | ||
"type": "solver::Multigrid", | ||
"min_coarse_rows": 2, | ||
"mg_level": [ | ||
{ | ||
"type": "multigrid::Pgm", | ||
"deterministic": true | ||
} | ||
], | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 1 | ||
} | ||
] | ||
}, | ||
"criteria": [ | ||
{ | ||
"type": "Iteration", | ||
"max_iters": 100 | ||
}, | ||
{ | ||
"type": "ResidualNorm", | ||
"reduction_factor": 1e-8, | ||
"baseline": "absolute" | ||
} | ||
] | ||
} |
Oops, something went wrong.