Apply clang-format to source tree
[alexxy/gromacs.git] / src / gromacs / simd / impl_ibm_vsx / impl_ibm_vsx_util_double.h
index 6d96e43ce4a7a9945dd40124a13f143f437dc5f9..ca5852f421f9bb5f72a8c33161eb925b7f2f832a 100644 (file)
@@ -1,7 +1,7 @@
 /*
  * This file is part of the GROMACS molecular simulation package.
  *
- * Copyright (c) 2014,2015,2016,2017,2018, by the GROMACS development team, led by
+ * Copyright (c) 2014,2015,2016,2017,2018,2019, by the GROMACS development team, led by
  * Mark Abraham, David van der Spoel, Berk Hess, and Erik Lindahl,
  * and including many others, as listed in the AUTHORS file in the
  * top-level source directory and at http://www.gromacs.org.
 namespace gmx
 {
 
-template <int align>
-static inline void gmx_simdcall
-gatherLoadTranspose(const double *        base,
-                    const std::int32_t    offset[],
-                    SimdDouble *          v0,
-                    SimdDouble *          v1,
-                    SimdDouble *          v2,
-                    SimdDouble *          v3)
+template<int align>
+static inline void gmx_simdcall gatherLoadTranspose(const double*      base,
+                                                    const std::int32_t offset[],
+                                                    SimdDouble*        v0,
+                                                    SimdDouble*        v1,
+                                                    SimdDouble*        v2,
+                                                    SimdDouble*        v3)
 {
     __vector double t1, t2, t3, t4;
 
-    t1                = *reinterpret_cast<const __vector double *>(base + align * offset[0]);
-    t2                = *reinterpret_cast<const __vector double *>(base + align * offset[1]);
-    t3                = *reinterpret_cast<const __vector double *>(base + align * offset[0] + 2);
-    t4                = *reinterpret_cast<const __vector double *>(base + align * offset[1] + 2);
+    t1                = *reinterpret_cast<const __vector double*>(base + align * offset[0]);
+    t2                = *reinterpret_cast<const __vector double*>(base + align * offset[1]);
+    t3                = *reinterpret_cast<const __vector double*>(base + align * offset[0] + 2);
+    t4                = *reinterpret_cast<const __vector double*>(base + align * offset[1] + 2);
     v0->simdInternal_ = vec_mergeh(t1, t2);
     v1->simdInternal_ = vec_mergel(t1, t2);
     v2->simdInternal_ = vec_mergeh(t3, t4);
     v3->simdInternal_ = vec_mergel(t3, t4);
-
 }
 
-template <int align>
+template<int align>
 static inline void gmx_simdcall
-gatherLoadTranspose(const double *        base,
-                    const std::int32_t    offset[],
-                    SimdDouble *          v0,
-                    SimdDouble *          v1)
+                   gatherLoadTranspose(const double* base, const std::int32_t offset[], SimdDouble* v0, SimdDouble* v1)
 {
     __vector double t1, t2;
 
-    t1                = *reinterpret_cast<const __vector double *>(base + align * offset[0]);
-    t2                = *reinterpret_cast<const __vector double *>(base + align * offset[1]);
+    t1                = *reinterpret_cast<const __vector double*>(base + align * offset[0]);
+    t2                = *reinterpret_cast<const __vector double*>(base + align * offset[1]);
     v0->simdInternal_ = vec_mergeh(t1, t2);
     v1->simdInternal_ = vec_mergel(t1, t2);
-
 }
 
 static const int c_simdBestPairAlignmentDouble = 2;
 
-template <int align>
-static inline void gmx_simdcall
-gatherLoadUTranspose(const double *        base,
-                     const std::int32_t    offset[],
-                     SimdDouble *          v0,
-                     SimdDouble *          v1,
-                     SimdDouble *          v2)
+template<int align>
+static inline void gmx_simdcall gatherLoadUTranspose(const double*      base,
+                                                     const std::int32_t offset[],
+                                                     SimdDouble*        v0,
+                                                     SimdDouble*        v1,
+                                                     SimdDouble*        v2)
 {
-    SimdDouble      t1, t2;
+    SimdDouble t1, t2;
 
-    t1  = simdLoad(base + align * offset[0]);
-    t2  = simdLoad(base + align * offset[1]);
+    t1 = simdLoad(base + align * offset[0]);
+    t2 = simdLoad(base + align * offset[1]);
 
     v0->simdInternal_ = vec_mergeh(t1.simdInternal_, t2.simdInternal_);
     v1->simdInternal_ = vec_mergel(t1.simdInternal_, t2.simdInternal_);
@@ -106,13 +99,12 @@ gatherLoadUTranspose(const double *        base,
 }
 
 // gcc-4.9 fails to recognize that the argument to vec_extract() is used
-template <int align>
-static inline void gmx_simdcall
-transposeScatterStoreU(double *              base,
-                       const std::int32_t    offset[],
-                       SimdDouble            v0,
-                       SimdDouble            v1,
-                       SimdDouble gmx_unused v2)
+template<int align>
+static inline void gmx_simdcall transposeScatterStoreU(double*            base,
+                                                       const std::int32_t offset[],
+                                                       SimdDouble         v0,
+                                                       SimdDouble         v1,
+                                                       SimdDouble gmx_unused v2)
 {
     SimdDouble t1, t2;
 
@@ -120,18 +112,14 @@ transposeScatterStoreU(double *              base,
     t2.simdInternal_ = vec_mergel(v0.simdInternal_, v1.simdInternal_);
 
     store(base + align * offset[0], t1);
-    base[align * offset[0] + 2]  = vec_extract(v2.simdInternal_, 0);
+    base[align * offset[0] + 2] = vec_extract(v2.simdInternal_, 0);
     store(base + align * offset[1], t2);
-    base[align * offset[1] + 2]  = vec_extract(v2.simdInternal_, 1);
+    base[align * offset[1] + 2] = vec_extract(v2.simdInternal_, 1);
 }
 
-template <int align>
+template<int align>
 static inline void gmx_simdcall
-transposeScatterIncrU(double *            base,
-                      const std::int32_t  offset[],
-                      SimdDouble          v0,
-                      SimdDouble          v1,
-                      SimdDouble          v2)
+                   transposeScatterIncrU(double* base, const std::int32_t offset[], SimdDouble v0, SimdDouble v1, SimdDouble v2)
 {
     if (align % 4 == 0)
     {
@@ -165,25 +153,21 @@ transposeScatterIncrU(double *            base,
         t1 = vec_mergeh(v0.simdInternal_, v1.simdInternal_);
         t2 = vec_mergel(v0.simdInternal_, v1.simdInternal_);
 
-        t3 = simdLoad(base + align * offset[0]);
-        t3.simdInternal_             = vec_add(t3.simdInternal_, t1);
+        t3               = simdLoad(base + align * offset[0]);
+        t3.simdInternal_ = vec_add(t3.simdInternal_, t1);
         store(base + align * offset[0], t3);
         base[align * offset[0] + 2] += vec_extract(v2.simdInternal_, 0);
 
-        t4 = simdLoad(base + align * offset[1]);
-        t4.simdInternal_             = vec_add(t4.simdInternal_, t2);
+        t4               = simdLoad(base + align * offset[1]);
+        t4.simdInternal_ = vec_add(t4.simdInternal_, t2);
         store(base + align * offset[1], t4);
         base[align * offset[1] + 2] += vec_extract(v2.simdInternal_, 1);
     }
 }
 
-template <int align>
+template<int align>
 static inline void gmx_simdcall
-transposeScatterDecrU(double *            base,
-                      const std::int32_t  offset[],
-                      SimdDouble          v0,
-                      SimdDouble          v1,
-                      SimdDouble          v2)
+                   transposeScatterDecrU(double* base, const std::int32_t offset[], SimdDouble v0, SimdDouble v1, SimdDouble v2)
 {
     if (align % 4 == 0)
     {
@@ -217,64 +201,56 @@ transposeScatterDecrU(double *            base,
         t1 = vec_mergeh(v0.simdInternal_, v1.simdInternal_);
         t2 = vec_mergel(v0.simdInternal_, v1.simdInternal_);
 
-        t3 = simdLoad(base + align * offset[0]);
-        t3.simdInternal_             = vec_sub(t3.simdInternal_, t1);
+        t3               = simdLoad(base + align * offset[0]);
+        t3.simdInternal_ = vec_sub(t3.simdInternal_, t1);
         store(base + align * offset[0], t3);
         base[align * offset[0] + 2] -= vec_extract(v2.simdInternal_, 0);
 
-        t4 = simdLoad(base + align * offset[1]);
-        t4.simdInternal_             = vec_sub(t4.simdInternal_, t2);
+        t4               = simdLoad(base + align * offset[1]);
+        t4.simdInternal_ = vec_sub(t4.simdInternal_, t2);
         store(base + align * offset[1], t4);
         base[align * offset[1] + 2] -= vec_extract(v2.simdInternal_, 1);
     }
 }
 
-static inline void gmx_simdcall
-expandScalarsToTriplets(SimdDouble    scalar,
-                        SimdDouble *  triplets0,
-                        SimdDouble *  triplets1,
-                        SimdDouble *  triplets2)
+static inline void gmx_simdcall expandScalarsToTriplets(SimdDouble  scalar,
+                                                        SimdDouble* triplets0,
+                                                        SimdDouble* triplets1,
+                                                        SimdDouble* triplets2)
 {
     triplets0->simdInternal_ = vec_mergeh(scalar.simdInternal_, scalar.simdInternal_);
     triplets1->simdInternal_ = scalar.simdInternal_;
     triplets2->simdInternal_ = vec_mergel(scalar.simdInternal_, scalar.simdInternal_);
 }
 
-template <int align>
-static inline void gmx_simdcall
-gatherLoadBySimdIntTranspose(const double *  base,
-                             SimdDInt32      offset,
-                             SimdDouble *    v0,
-                             SimdDouble *    v1,
-                             SimdDouble *    v2,
-                             SimdDouble *    v3)
+template<int align>
+static inline void gmx_simdcall gatherLoadBySimdIntTranspose(const double* base,
+                                                             SimdDInt32    offset,
+                                                             SimdDouble*   v0,
+                                                             SimdDouble*   v1,
+                                                             SimdDouble*   v2,
+                                                             SimdDouble*   v3)
 {
     alignas(GMX_SIMD_ALIGNMENT) std::int32_t ioffset[GMX_SIMD_DINT32_WIDTH];
 
-    store(ioffset, offset );
+    store(ioffset, offset);
     gatherLoadTranspose<align>(base, ioffset, v0, v1, v2, v3);
 }
 
-template <int align>
+template<int align>
 static inline void gmx_simdcall
-gatherLoadBySimdIntTranspose(const double *    base,
-                             SimdDInt32        offset,
-                             SimdDouble *      v0,
-                             SimdDouble *      v1)
+                   gatherLoadBySimdIntTranspose(const double* base, SimdDInt32 offset, SimdDouble* v0, SimdDouble* v1)
 {
     alignas(GMX_SIMD_ALIGNMENT) std::int32_t ioffset[GMX_SIMD_DINT32_WIDTH];
 
-    store(ioffset, offset );
+    store(ioffset, offset);
     gatherLoadTranspose<align>(base, ioffset, v0, v1);
 }
 
 
-template <int align>
+template<int align>
 static inline void gmx_simdcall
-gatherLoadUBySimdIntTranspose(const double *  base,
-                              SimdDInt32      offset,
-                              SimdDouble *    v0,
-                              SimdDouble *    v1)
+                   gatherLoadUBySimdIntTranspose(const double* base, SimdDInt32 offset, SimdDouble* v0, SimdDouble* v1)
 {
     alignas(GMX_SIMD_ALIGNMENT) std::int32_t ioffset[GMX_SIMD_DINT32_WIDTH];
 
@@ -287,11 +263,7 @@ gatherLoadUBySimdIntTranspose(const double *  base,
 }
 
 static inline double gmx_simdcall
-reduceIncr4ReturnSum(double *    m,
-                     SimdDouble  v0,
-                     SimdDouble  v1,
-                     SimdDouble  v2,
-                     SimdDouble  v3)
+                     reduceIncr4ReturnSum(double* m, SimdDouble v0, SimdDouble v1, SimdDouble v2, SimdDouble v3)
 {
     __vector double t1, t2, t3, t4;
 
@@ -303,13 +275,13 @@ reduceIncr4ReturnSum(double *    m,
     t1 = vec_add(t1, t2);
     t3 = vec_add(t3, t4);
 
-    *reinterpret_cast<__vector double *>(m)   += t1;
-    *reinterpret_cast<__vector double *>(m+2) += t3;
+    *reinterpret_cast<__vector double*>(m) += t1;
+    *reinterpret_cast<__vector double*>(m + 2) += t3;
 
     t1 = vec_add(t1, t3);
     return reduce(t1);
 }
 
-}      // namespace gmx
+} // namespace gmx
 
 #endif // GMX_SIMD_IMPLEMENTATION_IBM_VSX_UTIL_DOUBLE_H