2 * This file is part of the GROMACS molecular simulation package.
4 * Copyright (c) 2014, 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.
45 /*! \addtogroup module_simd */
48 #ifdef GMX_SIMD4_HAVE_REAL
50 const gmx_simd4_real_t rSimd4_1_2_3 = setSimd4RealFrom3R(1, 2, 3);
51 const gmx_simd4_real_t rSimd4_4_5_6 = setSimd4RealFrom3R(4, 5, 6);
52 const gmx_simd4_real_t rSimd4_7_8_9 = setSimd4RealFrom3R(7, 8, 9);
53 const gmx_simd4_real_t rSimd4_5_7_9 = setSimd4RealFrom3R(5, 7, 9);
54 const gmx_simd4_real_t rSimd4_m1_m2_m3 = setSimd4RealFrom3R(-1, -2, -3);
55 const gmx_simd4_real_t rSimd4_3_1_4 = setSimd4RealFrom3R(3, 1, 4);
56 const gmx_simd4_real_t rSimd4_m3_m1_m4 = setSimd4RealFrom3R(-3, -1, -4);
57 const gmx_simd4_real_t rSimd4_2p25 = setSimd4RealFrom1R(2.25);
58 const gmx_simd4_real_t rSimd4_3p75 = setSimd4RealFrom1R(3.75);
59 const gmx_simd4_real_t rSimd4_m2p25 = setSimd4RealFrom1R(-2.25);
60 const gmx_simd4_real_t rSimd4_m3p75 = setSimd4RealFrom1R(-3.75);
61 const gmx_simd4_real_t rSimd4_Exp = setSimd4RealFrom3R( 1.4055235171027452623914516e+18,
62 5.3057102734253445623914516e-13,
63 -2.1057102745623934534514516e+16);
64 # if (defined GMX_SIMD_HAVE_DOUBLE) && (defined GMX_DOUBLE)
65 // Make sure we also test exponents outside single precision when we use double
66 const gmx_simd4_real_t rSimd_ExpDouble = setSimd4RealFrom3R( 6.287393598732017379054414e+176,
67 8.794495252903116023030553e-140,
68 -3.637060701570496477655022e+202);
69 // Magic FP numbers corresponding to specific bit patterns
70 const gmx_simd4_real_t rSimd4_Bits1 = setSimd4RealFrom1R(-1.07730874267432137e+236);
71 const gmx_simd4_real_t rSimd4_Bits2 = setSimd4RealFrom1R(-9.25596313493178307e+061);
72 const gmx_simd4_real_t rSimd4_Bits3 = setSimd4RealFrom1R(-8.57750588235293981e+003);
73 const gmx_simd4_real_t rSimd4_Bits4 = setSimd4RealFrom1R( 1.22416778341839096e-250);
74 const gmx_simd4_real_t rSimd4_Bits5 = setSimd4RealFrom1R(-1.15711777004554095e+294);
75 const gmx_simd4_real_t rSimd4_Bits6 = setSimd4RealFrom1R( 1.53063836115600621e-018);
77 const gmx_simd4_real_t rSimd4_Bits1 = setSimd4RealFrom1R(-5.9654142337e+29);
78 const gmx_simd4_real_t rSimd4_Bits2 = setSimd4RealFrom1R(-1.0737417600e+08);
79 const gmx_simd4_real_t rSimd4_Bits3 = setSimd4RealFrom1R(-6.0235290527e+00);
80 const gmx_simd4_real_t rSimd4_Bits4 = setSimd4RealFrom1R( 1.0788832913e-31);
81 const gmx_simd4_real_t rSimd4_Bits5 = setSimd4RealFrom1R(-1.0508719529e+37);
82 const gmx_simd4_real_t rSimd4_Bits6 = setSimd4RealFrom1R( 1.1488970369e-02);
86 simd4Real2Vector(const gmx_simd4_real_t simd4)
88 real mem[GMX_SIMD4_WIDTH*2];
89 real * p = gmx_simd4_align_r(mem);
91 gmx_simd4_store_r(p, simd4);
92 std::vector<real> v(p, p+GMX_SIMD4_WIDTH);
98 vector2Simd4Real(const std::vector<real> &v)
100 real mem[GMX_SIMD4_WIDTH*2];
101 real * p = gmx_simd4_align_r(mem);
103 for (int i = 0; i < GMX_SIMD4_WIDTH; i++)
105 p[i] = v[i % v.size()]; // repeat vector contents to fill simd width
107 return gmx_simd4_load_r(p);
111 setSimd4RealFrom3R(real r0, real r1, real r2)
113 std::vector<real> v(3);
117 return vector2Simd4Real(v);
121 setSimd4RealFrom1R(real value)
123 std::vector<real> v(GMX_SIMD4_WIDTH);
124 for (int i = 0; i < GMX_SIMD4_WIDTH; i++)
128 return vector2Simd4Real(v);
131 testing::AssertionResult
132 Simd4Test::compareSimd4RealUlp(const char * refExpr, const char * tstExpr,
133 const gmx_simd4_real_t ref, const gmx_simd4_real_t tst)
135 return compareVectorRealUlp(refExpr, tstExpr, simd4Real2Vector(ref), simd4Real2Vector(tst));
138 testing::AssertionResult
139 Simd4Test::compareSimd4RealEq(const char * refExpr, const char * tstExpr,
140 const gmx_simd4_real_t ref, const gmx_simd4_real_t tst)
142 return compareVectorEq(refExpr, tstExpr, simd4Real2Vector(ref), simd4Real2Vector(tst));
145 #endif // GMX_SIMD4_HAVE_REAL