Skip to content

Commit

Permalink
Allow to reduce compilation overhead by disabling unused components i…
Browse files Browse the repository at this point in the history
…n runtime interface
  • Loading branch information
ddemidov committed May 3, 2017
1 parent 0ae2165 commit e3b8e8c
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .appveyor.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
10 changes: 10 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
16 changes: 13 additions & 3 deletions amgcl/relaxation/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -157,15 +157,19 @@ void process_rap(runtime::relaxation::type relaxation, const Func &func) {
case runtime::relaxation::gauss_seidel:
process_rap<Backend, amgcl::relaxation::gauss_seidel>(func);
break;
#ifndef AMGCL_RUNTIME_DISABLE_MULTICOLOR_GS
case runtime::relaxation::multicolor_gauss_seidel:
process_rap<Backend, amgcl::relaxation::multicolor_gauss_seidel>(func);
break;
#endif
case runtime::relaxation::ilu0:
process_rap<Backend, amgcl::relaxation::ilu0>(func);
break;
#ifndef AMGCL_RUNTIME_DISABLE_PARALLEL_ILU0
case runtime::relaxation::parallel_ilu0:
process_rap<Backend, amgcl::relaxation::parallel_ilu0>(func);
break;
#endif
case runtime::relaxation::iluk:
process_rap<Backend, amgcl::relaxation::iluk>(func);
break;
Expand All @@ -178,12 +182,18 @@ void process_rap(runtime::relaxation::type relaxation, const Func &func) {
case runtime::relaxation::spai0:
process_rap<Backend, amgcl::relaxation::spai0>(func);
break;
#ifndef AMGCL_RUNTIME_DISABLE_SPAI1
case runtime::relaxation::spai1:
process_rap<Backend, amgcl::relaxation::spai1>(func);
break;
#endif
#ifndef AMGCL_RUNTIME_DISABLE_CHEBYSHEV
case runtime::relaxation::chebyshev:
process_rap<Backend, amgcl::relaxation::chebyshev>(func);
break;
#endif
default:
precondition(false, "Unsupported relaxation value");
}
}

Expand Down
10 changes: 10 additions & 0 deletions amgcl/runtime.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -179,27 +179,31 @@ process_amg(
amgcl::relaxation::gauss_seidel
>(func);
break;
#ifndef AMGCL_RUNTIME_DISABLE_MULTICOLOR_GS
case runtime::relaxation::multicolor_gauss_seidel:
process_amg<
Backend,
Coarsening,
amgcl::relaxation::multicolor_gauss_seidel
>(func);
break;
#endif
case runtime::relaxation::ilu0:
process_amg<
Backend,
Coarsening,
amgcl::relaxation::ilu0
>(func);
break;
#ifndef AMGCL_RUNTIME_DISABLE_PARALLEL_ILU0
case runtime::relaxation::parallel_ilu0:
process_amg<
Backend,
Coarsening,
amgcl::relaxation::parallel_ilu0
>(func);
break;
#endif
case runtime::relaxation::iluk:
process_amg<
Backend,
Expand Down Expand Up @@ -228,20 +232,26 @@ process_amg(
amgcl::relaxation::spai0
>(func);
break;
#ifndef AMGCL_RUNTIME_DISABLE_SPAI1
case runtime::relaxation::spai1:
process_amg<
Backend,
Coarsening,
amgcl::relaxation::spai1
>(func);
break;
#endif
#ifndef AMGCL_RUNTIME_DISABLE_CHEBYSHEV
case runtime::relaxation::chebyshev:
process_amg<
Backend,
Coarsening,
amgcl::relaxation::chebyshev
>(func);
break;
#endif
default:
precondition(false, "Unsupported relaxation value");
}
}

Expand Down
28 changes: 18 additions & 10 deletions tests/test_solver.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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[] = {
Expand Down

0 comments on commit e3b8e8c

Please sign in to comment.