Template Numerical Library
version develop:9e8685af4
|
TNL is a collection of building blocks that facilitate the development of efficient numerical solvers. It is implemented in C++ using modern programming paradigms in order to provide flexible and user friendly interface. TNL provides native support for modern hardware architectures such as multicore CPUs, GPUs, and distributed systems, which can be managed via a unified interface.
Similarly to the STL, features provided by the TNL can be grouped into several modules:
TODO: Each topic in this list should have a separate page or tutorial.
See also Comparison with other libraries.
TNL also provides several optional components:
These components can be individually enabled or disabled and installed by a convenient install
script. See the Installation section for details.
You can either download the stable version or directly clone the git repository via HTTPS:
git clone https://mmg-gitlab.fjfi.cvut.cz/gitlab/tnl/tnl-dev.git
or via SSH:
git clone gitlab@mmg-gitlab.fjfi.cvut.cz:tnl/tnl-dev.git
Since TNL is a header-only library, no installation is necessary to actually use the library in your project. See the Usage section for details.
You may also want to install some optional dependencies and/or compile and install various tools and examples. See the following section for details.
In order to use TNL, you need to install a compatible compiler, a parallel computing platform, and (optionally) some libraries.
Libraries: Various libraries are needed to enable optional features or enhance the functionality of some TNL components. Make sure that all relevant packages are installed and use the appropriate flags when compiling your project.
Library | Affected components | Compiler flags | Notes |
---|---|---|---|
zlib | XML-based mesh readers and writers | -DHAVE_ZLIB -lz | |
TinyXML2 | XML-based mesh readers | -DHAVE_TINYXML2 -ltinyxml2 | If TinyXML2 is not found as a system library, the install script will download, compile and install TinyXML2 along with TNL. |
Metis | tnl-decompose-mesh | Only used for the compilation of the tnl-decompose-mesh tool. | |
libpng | Image processing classes | -DHAVE_PNG_H -lpng | |
libjpeg | Image processing classes | -DHAVE_JPEG_H -ljpeg | |
DCMTK | Image processing classes | -DHAVE_DCMTK_H -ldcm... |
TNL provides several optional components such as pre-processing and post-processing tools which can be compiled and installed by executing the install
script:
./install
CMake 3.13 or later is required for the compilation.
The script compiles and/or installs all optional components into the ~/.local/
directory, and compiles and executes all unit tests from the src/UnitTests directory.
Individual components can be disabled and the installation prefix can be changed by passing command-line arguments to the install script. Run ./install --help
for details.
TNL can be used with various build systems if you configure the compiler flags as explained below. See also an example project providing a simple Makefile
.
-std=c++14
-I /path/to/include
<prefix>/include
, where <prefix>
is the installation path (it is ~/.local
by default).<git_repo>/src
and <git_repo/src/3rdparty
, where <git_repo>
is the path where you have cloned the TNL git repository.-I
flag, you can set the CPATH
environment variable to a colon-delimited list of include paths. Note that this may affect the build systems of other projects as well. For example: export CPATH="$HOME/.local/include:$CPATH"
-O3 -DNDEBUG
(you can also add -march=native -mtune=native
to enable CPU-specific optimizations).To enable parallel computing platforms in TNL, additional compiler flags are needed. They can be enabled by defining a corresponding C preprocessor macro which has the form HAVE_<PLATFORM>
, i.e.:
-D HAVE_OPENMP
enables OpenMP (also -fopenmp
is usually needed to enable OpenMP support in the compiler)-D HAVE_CUDA
enables CUDA (the compiler must actually support CUDA, use e.g. nvcc
or clang++
)nvcc
, the following experimental flags are also required: --expt-relaxed-constexpr --expt-extended-lambda
-D HAVE_MPI
enables MPI (use a compiler wrapper such as mpicxx
or link manually against the MPI libraries)If you installed some TNL tools or examples using the install
script, we recommend you to configure several environment variables for convenience. If you used the default installation path ~/.local/
:
export PATH=$PATH:$HOME/.local/bin
install
script and not as a system package, also export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$HOME/.local/lib
These commands can be added to the initialization scripts of your favourite shell, e.g. .bash_profile
.