LAL 7.7.0.1-678514e
LALSIMD.h
Go to the documentation of this file.
1/*
2 * Copyright (C) 2015 Jolien Creighton, Reinhard Prix, Karl Wette
3 *
4 * This program is free software; you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation; either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with with program; see the file COPYING. If not, write to the
16 * Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston,
17 * MA 02110-1301 USA
18 */
19
20#ifndef LALSIMD_H
21#define LALSIMD_H
22
23#if defined(__cplusplus)
24extern "C" {
25#endif
26
27/**
28 * \defgroup LALSIMD_h Header LALSIMD.h
29 * \ingroup lal_std
30 * \author Karl Wette
31 * \brief SIMD extension detection and runtime selection for LALSuite
32 *
33 * ### Synopsis ###
34 * \code
35 * #include <lal/LALSIMD.h>
36 *
37 * if (LAL_HAVE_SSE_RUNTIME()) {
38 * perform_sse_magic(out, in, ...);
39 * }
40 * \endcode
41 */
42/** @{ */
43
44/**
45 * SIMD instruction sets this module can detect
46 */
47typedef enum tagLAL_SIMD_ISET {
48
49 LAL_SIMD_ISET_GEN, /**< GENeric floating-point unit */
50 LAL_SIMD_ISET_SSE, /**< SSE (Streaming SIMD Extensions) */
51 LAL_SIMD_ISET_SSE2, /**< SSE version 2 */
52 LAL_SIMD_ISET_SSE3, /**< SSE version 3 */
53 LAL_SIMD_ISET_SSSE3, /**< Supplemental SSE version 3 */
54 LAL_SIMD_ISET_SSE4_1, /**< SSE version 4.1 */
55 LAL_SIMD_ISET_SSE4_2, /**< SSE version 4.2 */
56 LAL_SIMD_ISET_AVX, /**< AVX (Advanced Vector Extensions) */
57 LAL_SIMD_ISET_AVX2, /**< AVX version 2 */
58
61
62/**
63 * Return true if the executing machine supports the given instruction set
64 */
66
67/**
68 * Return the name of a given instruction set as a string
69 */
71
72/** \name Convenience macros for SIMD runtime selection */
73/** @{ */
74#define LAL_HAVE_SSE_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_SSE))
75#define LAL_HAVE_SSE2_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_SSE2))
76#define LAL_HAVE_SSE3_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_SSE3))
77#define LAL_HAVE_SSSE3_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_SSSE3))
78#define LAL_HAVE_SSE4_1_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_SSE4_1))
79#define LAL_HAVE_SSE4_2_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_SSE4_2))
80#define LAL_HAVE_AVX_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_AVX))
81#define LAL_HAVE_AVX2_RUNTIME() (XLALHaveSIMDInstructionSet(LAL_SIMD_ISET_AVX2))
82/** @} */
83
84/** @} */
85
86#if defined(__cplusplus)
87}
88#endif
89
90#endif /* LALSIMD_H */
int XLALHaveSIMDInstructionSet(LAL_SIMD_ISET iset)
Return true if the executing machine supports the given instruction set.
Definition: LALSIMD.c:284
LAL_SIMD_ISET
SIMD instruction sets this module can detect.
Definition: LALSIMD.h:47
const char * XLALSIMDInstructionSetName(LAL_SIMD_ISET iset)
Return the name of a given instruction set as a string.
Definition: LALSIMD.c:289
@ LAL_SIMD_ISET_SSE4_1
SSE version 4.1.
Definition: LALSIMD.h:54
@ LAL_SIMD_ISET_SSE3
SSE version 3.
Definition: LALSIMD.h:52
@ LAL_SIMD_ISET_SSE
SSE (Streaming SIMD Extensions)
Definition: LALSIMD.h:50
@ LAL_SIMD_ISET_AVX2
AVX version 2.
Definition: LALSIMD.h:57
@ LAL_SIMD_ISET_SSE4_2
SSE version 4.2.
Definition: LALSIMD.h:55
@ LAL_SIMD_ISET_SSE2
SSE version 2.
Definition: LALSIMD.h:51
@ LAL_SIMD_ISET_GEN
GENeric floating-point unit.
Definition: LALSIMD.h:49
@ LAL_SIMD_ISET_AVX
AVX (Advanced Vector Extensions)
Definition: LALSIMD.h:56
@ LAL_SIMD_ISET_SSSE3
Supplemental SSE version 3.
Definition: LALSIMD.h:53
@ LAL_SIMD_ISET_MAX
Definition: LALSIMD.h:59