BitMagic-C++
bmsimd.h
Go to the documentation of this file.
1#ifndef BMSIMD__H__INCLUDED__
2#define BMSIMD__H__INCLUDED__
3/*
4Copyright(c) 2002-2017 Anatoliy Kuznetsov(anatoliy_kuznetsov at yahoo.com)
5
6Licensed under the Apache License, Version 2.0 (the "License");
7you may not use this file except in compliance with the License.
8You may obtain a copy of the License at
9
10 http://www.apache.org/licenses/LICENSE-2.0
11
12Unless required by applicable law or agreed to in writing, software
13distributed under the License is distributed on an "AS IS" BASIS,
14WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15See the License for the specific language governing permissions and
16limitations under the License.
17
18For more information please visit: http://bitmagic.io
19*/
20/*! \file bmsimd.h
21 \brief SIMD target version definitions
22*/
23
24#ifdef BMNEONOPT
25#pragma GCC diagnostic push
26#pragma GCC diagnostic ignored "-Wstrict-aliasing"
27#include "sse2neon.h"
28#pragma GCC diagnostic pop
29#define BMSSE2OPT
30#endif
31
32
33#ifdef BMWASMSIMDOPT
34#include <wasm_simd128.h>
35#define BMSSE42OPT
36#endif
37
38#ifdef BMAVX512OPT
39# undef BMAVX2OPT
40# undef BMSSE42OPT
41# undef BMSSE2OPT
42# define BMVECTOPT
43# include "bmavx512.h"
44#endif
45
46
47#ifdef BMAVX2OPT
48# undef BMSSE42OPT
49# undef BMSSE2OPT
50# define BMVECTOPT
51# include "bmavx2.h"
52#endif
53
54
55#ifdef BMSSE42OPT
56# define BMVECTOPT
57# include "bmsse4.h"
58#endif
59
60#ifdef BMSSE2OPT
61# undef BM64OPT
62# define BMVECTOPT
63# include "bmsse2.h"
64#endif
65
66namespace bm
67{
68
69/**
70 @brief return SIMD optimization used for building BitMagic
71 @return SIMD code
72
73 @ingroup bmagic
74*/
75inline int simd_version()
76{
77#if defined(BMWASMSIMDOPT)
78 return bm::simd_wasm128;
79#elif defined(BMNEONOPT)
80 return bm::simd_neon;
81#elif defined(BMAVX512OPT)
82 return bm::simd_avx512;
83#elif defined(BMAVX2OPT)
84 return bm::simd_avx2;
85#elif defined(BMSSE42OPT)
86 return bm::simd_sse42;
87#elif defined(BMSSE2OPT)
88 return bm::simd_sse2;
89#else
90 return bm::simd_none;
91#endif
92}
93
94
95} // namespace
96
97#endif
Compute functions for SSE2 SIMD instruction set (internal)
Compute functions for SSE4.2 SIMD instruction set (internal)
int simd_version()
return SIMD optimization used for building BitMagic
Definition: bmsimd.h:75
Definition: bm.h:78
@ simd_sse42
!< Intel SSE2
Definition: bmconst.h:438
@ simd_sse2
!< No SIMD or any other optimization
Definition: bmconst.h:437
@ simd_none
Definition: bmconst.h:436
@ simd_avx512
!< Intel AVX2
Definition: bmconst.h:440
@ simd_neon
! WASM SIMD 128
Definition: bmconst.h:442
@ simd_avx2
!< Intel SSE4.2
Definition: bmconst.h:439
@ simd_wasm128
!< Intel AVX512
Definition: bmconst.h:441