From e3b8e8cc8b1bc7704a063b625d80b9f265719220 Mon Sep 17 00:00:00 2001 From: Denis Demidov Date: Wed, 3 May 2017 22:13:08 +0300 Subject: [PATCH] Allow to reduce compilation overhead by disabling unused components in runtime interface --- .appveyor.yml | 2 +- CMakeLists.txt | 10 ++++++++++ amgcl/relaxation/runtime.hpp | 16 +++++++++++++--- amgcl/runtime.hpp | 10 ++++++++++ tests/test_solver.hpp | 28 ++++++++++++++++++---------- 5 files changed, 52 insertions(+), 14 deletions(-) diff --git a/.appveyor.yml b/.appveyor.yml index b68f19cf..c14d8ffe 100644 --- a/.appveyor.yml +++ b/.appveyor.yml @@ -10,7 +10,7 @@ configuration: - Release build_script: - git submodule update --init --recursive - - cmake -DAMGCL_BUILD_TESTS=ON -DAMGCL_BUILD_EXAMPLES=ON . -Bbuild + - cmake -DAMGCL_BUILD_TESTS=ON -DAMGCL_BUILD_EXAMPLES=ON -DAMGCL_DISABLE_RARE_COMPONENTS=ON . -Bbuild - cmake --build build --config Release test_script: - cd build diff --git a/CMakeLists.txt b/CMakeLists.txt index c31f6ee0..831273b2 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -237,6 +237,16 @@ endif() if (AMGCL_MASTER_PROJECT) option(AMGCL_BUILD_TESTS OFF) option(AMGCL_BUILD_EXAMPLES OFF) + option(AMGCL_DISABLE_RARE_COMPONENTS OFF) + + if(AMGCL_DISABLE_RARE_COMPONENTS) + add_definitions( + -DAMGCL_RUNTIME_DISABLE_MULTICOLOR_GS + -DAMGCL_RUNTIME_DISABLE_PARALLEL_ILU0 + -DAMGCL_RUNTIME_DISABLE_SPAI1 + -DAMGCL_RUNTIME_DISABLE_CHEBYSHEV + ) + endif() add_subdirectory(docs) diff --git a/amgcl/relaxation/runtime.hpp b/amgcl/relaxation/runtime.hpp index 85059313..12441eb7 100644 --- a/amgcl/relaxation/runtime.hpp +++ b/amgcl/relaxation/runtime.hpp @@ -94,10 +94,10 @@ inline std::istream& operator>>(std::istream &in, type &r) std::string val; in >> val; - if (val == "multicolor_gauss_seidel") - r = multicolor_gauss_seidel; - else if (val == "gauss_seidel") + if (val == "gauss_seidel") r = gauss_seidel; + else if (val == "multicolor_gauss_seidel") + r = multicolor_gauss_seidel; else if (val == "ilu0") r = ilu0; else if (val == "parallel_ilu0") @@ -157,15 +157,19 @@ void process_rap(runtime::relaxation::type relaxation, const Func &func) { case runtime::relaxation::gauss_seidel: process_rap(func); break; +#ifndef AMGCL_RUNTIME_DISABLE_MULTICOLOR_GS case runtime::relaxation::multicolor_gauss_seidel: process_rap(func); break; +#endif case runtime::relaxation::ilu0: process_rap(func); break; +#ifndef AMGCL_RUNTIME_DISABLE_PARALLEL_ILU0 case runtime::relaxation::parallel_ilu0: process_rap(func); break; +#endif case runtime::relaxation::iluk: process_rap(func); break; @@ -178,12 +182,18 @@ void process_rap(runtime::relaxation::type relaxation, const Func &func) { case runtime::relaxation::spai0: process_rap(func); break; +#ifndef AMGCL_RUNTIME_DISABLE_SPAI1 case runtime::relaxation::spai1: process_rap(func); break; +#endif +#ifndef AMGCL_RUNTIME_DISABLE_CHEBYSHEV case runtime::relaxation::chebyshev: process_rap(func); break; +#endif + default: + precondition(false, "Unsupported relaxation value"); } } diff --git a/amgcl/runtime.hpp b/amgcl/runtime.hpp index 26b0b16c..94114313 100644 --- a/amgcl/runtime.hpp +++ b/amgcl/runtime.hpp @@ -179,6 +179,7 @@ process_amg( amgcl::relaxation::gauss_seidel >(func); break; +#ifndef AMGCL_RUNTIME_DISABLE_MULTICOLOR_GS case runtime::relaxation::multicolor_gauss_seidel: process_amg< Backend, @@ -186,6 +187,7 @@ process_amg( amgcl::relaxation::multicolor_gauss_seidel >(func); break; +#endif case runtime::relaxation::ilu0: process_amg< Backend, @@ -193,6 +195,7 @@ process_amg( amgcl::relaxation::ilu0 >(func); break; +#ifndef AMGCL_RUNTIME_DISABLE_PARALLEL_ILU0 case runtime::relaxation::parallel_ilu0: process_amg< Backend, @@ -200,6 +203,7 @@ process_amg( amgcl::relaxation::parallel_ilu0 >(func); break; +#endif case runtime::relaxation::iluk: process_amg< Backend, @@ -228,6 +232,7 @@ process_amg( amgcl::relaxation::spai0 >(func); break; +#ifndef AMGCL_RUNTIME_DISABLE_SPAI1 case runtime::relaxation::spai1: process_amg< Backend, @@ -235,6 +240,8 @@ process_amg( amgcl::relaxation::spai1 >(func); break; +#endif +#ifndef AMGCL_RUNTIME_DISABLE_CHEBYSHEV case runtime::relaxation::chebyshev: process_amg< Backend, @@ -242,6 +249,9 @@ process_amg( amgcl::relaxation::chebyshev >(func); break; +#endif + default: + precondition(false, "Unsupported relaxation value"); } } diff --git a/tests/test_solver.hpp b/tests/test_solver.hpp index d3b9b4d6..fbed3f03 100644 --- a/tests/test_solver.hpp +++ b/tests/test_solver.hpp @@ -105,16 +105,24 @@ void test_problem( }; amgcl::runtime::relaxation::type relaxation[] = { - amgcl::runtime::relaxation::spai0, - amgcl::runtime::relaxation::spai1, - amgcl::runtime::relaxation::damped_jacobi, - amgcl::runtime::relaxation::gauss_seidel, - amgcl::runtime::relaxation::multicolor_gauss_seidel, - amgcl::runtime::relaxation::ilu0, - amgcl::runtime::relaxation::parallel_ilu0, - amgcl::runtime::relaxation::iluk, - amgcl::runtime::relaxation::ilut, - amgcl::runtime::relaxation::chebyshev + amgcl::runtime::relaxation::spai0 +#ifndef AMGCL_RUNTIME_DISABLE_SPAI1 + , amgcl::runtime::relaxation::spai1 +#endif + , amgcl::runtime::relaxation::damped_jacobi + , amgcl::runtime::relaxation::gauss_seidel +#ifndef AMGCL_RUNTIME_DISABLE_MULTICOLOR_GS + , amgcl::runtime::relaxation::multicolor_gauss_seidel +#endif + , amgcl::runtime::relaxation::ilu0 +#ifndef AMGCL_RUNTIME_DISABLE_PARALLEL_ILU0 + , amgcl::runtime::relaxation::parallel_ilu0 +#endif + , amgcl::runtime::relaxation::iluk + , amgcl::runtime::relaxation::ilut +#ifndef AMGCL_RUNTIME_DISABLE_CHEBYSHEV + , amgcl::runtime::relaxation::chebyshev +#endif }; amgcl::runtime::solver::type solver[] = {