Skip to content
Snippets Groups Projects
Commit 53ee4035 authored by Jö Fahlke's avatar Jö Fahlke
Browse files

[cmake][Vc] Use the HAVE/ENABLE trick for Vc.

This solves a problem that is introduced by unconditionally setting
`HAVE_VC=1` in config.h:

If a compilation unit is compiled without the `-fabi-version=6` or similar
then the compilers vector types (which are used by Vc under the hood if
available) will mangle to the same string, irrespective of the number of lanes
they actually use.  This makes certain overloaded function definitions in the
Vc headers clash, since their only difference is whether they apply to
e.g. AVX types (4 lanes) or SSE types (2 lanes).

This is normally not a problem, since any program that uses Vc needs to have a
call to `add_dune_vc_flags()` in `CMakeLists.txt`.  However, since I now want
to put support for vectorized types into the `fmatrix.hh`, any compilation
unit that uses a `FieldMatrix` will automatically include the Vc headers
because `config.h` unconditionally sets `HAVE_VC=1`.

Using the HAVE/ENABLE-trick makes sure that the value of `HAVE_VC` is in sync
with the compilation flags.

Note: I tried using `COMPILE_DEFINITION` for `ENABLE_VC=1` in
      `dune_register_package_flags()`, but that will always add
      `-DENABLE_VC=1` to the compiler command line, even when
      `add_dune_vc_flags()` hasn't been called for that target, and
      `dune_enable_all_packages()` isn't in use.  Using `COMPILE_OPTIONS`
      instead seems inappropriate, but does work.
parent 3e34c7f0
No related branches found
No related tags found
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment