simd.hpp
Go to the documentation of this file.
1/*!
2 *
3 *
4 * \brief Some Macros and basic definitions for the use of SIMD block storage
5 *
6 * \author O. Krause
7 * \date 2016
8 *
9 *
10 * \par Copyright 1995-2015 Shark Development Team
11 *
12 * <BR><HR>
13 * This file is part of Shark.
14 * <http://image.diku.dk/shark/>
15 *
16 * Shark is free software: you can redistribute it and/or modify
17 * it under the terms of the GNU Lesser General Public License as published
18 * by the Free Software Foundation, either version 3 of the License, or
19 * (at your option) any later version.
20 *
21 * Shark is distributed in the hope that it will be useful,
22 * but WITHOUT ANY WARRANTY; without even the implied warranty of
23 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
24 * GNU Lesser General Public License for more details.
25 *
26 * You should have received a copy of the GNU Lesser General Public License
27 * along with Shark. If not, see <http://www.gnu.org/licenses/>.
28 *
29 */
30
31#ifndef REMORA_KERNELS_DEFAULT_SIMD_HPP
32#define REMORA_KERNELS_DEFAULT_SIMD_HPP
33
34#include <boost/version.hpp>
35#include <cstddef>
36
37//older boost versions have some issues
38 #if (BOOST_VERSION >= 106300)
39 #include <boost/align/assume_aligned.hpp>
40 #include <boost/align/aligned_allocator.hpp>
41#else//subset of boost/align 1.63
42 #include "boost_align/assume_aligned.hpp"
43 #include "boost_align/aligned_allocator.hpp"
44#endif
45
46
47
48
49#ifdef __AVX__
50 #define REMORA_VECTOR_LENGTH 32
51#else
52 #define REMORA_VECTOR_LENGTH 16
53#endif
54
55namespace remora{namespace bindings{namespace detail{
56template<class T>
57struct block{
58 static const std::size_t max_vector_elements = REMORA_VECTOR_LENGTH/sizeof(T);
59 #ifdef REMORA_USE_SIMD
60 static const std::size_t vector_elements = REMORA_VECTOR_LENGTH/sizeof(T);
61 #ifdef BOOST_COMP_CLANG_DETECTION
62 typedef T type __attribute__((ext_vector_type (vector_elements)));
63 #else
64 typedef T type __attribute__((vector_size (REMORA_VECTOR_LENGTH)));
65 #endif
66 #else
67 static const std::size_t vector_elements = 1;
68 typedef T type;
69 #endif
70 static const std::size_t align = 64;
71};
72}}}
73#endif