T-SIMD v31.1.0
A C++ template SIMD library
Loading...
Searching...
No Matches
mask_impl_intel32.H
1// ===========================================================================
2//
3// Mask class definitions and architecture specific functions
4// for Intel 32 byte (256 bit)
5//
6// This source code file is part of the following software:
7//
8// - the low-level C++ template SIMD library
9// - the SIMD implementation of the MinWarping and the 2D-Warping methods
10// for local visual homing.
11//
12// The software is provided based on the accompanying license agreement in the
13// file LICENSE.md.
14// The software is provided "as is" without any warranty by the licensor and
15// without any liability of the licensor, and the software may not be
16// distributed by the licensee; see the license agreement for details.
17//
18// (C) Jonas Keller, Ralf Möller
19// Computer Engineering
20// Faculty of Technology
21// Bielefeld University
22// www.ti.uni-bielefeld.de
23//
24// ===========================================================================
25
26// 05. Jun 24 (Jonas Keller): added Intel32 implementations of masked load and
27// store functions for 32 bit and 64 bit data types
28
29#pragma once
30#ifndef SIMD_VEC_MASK_IMPL_INTEL_32_H_
31#define SIMD_VEC_MASK_IMPL_INTEL_32_H_
32
33#include "../base.H"
34#include "../defs.H"
35#include "../mask_impl_emu.H"
36#include "../types.H"
37#include "../vec.H"
38#include "intrins_intel.H"
39
40#if defined(SIMDVEC_INTEL_ENABLE) && defined(_SIMD_VEC_32_AVAIL_) && \
41 !defined(SIMDVEC_SANDBOX)
42namespace simd {
43namespace internal {
44namespace mask {
45template <typename T, SIMD_ENABLE_IF(sizeof(T) == 4)>
46static SIMD_INLINE Vec<T, 32> maskz_loadu(const Mask<T, 32> &k,
47 const T *const p)
48{
49 return reinterpret<T>(Vec<Float, 32>(_mm256_maskload_ps(
50 reinterpret_cast<const Float *>(p), reinterpret<Int>((Vec<T, 32>) k))));
51}
52
53template <typename T, SIMD_ENABLE_IF(sizeof(T) == 8), typename = void>
54static SIMD_INLINE Vec<T, 32> maskz_loadu(const Mask<T, 32> &k,
55 const T *const p)
56{
57 return reinterpret<T>(Vec<Double, 32>(_mm256_maskload_pd(
58 reinterpret_cast<const Double *>(p), reinterpret<Long>((Vec<T, 32>) k))));
59}
60
61template <typename T, SIMD_ENABLE_IF(sizeof(T) == 4 || sizeof(T) == 8)>
62static SIMD_INLINE Vec<T, 32> mask_loadu(const Vec<T, 32> &src,
63 const Mask<T, 32> &k, const T *const p)
64{
65 return mask::mask_ifelse(k, mask::maskz_loadu(k, p), src);
66}
67
68template <typename T, SIMD_ENABLE_IF(sizeof(T) == 4 || sizeof(T) == 8)>
69static SIMD_INLINE Vec<T, 32> maskz_load(const Mask<T, 32> &k, const T *const p)
70{
71 return mask::maskz_loadu(k, p);
72}
73
74template <typename T, SIMD_ENABLE_IF(sizeof(T) == 4 || sizeof(T) == 8)>
75static SIMD_INLINE Vec<T, 32> mask_load(const Vec<T, 32> &src,
76 const Mask<T, 32> &k, const T *const p)
77{
78 return mask::mask_loadu(src, k, p);
79}
80
81template <typename T, SIMD_ENABLE_IF(sizeof(T) == 4)>
82static SIMD_INLINE void mask_storeu(T *const p, const Mask<T, 32> &k,
83 const Vec<T, 32> &a)
84{
85 _mm256_maskstore_ps(reinterpret_cast<Float *>(p),
86 reinterpret<Int>((Vec<T, 32>) k), reinterpret<Float>(a));
87}
88
89template <typename T, SIMD_ENABLE_IF(sizeof(T) == 8), typename = void>
90static SIMD_INLINE void mask_storeu(T *const p, const Mask<T, 32> &k,
91 const Vec<T, 32> &a)
92{
93 _mm256_maskstore_pd(reinterpret_cast<Double *>(p),
94 reinterpret<Long>((Vec<T, 32>) k),
96}
97
98template <typename T, SIMD_ENABLE_IF(sizeof(T) == 4 || sizeof(T) == 8)>
99static SIMD_INLINE void mask_store(T *const p, const Mask<T, 32> &k,
100 const Vec<T, 32> &a)
101{
102 mask::mask_storeu(p, k, a);
103}
104
105} // namespace mask
106} // namespace internal
107} // namespace simd
108#endif
109
110#endif // SIMD_VEC_MASK_IMPL_INTEL_32_H_
float Float
Single-precision floating point number (32-bit)
Definition types.H:56
double Double
Double-precision floating point number (64-bit)
Definition types.H:57
static Vec< Tout, SIMD_WIDTH > reinterpret(const Vec< Tin, SIMD_WIDTH > &a)
Reinterprets a given Vec as a Vec with a different element type.
Definition base.H:58
Namespace for T-SIMD.
Definition time_measurement.H:161