Skip to content
Snippets Groups Projects
Commit 2ccff869 authored by Dominic Kempf's avatar Dominic Kempf
Browse files

[!321] Add a bit more traits concept around the vector class library

Merge branch 'feature/vcl-traits-stuff' into 'master'

ref:extensions/dune-codegen The VCL does not export enough information about
its types to reason about them, when they are used as template parameters. In
the long run, a proper solution will be needed I guess\...

See merge request [extensions/dune-codegen!321]

  [extensions/dune-codegen!321]: gitlab.dune-project.org/extensions/dune-codegen/merge_requests/321
parents 94d31143 9757ba41
No related branches found
No related tags found
No related merge requests found
#ifndef DUNE_CODEGEN_COMMON_SIMD_TRAITS_HH
#define DUNE_CODEGEN_COMMON_SIMD_TRAITS_HH
/** This is just the declaration of the traits classes, specialization for VCL and
* OpCounter VCL are elsewhere.
*/
template<typename T>
struct base_floatingpoint
{};
template<typename T>
struct simd_size
{};
#endif
#ifndef DUNE_CODEGEN_COMMON_VCLTRAITS_HH
#define DUNE_CODEGEN_COMMON_VCLTRAITS_HH
/** A collection of traits tools for the Vector Class Library */
#include<dune/codegen/common/vectorclass.hh>
template<>
struct base_floatingpoint<Vec2d>
{
using value = double;
};
template<>
struct base_floatingpoint<Vec4f>
{
using value = float;
};
template<>
struct simd_size<Vec2d>
{
static constexpr std::size_t value = 2;
};
template<>
struct simd_size<Vec4f>
{
static constexpr std::size_t value = 4;
};
#if MAX_VECTOR_SIZE >= 256
template<>
struct base_floatingpoint<Vec4d>
{
using value = double;
};
template<>
struct base_floatingpoint<Vec8f>
{
using value = float;
};
template<>
struct simd_size<Vec4d>
{
static constexpr std::size_t value = 4;
};
template<>
struct simd_size<Vec8f>
{
static constexpr std::size_t value = 8;
};
#endif
#if MAX_VECTOR_SIZE >= 512
template<>
struct base_floatingpoint<Vec8d>
{
using value = double;
};
template<>
struct base_floatingpoint<Vec16f>
{
using value = float;
};
template<>
struct simd_size<Vec8d>
{
static constexpr std::size_t value = 8;
};
template<>
struct simd_size<Vec16f>
{
static constexpr std::size_t value = 16;
};
#endif
#endif
#ifndef DUNE_CODEGEN_COMMON_VECTORCLASS_HH
#define DUNE_CODEGEN_COMMON_VECTORCLASS_HH
template<typename T>
struct base_floatingpoint
{};
#include<dune/codegen/common/simdtraits.hh>
#ifdef ENABLE_COUNTER
#if HAVE_DUNE_OPCOUNTER
#include<dune/opcounter/vectorclass.hh>
template<typename F, int size>
struct base_floatingpoint<OpCounter::impl::OpCounterVector<F, size>>
{
using value = OpCounter::OpCounter<F>;
};
#else
#error "dune-opcounter is needed for opcounted vector types"
#endif
#else
#include<dune/codegen/vectorclass/vectorclass.h>
#include<dune/codegen/vectorclass/vectormath_exp.h>
#include<dune/codegen/vectorclass/vectormath_hyp.h>
#include<dune/codegen/vectorclass/vectormath_trig.h>
template<>
struct base_floatingpoint<Vec2d>
{
using value = double;
};
template<>
struct base_floatingpoint<Vec4f>
{
using value = float;
};
#if MAX_VECTOR_SIZE >= 256
template<>
struct base_floatingpoint<Vec4d>
{
using value = double;
};
template<>
struct base_floatingpoint<Vec8f>
{
using value = float;
};
#endif
#if MAX_VECTOR_SIZE >= 512
template<>
struct base_floatingpoint<Vec8d>
{
using value = double;
};
template<>
struct base_floatingpoint<Vec16f>
{
using value = float;
};
#endif
#include<dune/codegen/common/vcltraits.hh>
#endif
......
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