]>
Commit | Line | Data |
---|---|---|
f22341db | 1 | /* This file is part of the Vc library. |
2 | ||
3 | Copyright (C) 2010-2012 Matthias Kretz <kretz@kde.org> | |
4 | ||
5 | Vc is free software: you can redistribute it and/or modify | |
6 | it under the terms of the GNU Lesser General Public License as | |
7 | published by the Free Software Foundation, either version 3 of | |
8 | the License, or (at your option) any later version. | |
9 | ||
10 | Vc is distributed in the hope that it will be useful, but | |
11 | WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | GNU Lesser General Public License for more details. | |
14 | ||
15 | You should have received a copy of the GNU Lesser General Public | |
16 | License along with Vc. If not, see <http://www.gnu.org/licenses/>. | |
17 | ||
18 | */ | |
19 | ||
20 | #ifndef VC_SSE_HELPERIMPL_TCC | |
21 | #define VC_SSE_HELPERIMPL_TCC | |
22 | ||
f22341db | 23 | #include <cstdio> |
24 | ||
c017a39f | 25 | namespace AliRoot { |
f22341db | 26 | namespace Vc |
27 | { | |
28 | namespace Internal | |
29 | { | |
30 | ||
31 | template<size_t X> | |
c017a39f | 32 | static _VC_CONSTEXPR size_t nextMultipleOf(size_t value) |
f22341db | 33 | { |
c017a39f | 34 | return (value % X) > 0 ? value + X - (value % X) : value; |
f22341db | 35 | } |
36 | ||
37 | template<Vc::MallocAlignment A> | |
c017a39f | 38 | Vc_ALWAYS_INLINE void *HelperImpl<SSE2Impl>::malloc(size_t n) |
f22341db | 39 | { |
40 | switch (A) { | |
41 | case Vc::AlignOnVector: | |
42 | return _mm_malloc(nextMultipleOf<Vc::SSE::VectorAlignment>(n), Vc::SSE::VectorAlignment); | |
43 | case Vc::AlignOnCacheline: | |
44 | // TODO: hardcoding 64 is not such a great idea | |
45 | return _mm_malloc(nextMultipleOf<64>(n), 64); | |
46 | case Vc::AlignOnPage: | |
47 | // TODO: hardcoding 4096 is not such a great idea | |
48 | return _mm_malloc(nextMultipleOf<4096>(n), 4096); | |
49 | default: | |
50 | #ifndef NDEBUG | |
51 | abort(); | |
52 | #endif | |
53 | return _mm_malloc(n, 8); | |
54 | } | |
55 | } | |
56 | ||
c017a39f | 57 | Vc_ALWAYS_INLINE void HelperImpl<SSE2Impl>::free(void *p) |
f22341db | 58 | { |
59 | _mm_free(p); | |
60 | } | |
61 | ||
62 | } // namespace Internal | |
63 | } // namespace Vc | |
c017a39f | 64 | } // namespace AliRoot |
f22341db | 65 | |
66 | #endif // VC_SSE_HELPERIMPL_TCC |