Peano
Loading...
Searching...
No Matches
align.h
Go to the documentation of this file.
1/*******************************************************************************
2 * This file is part of SWIFT.
3 * Copyright (c) 2016 Matthieu Schaller (schaller@strw.leidenuniv.nl).
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Lesser General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 *
18 ******************************************************************************/
19#ifndef SWIFT_ALIGN_H
20#define SWIFT_ALIGN_H
21
25#define SWIFT_STRUCT_ALIGNMENT 32
26
30#define SWIFT_STRUCT_ALIGN __attribute__((aligned(SWIFT_STRUCT_ALIGNMENT)))
31
35#define SWIFT_CACHE_ALIGNMENT 64
36
40#define SWIFT_CACHE_ALIGN __attribute__((aligned(SWIFT_CACHE_ALIGNMENT)))
41
54#if defined(__ICC)
55#define swift_align_information(type, array, alignment) \
56 __assume_aligned(array, alignment);
57#elif (__GNUC__ > 4) || (__GNUC__ == 4 && __GNUC_MINOR__ > 6)
58#define swift_align_information(type, array, alignment) \
59 array = (type *)__builtin_assume_aligned(array, alignment);
60#else
61#define swift_align_information(type, array, alignment) ;
62#endif
63
76#define swift_declare_aligned_ptr(type, array, ptr, alignment) \
77 type *restrict array = ptr; \
78 swift_align_information(type, array, alignment);
79
90#if defined(__ICC)
91#define swift_assume_size(var, size) __assume(var % size == 0);
92#else
93#define swift_assume_size(var, size) ;
94#endif
95
96#endif /* SWIFT_ALIGN_H */