Split SIMD implementations into 4 files
[gromacs.git] / src / gromacs / simd / impl_x86_sse2 / impl_x86_sse2_simd4_float.h
blob3c043e088ed3f6f5bad8e2d752cf2f310e83e986
1 /*
2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014,2015, by the GROMACS development team, led by
5 * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
6 * and including many others, as listed in the AUTHORS file in the
7 * top-level source directory and at http://www.gromacs.org.
9 * GROMACS is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU Lesser General Public License
11 * as published by the Free Software Foundation; either version 2.1
12 * of the License, or (at your option) any later version.
14 * GROMACS is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Lesser General Public License for more details.
19 * You should have received a copy of the GNU Lesser General Public
20 * License along with GROMACS; if not, see
21 * http://www.gnu.org/licenses, or write to the Free Software Foundation,
22 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 * If you want to redistribute modifications to GROMACS, please
25 * consider that scientific software is very special. Version
26 * control is crucial - bugs must be traceable. We will be happy to
27 * consider code for inclusion in the official distribution, but
28 * derived work must not be called official GROMACS. Details are found
29 * in the README & COPYING files - if they are missing, get the
30 * official version at http://www.gromacs.org.
32 * To help us fund GROMACS development, we humbly ask that you cite
33 * the research papers on the package. Check out http://www.gromacs.org.
36 #ifndef GMX_SIMD_IMPL_X86_SSE2_SIMD4_FLOAT_H
37 #define GMX_SIMD_IMPL_X86_SSE2_SIMD4_FLOAT_H
39 #include "config.h"
41 #include <emmintrin.h>
43 #include "impl_x86_sse2_common.h"
44 #include "impl_x86_sse2_simd_float.h"
46 /* SSE2 is already 4-wide in single, so we just reuse float datatype for SIMD4. */
47 #define gmx_simd4_float_t gmx_simd_float_t
48 #define gmx_simd4_load_f gmx_simd_load_f
49 #define gmx_simd4_load1_f gmx_simd_load1_f
50 #define gmx_simd4_set1_f gmx_simd_set1_f
51 #define gmx_simd4_store_f gmx_simd_store_f
52 #define gmx_simd4_loadu_f gmx_simd_loadu_f
53 #define gmx_simd4_storeu_f gmx_simd_storeu_f
54 #define gmx_simd4_setzero_f gmx_simd_setzero_f
55 #define gmx_simd4_add_f gmx_simd_add_f
56 #define gmx_simd4_sub_f gmx_simd_sub_f
57 #define gmx_simd4_mul_f gmx_simd_mul_f
58 #define gmx_simd4_fmadd_f gmx_simd_fmadd_f
59 #define gmx_simd4_fmsub_f gmx_simd_fmsub_f
60 #define gmx_simd4_fnmadd_f gmx_simd_fnmadd_f
61 #define gmx_simd4_fnmsub_f gmx_simd_fnmsub_f
62 #define gmx_simd4_and_f gmx_simd_and_f
63 #define gmx_simd4_andnot_f gmx_simd_andnot_f
64 #define gmx_simd4_or_f gmx_simd_or_f
65 #define gmx_simd4_xor_f gmx_simd_xor_f
66 #define gmx_simd4_rsqrt_f gmx_simd_rsqrt_f
67 #define gmx_simd4_fabs_f gmx_simd_fabs_f
68 #define gmx_simd4_fneg_f gmx_simd_fneg_f
69 #define gmx_simd4_max_f gmx_simd_max_f
70 #define gmx_simd4_min_f gmx_simd_min_f
71 #define gmx_simd4_round_f gmx_simd_round_f
72 #define gmx_simd4_trunc_f gmx_simd_trunc_f
73 #define gmx_simd4_dotproduct3_f gmx_simd4_dotproduct3_f_sse2
74 #define gmx_simd4_fbool_t gmx_simd_fbool_t
75 #define gmx_simd4_cmpeq_f gmx_simd_cmpeq_f
76 #define gmx_simd4_cmplt_f gmx_simd_cmplt_f
77 #define gmx_simd4_cmple_f gmx_simd_cmple_f
78 #define gmx_simd4_and_fb gmx_simd_and_fb
79 #define gmx_simd4_or_fb gmx_simd_or_fb
80 #define gmx_simd4_anytrue_fb gmx_simd_anytrue_fb
81 #define gmx_simd4_blendzero_f gmx_simd_blendzero_f
82 #define gmx_simd4_blendnotzero_f gmx_simd_blendnotzero_f
83 #define gmx_simd4_blendv_f gmx_simd_blendv_f
84 #define gmx_simd4_reduce_f gmx_simd_reduce_f
86 /* SIMD4 Dotproduct helper function */
87 static gmx_inline float gmx_simdcall
88 gmx_simd4_dotproduct3_f_sse2(__m128 a, __m128 b)
90 float f;
91 __m128 c;
92 a = _mm_mul_ps(a, b);
93 c = _mm_add_ps(a, _mm_shuffle_ps(a, a, _MM_SHUFFLE(2, 1, 2, 1)));
94 c = _mm_add_ps(c, _mm_shuffle_ps(a, a, _MM_SHUFFLE(3, 2, 3, 2)));
95 _mm_store_ss(&f, c);
96 return f;
99 #endif /* GMX_SIMD_IMPL_X86_SSE2_SIMD4_FLOAT_H */