Remove unused config.h defines
[alexxy/gromacs.git] / src / gromacs / legacyheaders / gmx_simd_vec.h
1 /*
2  * This file is part of the GROMACS molecular simulation package.
3  *
4  * Copyright (c) 1991-2000, University of Groningen, The Netherlands.
5  * Copyright (c) 2001-2012, The GROMACS Development Team
6  * Copyright (c) 2012,2013, by the GROMACS development team, led by
7  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
8  * and including many others, as listed in the AUTHORS file in the
9  * top-level source directory and at http://www.gromacs.org.
10  *
11  * GROMACS is free software; you can redistribute it and/or
12  * modify it under the terms of the GNU Lesser General Public License
13  * as published by the Free Software Foundation; either version 2.1
14  * of the License, or (at your option) any later version.
15  *
16  * GROMACS is distributed in the hope that it will be useful,
17  * but WITHOUT ANY WARRANTY; without even the implied warranty of
18  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
19  * Lesser General Public License for more details.
20  *
21  * You should have received a copy of the GNU Lesser General Public
22  * License along with GROMACS; if not, see
23  * http://www.gnu.org/licenses, or write to the Free Software Foundation,
24  * Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA.
25  *
26  * If you want to redistribute modifications to GROMACS, please
27  * consider that scientific software is very special. Version
28  * control is crucial - bugs must be traceable. We will be happy to
29  * consider code for inclusion in the official distribution, but
30  * derived work must not be called official GROMACS. Details are found
31  * in the README & COPYING files - if they are missing, get the
32  * official version at http://www.gromacs.org.
33  *
34  * To help us fund GROMACS development, we humbly ask that you cite
35  * the research papers on the package. Check out http://www.gromacs.org.
36  */
37
38 /* The macros in this file are intended to be used for writing
39  * architecture-independent SIMD intrinsics code.
40  * To support a new architecture, adding macros here should be (nearly)
41  * all that is needed.
42  */
43
44 /* This file contains vector operation functions using SIMD intrinsics.
45  * gmx_simd_macros.h should be included before including this file.
46  */
47
48 #ifndef _gmx_simd_vec_h_
49 #define _gmx_simd_vec_h_
50
51 #ifndef _gmx_simd_macros_h_
52 #error "gmx_simd_macros.h was not included before including gmx_simd_vec.h"
53 #endif
54
55
56 /* x^2 + y^2 + z^2 */
57 static gmx_inline gmx_mm_pr
58 gmx_calc_rsq_pr(gmx_mm_pr x, gmx_mm_pr y, gmx_mm_pr z)
59 {
60     return gmx_madd_pr(z, z, gmx_madd_pr(y, y, gmx_mul_pr(x, x)));
61 }
62
63 /* inner-product of multiple vectors */
64 static gmx_inline gmx_mm_pr
65 gmx_iprod_pr(gmx_mm_pr ax, gmx_mm_pr ay, gmx_mm_pr az,
66              gmx_mm_pr bx, gmx_mm_pr by, gmx_mm_pr bz)
67 {
68     gmx_mm_pr ret;
69
70     ret = gmx_mul_pr(ax, bx);
71     ret = gmx_madd_pr(ay, by, ret);
72     ret = gmx_madd_pr(az, bz, ret);
73
74     return ret;
75 }
76
77 /* norm squared of multiple vectors */
78 static gmx_inline gmx_mm_pr
79 gmx_norm2_pr(gmx_mm_pr ax, gmx_mm_pr ay, gmx_mm_pr az)
80 {
81     gmx_mm_pr ret;
82
83     ret = gmx_mul_pr(ax, ax);
84     ret = gmx_madd_pr(ay, ay, ret);
85     ret = gmx_madd_pr(az, az, ret);
86
87     return ret;
88 }
89
90 /* cross-product of multiple vectors */
91 static gmx_inline void
92 gmx_cprod_pr(gmx_mm_pr ax, gmx_mm_pr ay, gmx_mm_pr az,
93              gmx_mm_pr bx, gmx_mm_pr by, gmx_mm_pr bz,
94              gmx_mm_pr *cx, gmx_mm_pr *cy, gmx_mm_pr *cz)
95 {
96     *cx = gmx_mul_pr(ay, bz);
97     *cx = gmx_nmsub_pr(az, by, *cx);
98
99     *cy = gmx_mul_pr(az, bx);
100     *cy = gmx_nmsub_pr(ax, bz, *cy);
101
102     *cz = gmx_mul_pr(ax, by);
103     *cz = gmx_nmsub_pr(ay, bx, *cz);
104 }
105
106 /* a + b + c + d (not really a vector operation, but where else put this?) */
107 static gmx_inline gmx_mm_pr
108 gmx_sum4_pr(gmx_mm_pr a, gmx_mm_pr b, gmx_mm_pr c, gmx_mm_pr d)
109 {
110     return gmx_add_pr(gmx_add_pr(a, b), gmx_add_pr(c, d));
111 }
112
113
114 #endif /* _gmx_simd_vec_h_ */