Compilation issuesΒΆ
AMGCL is a header-only library, so one does not need to compile it in order to use the library. However, there are some dependencies coming with the library:
- The runtime interface of AMGCL depends on the header-only
Boost.property_tree library that allows the solvers and preconditioners
to accept dynamically formed parameters. When the runtime interface is not
used, it is possible to get rid of the Boost.property_tree dependency by
defining the preprocessor macro
AMGCL_NO_BOOST
. - AMGCL uses OpenMP during the setup of the provided solvers and
preconditioners, and also for the
amgcl::backend::builtin
backend. OpenMP is supported by most, if not all, of the relatively modern C++ compilers, so that should not be a problem. One just has to remember to enable the OpenMP support during the compilation of the project that uses AMGCL. - Each of the AMGCL backends brings its own set of dependencies. For example,
the
amgcl::backend::vexcl
backend depends on the header-only VexCL library, which in turn depends on some Boost libraries and either on CUDA or OpenCL support. Theamgcl::backend::cuda
backend depends on the CUDA support and the CUSPARSE and Thrust libraries.
If your project already uses CMake as the build system, then using AMGCL should be easy. Here is a concise example that shows how to compile a project using AMGCL with the builtin backend:
cmake_minimum_required(VERSION 3.1)
project(example)
find_package(amgcl)
add_executable(example example.cpp)
target_link_libraries(example amgcl::amgcl)
And here is an example of adding the support for the VexCL backend:
cmake_minimum_required(VERSION 3.1)
project(example)
find_package(amgcl)
find_package(VexCL)
add_executable(example example.cpp)
target_link_libraries(example amgcl::amgcl VexCL::OpenCL)
find_package(amgcl)
may be used when the cmake support for AMGCL was
installed either system-wide, or in the current user home directory. If that is
not the case, one can simply copy the amgcl folder into a subdirectory of the
main project and replace the find_package(amgcl)
line with
add_subdirectory(amgcl)
.
Finally, in order to compile the AMGCL tests and examples, the following script may be used:
git clone https://github.com/ddemidov/amgcl
cd ./amgcl
cmake -Bbuild -DAMGCL_BUILD_TESTS=ON -DAMGCL_BUILD_EXAMPLES=ON .
cmake --build build
After this, the compiled tests and examples may be found in the build
folder.