vir-simd 0.4.189
Parallelism TS 2 extensions and simd fallback implementation
Loading...
Searching...
No Matches
simd_concepts.h
Go to the documentation of this file.
1/* SPDX-License-Identifier: LGPL-3.0-or-later */
2/* Copyright © 2023–2024 GSI Helmholtzzentrum fuer Schwerionenforschung GmbH
3 * Matthias Kretz <m.kretz@gsi.de>
4 */
5
6#ifndef VIR_SIMD_CONCEPTS_H_
7#define VIR_SIMD_CONCEPTS_H_
8
12
13#if defined DOXYGEN \
14 || (defined __cpp_concepts && __cpp_concepts >= 201907 && __has_include(<concepts>) \
15 && (__GNUC__ > 10 || defined __clang__))
16#define VIR_HAVE_SIMD_CONCEPTS 1
17#include <concepts>
18
19#include "simd.h"
20
21namespace vir
22{
23 using std::size_t;
24
26 template <typename T>
27 concept arithmetic = std::floating_point<T> or std::integral<T>;
28
36 template <typename T>
37 concept vectorizable = arithmetic<T> and not std::same_as<T, bool>;
38
40 template <typename T>
41 concept simd_abi_tag = stdx::is_abi_tag_v<T>;
42
46 template <typename V>
47 concept any_simd
48 = stdx::is_simd_v<V> and vectorizable<typename V::value_type>
50
54 template <typename V>
56 = stdx::is_simd_mask_v<V> and any_simd<typename V::simd_type>
58
60 template <typename V>
62
64 template <typename V, typename T>
65 concept typed_simd = any_simd<V> and std::same_as<T, typename V::value_type>;
66
68 template <typename V, size_t Width>
69 concept sized_simd = any_simd<V> and V::size() == Width;
70
72 template <typename V, size_t Width>
73 concept sized_simd_mask = any_simd_mask<V> and V::size() == Width;
74}
75
76#endif // has concepts
77#endif // VIR_SIMD_CONCEPTS_H_
78
79// vim: noet cc=101 tw=100 sw=2 ts=8
Satisfied if V is a (valid) specialization of simd_mask<T, Abi>.
Definition simd_concepts.h:56
Satisfied if V is either a simd or a simd_mask.
Definition simd_concepts.h:61
Satisfied if V is a (valid) specialization of simd<T, Abi>.
Definition simd_concepts.h:48
This concept matches the core language defintion of an arithmetic type.
Definition simd_concepts.h:27
Satisfied if T is a SIMD ABI tag.
Definition simd_concepts.h:41
Satisfied if V is a simd_mask with the given size Width.
Definition simd_concepts.h:73
Satisfied if V is a simd with the given size Width.
Definition simd_concepts.h:69
Satisfied if V is a simd<T, Abi> with arbitrary but valid ABI tag Abi.
Definition simd_concepts.h:65
Satisfied for all arithmetic types except bool.
Definition simd_concepts.h:37
This namespace collects libraries and tools authored by Matthias Kretz.
Definition constexpr_wrapper.h:21