From: Magnus Lundborg Date: Thu, 19 Nov 2020 16:49:57 +0000 (+0100) Subject: Added scalar functions cbrt as well as masked Rcp X-Git-Url: http://biod.pnpi.spb.ru/gitweb/?a=commitdiff_plain;h=201eb7dbe95fd006d90a6cce0ec3bfea521d61b4;p=alexxy%2Fgromacs.git Added scalar functions cbrt as well as masked Rcp These functions as useful for nonbonded FE SIMD kernels. --- diff --git a/src/gromacs/simd/scalar/scalar.h b/src/gromacs/simd/scalar/scalar.h index 25f0471a43..6beb22595d 100644 --- a/src/gromacs/simd/scalar/scalar.h +++ b/src/gromacs/simd/scalar/scalar.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017,2018,2019, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2018,2019,2020, 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. @@ -212,6 +212,21 @@ static inline float maskzFma(float a, float b, float c, float m) return m != 0.0F ? (a * b + c) : 0.0F; } +/*! \brief Float 1.0/x, masked version. + * + * \param x Argument, x>0 for entries where mask is true. + * \param m Mask + * \return 1/x. The result for masked-out entries will be 0.0. + * + * \note This function might be superficially meaningless, but it helps us to + * write templated SIMD/non-SIMD code. For clarity it should not be used + * outside such code. + */ +static inline float gmx_simdcall maskzRcp(float x, float m) +{ + return m != 0.0F ? 1.0F / x : 0.0F; +} + /*! \brief Float Floating-point abs(). * * \param a any floating point values @@ -603,6 +618,21 @@ static inline double maskzFma(double a, double b, double c, double m) return m != 0.0 ? (a * b + c) : 0.0; } +/*! \brief Double 1.0/x, masked version. + * + * \param x Argument, x>0 for entries where mask is true. + * \param m Mask + * \return Approximation of 1/x. The result for masked-out entries will be 0.0. + * + * \note This function might be superficially meaningless, but it helps us to + * write templated SIMD/non-SIMD code. For clarity it should not be used + * outside such code. + */ +static inline double gmx_simdcall maskzRcp(double x, double m) +{ + return m != 0.0 ? 1.0 / x : 0.0; +} + /*! \brief double doubleing-point abs(). * * \param a any doubleing point values diff --git a/src/gromacs/simd/scalar/scalar_math.h b/src/gromacs/simd/scalar/scalar_math.h index 246e45b7f2..a523985984 100644 --- a/src/gromacs/simd/scalar/scalar_math.h +++ b/src/gromacs/simd/scalar/scalar_math.h @@ -1,7 +1,7 @@ /* * This file is part of the GROMACS molecular simulation package. * - * Copyright (c) 2016,2017,2019, by the GROMACS development team, led by + * Copyright (c) 2016,2017,2019,2020, 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. @@ -169,6 +169,21 @@ static inline float sqrt(float x) return std::sqrt(x); } +/*! \brief Float cbrt(x). This is the cubic root. + * + * \param x Argument, should be >= 0. + * \result The cubic root of x. Undefined if argument is invalid. + * + * \note This function might be superficially meaningless, but it helps us to + * write templated SIMD/non-SIMD code. For clarity it should not be used + * outside such code. + */ +template +static inline float cbrt(float x) +{ + return std::cbrt(x); +} + /*! \brief Float log(x). This is the natural logarithm. * * \param x Argument, should be >0. @@ -557,6 +572,21 @@ static inline double sqrt(double x) return std::sqrt(x); } +/*! \brief Double cbrt(x). This is the cubic root. + * + * \param x Argument, should be >= 0. + * \result The cubic root of x. Undefined if argument is invalid. + * + * \note This function might be superficially meaningless, but it helps us to + * write templated SIMD/non-SIMD code. For clarity it should not be used + * outside such code. + */ +template +static inline double cbrt(double x) +{ + return std::cbrt(x); +} + /*! \brief Double log(x). This is the natural logarithm. * * \param x Argument, should be >0.