Gromacs  2022.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Classes | Typedefs | Functions
#include "config.h"
#include <cstddef>
#include <cstdint>
#include <array>
#include <memory>
#include <type_traits>
#include "gromacs/utility/basedefinitions.h"
#include "gromacs/utility/real.h"
#include "impl_reference/impl_reference.h"
#include "gromacs/simd/scalar/scalar.h"
#include "gromacs/simd/scalar/scalar_math.h"
#include "gromacs/simd/scalar/scalar_util.h"
#include "gromacs/simd/simd_memory.h"
+ Include dependency graph for simd.h:
+ This graph shows which files directly or indirectly include this file:

Description

Definitions, capabilities, and wrappers for SIMD module.

The macros in this file are intended to be used for writing architecture-independent SIMD intrinsics code. To support a new architecture, adding a new sub-include with macros here should be (nearly) all that is needed.

The defines in this top-level file will set default Gromacs real precision operations to either single or double precision based on whether GMX_DOUBLE is 1. The actual implementation - including e.g. conversion operations specifically between single and double - is documented in impl_reference.h.

Author
Erik Lindahl erik..nosp@m.lind.nosp@m.ahl@s.nosp@m.cili.nosp@m.felab.nosp@m..se

SIMD data types

The actual storage of these types is implementation dependent. The documentation is generated from the reference implementation, but for normal usage this will likely not be what you are using.

typedef SimdFloat gmx::SimdReal
 Real precision floating-point SIMD datatype. More...
 
typedef SimdFBool gmx::SimdBool
 Boolean SIMD type for usage with SimdReal. More...
 
typedef SimdFInt32 gmx::SimdInt32
 32-bit integer SIMD type. More...
 
typedef SimdFIBool gmx::SimdIBool
 Boolean SIMD type for usage with SimdInt32. More...
 
typedef Simd4Float gmx::Simd4Real
 Real precision floating-point SIMD4 datatype. More...
 
typedef Simd4FBool gmx::Simd4Bool
 Boolean SIMD4 type for usage with SimdReal. More...
 
const int gmx::c_simdBestPairAlignment = c_simdBestPairAlignmentFloat
 

High-level SIMD proxy objects to disambiguate load/set operations

#define GMX_SIMD_HAVE_4NSIMD_UTIL_FLOAT   GMX_SIMD_HAVE_LOADU
 
#define GMX_SIMD4N_FLOAT_WIDTH   GMX_SIMD_FLOAT_WIDTH
 
#define GMX_SIMD_HAVE_4NSIMD_UTIL_DOUBLE   GMX_SIMD_HAVE_LOADU
 
#define GMX_SIMD4N_DOUBLE_WIDTH   GMX_SIMD_DOUBLE_WIDTH
 
#define GMX_SIMD_HAVE_4NSIMD_UTIL_REAL   GMX_SIMD_HAVE_4NSIMD_UTIL_FLOAT
 
#define GMX_SIMD4N_REAL_WIDTH   GMX_SIMD4N_FLOAT_WIDTH
 
using gmx::Simd4NFloat = SimdFloat
 
using gmx::Simd4NDouble = SimdDouble
 
using gmx::Simd4NReal = Simd4NFloat
 
template<typename T >
static std::remove_const_t< T > gmx::load (const internal::SimdTraitsT< T > *m)
 Load function that returns SIMD or scalar. More...
 
template<typename T >
static T gmx::load (const std::enable_if_t< std::is_arithmetic_v< T >, T > *m)
 
template<typename T , size_t N>
static T gmx_simdcall gmx::load (const AlignedArray< internal::SimdTraitsT< T >, N > &m)
 
template<typename T >
static T gmx::loadU (const internal::SimdTraitsT< T > *m)
 Load function that returns SIMD or scalar based on template argument. More...
 
template<typename T >
static T gmx::loadU (const std::enable_if_t< std::is_arithmetic_v< T >, T > *m)
 
template<typename T , size_t N>
static T gmx_simdcall gmx::loadU (const AlignedArray< internal::SimdTraitsT< T >, N > &m)
 
static SimdSetZeroProxy
gmx_simdcall 
gmx::setZero ()
 Helper function to set any SIMD or scalar variable to zero. More...
 
template<typename T >
gmx::load (const internal::Simd4TraitsT< T > *m)
 
template<typename T >
gmx::loadU (const internal::Simd4TraitsT< T > *m)
 
static Simd4NFloat gmx_simdcall gmx::loadUNDuplicate4 (const float *f)
 
static Simd4NFloat gmx_simdcall gmx::load4DuplicateN (const float *f)
 
static Simd4NFloat gmx_simdcall gmx::loadU4NOffset (const float *f, int)
 
static Simd4NDouble gmx_simdcall gmx::loadUNDuplicate4 (const double *f)
 
static Simd4NDouble gmx_simdcall gmx::load4DuplicateN (const double *f)
 
static Simd4NDouble gmx_simdcall gmx::loadU4NOffset (const double *f, int)
 

Classes

struct  gmx::SimdFloatTag
 Tag type to select to load SimdFloat with simdLoad(U) More...
 
struct  gmx::SimdDoubleTag
 Tag type to select to load SimdDouble with simdLoad(U) More...
 
struct  gmx::SimdFInt32Tag
 Tag type to select to load SimdFInt32 with simdLoad(U) More...
 
struct  gmx::SimdDInt32Tag
 Tag type to select to load SimdDInt32 with simdLoad(U) More...
 
struct  gmx::AlignedArray< float, N >
 Identical to std::array with GMX_SIMD_FLOAT_WIDTH alignment. Should not be deleted through base pointer (destructor is non-virtual). More...
 
struct  gmx::AlignedArray< double, N >
 Identical to std::array with GMX_SIMD_DOUBLE_WIDTH alignment. Should not be deleted through base pointer (destructor is non-virtual). More...
 
struct  gmx::internal::SimdTraits< T >
 Simd traits. More...
 
class  gmx::SimdSetZeroProxy
 Proxy object to enable setZero() for SIMD and real types. More...
 

Macros

SIMD predefined macros to describe high-level capabilities

These macros are used to describe the features available in default Gromacs real precision. They are set from the lower-level implementation files that have macros describing single and double precision individually, as well as the implementation details.

#define GMX_SIMD_HAVE_REAL   GMX_SIMD_HAVE_FLOAT
 1 if SimdReal is available, otherwise 0. More...
 
#define GMX_SIMD_REAL_WIDTH   GMX_SIMD_FLOAT_WIDTH
 Width of SimdReal. More...
 
#define GMX_SIMD_HAVE_INT32_EXTRACT   GMX_SIMD_HAVE_FINT32_EXTRACT
 1 if support is available for extracting elements from SimdInt32, otherwise 0 More...
 
#define GMX_SIMD_HAVE_INT32_LOGICAL   GMX_SIMD_HAVE_FINT32_LOGICAL
 1 if logical ops are supported on SimdInt32, otherwise 0. More...
 
#define GMX_SIMD_HAVE_INT32_ARITHMETICS   GMX_SIMD_HAVE_FINT32_ARITHMETICS
 1 if arithmetic ops are supported on SimdInt32, otherwise 0. More...
 
#define GMX_SIMD_HAVE_GATHER_LOADU_BYSIMDINT_TRANSPOSE_REAL   GMX_SIMD_HAVE_GATHER_LOADU_BYSIMDINT_TRANSPOSE_FLOAT
 1 if gmx::simdGatherLoadUBySimdIntTranspose is present, otherwise 0 More...
 
#define GMX_SIMD_HAVE_HSIMD_UTIL_REAL   GMX_SIMD_HAVE_HSIMD_UTIL_FLOAT
 1 if real half-register load/store/reduce utils present, otherwise 0 More...
 
#define GMX_SIMD4_HAVE_REAL   GMX_SIMD4_HAVE_FLOAT
 1 if Simd4Real is available, otherwise 0. More...
 

Typedefs

template<typename T >
using gmx::internal::SimdTraitsT = typename SimdTraits< T >::type
 
template<typename T >
using gmx::internal::Simd4TraitsT = typename Simd4Traits< T >::type
 

Functions

static bool isSimdAligned (const float *ptr)
 end of condition libapi More...
 
static bool isSimdAligned (const double *ptr)
 Returns whether a pointer to double is aligned to a SIMD boundary. More...
 

Function Documentation

static bool isSimdAligned ( const float *  ptr)
inlinestatic

end of condition libapi

Returns whether a pointer to float is aligned to a SIMD boundary

Parameters
[in]ptrA pointer to a float
static bool isSimdAligned ( const double *  ptr)
inlinestatic

Returns whether a pointer to double is aligned to a SIMD boundary.

Parameters
[in]ptrA pointer to a double