Gromacs
5.1.5
|
#include "config.h"
#include <stddef.h>
#include "gromacs/utility/basedefinitions.h"
#include "impl_reference/impl_reference.h"
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 defined. The actual implementation - including e.g. conversion operations specifically between single and double - is documented in impl_reference.h.
SIMD memory alignment operations | |
#define | gmx_simd_align_r gmx_simd_align_f |
Align real memory for SIMD usage. More... | |
#define | gmx_simd_align_i gmx_simd_align_fi |
Align integer memory for SIMD usage. More... | |
static float * | gmx_simd_align_f (float *p) |
Align a float pointer for usage with SIMD instructions. More... | |
static double * | gmx_simd_align_d (double *p) |
Align a double pointer for usage with SIMD instructions. More... | |
static int * | gmx_simd_align_fi (int *p) |
Align a (float) integer pointer for usage with SIMD instructions. More... | |
static int * | gmx_simd_align_di (int *p) |
Align a (double) integer pointer for usage with SIMD instructions. More... | |
static float * | gmx_simd4_align_f (float *p) |
Align a float pointer for usage with SIMD4 instructions. More... | |
static double * | gmx_simd4_align_d (double *p) |
Align a double pointer for usage with SIMD4 instructions. More... | |
Macros | |
SIMD predefined macros to describe high-level capabilities | |
#define | GMX_SIMD |
GMX_SIMD indicates that some sort of SIMD support is present in software. More... | |
#define | GMX_SIMD4_WIDTH 4 |
SIMD4 width is always 4, but use this for clarity in definitions. More... | |
#define | GMX_SIMD_HAVE_REAL |
Defined if gmx_simd_real_t is available. More... | |
#define | GMX_SIMD_REAL_WIDTH GMX_SIMD_FLOAT_WIDTH |
Width of gmx_simd_real_t. More... | |
#define | GMX_SIMD_HAVE_INT32 |
Defined if gmx_simd_int32_t is available. More... | |
#define | GMX_SIMD_INT32_WIDTH GMX_SIMD_FINT32_WIDTH |
Width of gmx_simd_int32_t. More... | |
#define | GMX_SIMD_HAVE_INT32_EXTRACT |
Defined if gmx_simd_extract_i() is available. More... | |
#define | GMX_SIMD_HAVE_INT32_LOGICAL |
Defined if logical ops are supported on gmx_simd_int32_t. More... | |
#define | GMX_SIMD_HAVE_INT32_ARITHMETICS |
Defined if arithmetic ops are supported on gmx_simd_int32_t. More... | |
#define | GMX_SIMD4_HAVE_REAL |
Defined if gmx_simd4_real_t is available. More... | |
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. | |
#define | gmx_simd_real_t gmx_simd_float_t |
Real precision floating-point SIMD datatype. More... | |
#define | gmx_simd_int32_t gmx_simd_fint32_t |
32-bit integer SIMD type. More... | |
#define | gmx_simd_bool_t gmx_simd_fbool_t |
Boolean SIMD type for usage with gmx_simd_real_t. More... | |
#define | gmx_simd_ibool_t gmx_simd_fibool_t |
Boolean SIMD type for usage with gmx_simd_int32_t. More... | |
SIMD load/store operations on gmx_simd_real_t | |
| |
#define | gmx_simd_load_r gmx_simd_load_f |
Load GMX_SIMD_REAL_WIDTH values from aligned memory to gmx_simd_real_t. More... | |
#define | gmx_simd_load1_r gmx_simd_load1_f |
Set all elements in gmx_simd_real_t from single value in memory. More... | |
#define | gmx_simd_set1_r gmx_simd_set1_f |
Set all elements in gmx_simd_real_t from a scalar. More... | |
#define | gmx_simd_store_r gmx_simd_store_f |
Store GMX_SIMD_REAL_WIDTH values from gmx_simd_real_t to aligned memory. More... | |
#define | gmx_simd_loadu_r gmx_simd_loadu_f |
Load GMX_SIMD_REAL_WIDTH values from unaligned memory to gmx_simd_real_t. More... | |
#define | gmx_simd_storeu_r gmx_simd_storeu_f |
Store GMX_SIMD_REAL_WIDTH values from gmx_simd_real_t to unaligned memory. More... | |
#define | gmx_simd_setzero_r gmx_simd_setzero_f |
Set all elements in gmx_simd_real_t to 0.0. More... | |
SIMD load/store operations on gmx_simd_int32_t | |
| |
#define | gmx_simd_load_i gmx_simd_load_fi |
Load GMX_SIMD_INT32_WIDTH values from aligned memory to gmx_simd_int32_t . More... | |
#define | gmx_simd_set1_i gmx_simd_set1_fi |
Set all elements in gmx_simd_int32_t from a single integer. More... | |
#define | gmx_simd_store_i gmx_simd_store_fi |
Store GMX_SIMD_REAL_WIDTH values from gmx_simd_int32_t to aligned memory. More... | |
#define | gmx_simd_loadu_i gmx_simd_loadu_fi |
Load GMX_SIMD_REAL_WIDTH values from unaligned memory to gmx_simd_int32_t. More... | |
#define | gmx_simd_storeu_i gmx_simd_storeu_fi |
Store GMX_SIMD_REAL_WIDTH values from gmx_simd_int32_t to unaligned memory. More... | |
#define | gmx_simd_extract_i gmx_simd_extract_fi |
Extract single integer from gmx_simd_int32_t element. More... | |
#define | gmx_simd_setzero_i gmx_simd_setzero_fi |
Set all elements in gmx_simd_int32_t to 0. More... | |
SIMD floating-point logical operations on gmx_simd_real_t | |
These instructions are available if GMX_SIMD_HAVE_LOGICAL is defined. | |
#define | gmx_simd_and_r gmx_simd_and_f |
Bitwise and on two gmx_simd_real_t. More... | |
#define | gmx_simd_andnot_r gmx_simd_andnot_f |
Bitwise and-not on two gmx_simd_real_t; 1st arg is complemented. More... | |
#define | gmx_simd_or_r gmx_simd_or_f |
Bitwise or on two gmx_simd_real_t. More... | |
#define | gmx_simd_xor_r gmx_simd_xor_f |
Bitwise exclusive-or on two gmx_simd_real_t. More... | |
SIMD floating-point arithmetic operations on gmx_simd_real_t | |
#define | gmx_simd_add_r gmx_simd_add_f |
SIMD a+b for two gmx_simd_real_t. More... | |
#define | gmx_simd_sub_r gmx_simd_sub_f |
SIMD a-b for two gmx_simd_real_t. More... | |
#define | gmx_simd_mul_r gmx_simd_mul_f |
SIMD a*b for two gmx_simd_real_t. More... | |
#define | gmx_simd_fmadd_r gmx_simd_fmadd_f |
SIMD a*b+c for three gmx_simd_real_t. More... | |
#define | gmx_simd_fmsub_r gmx_simd_fmsub_f |
SIMD a*b-c for three gmx_simd_real_t. More... | |
#define | gmx_simd_fnmadd_r gmx_simd_fnmadd_f |
SIMD -a*b+c for three gmx_simd_real_t. More... | |
#define | gmx_simd_fnmsub_r gmx_simd_fnmsub_f |
SIMD -a*b-c for three gmx_simd_real_t. More... | |
#define | gmx_simd_rsqrt_r gmx_simd_rsqrt_f |
SIMD table lookup for 1/sqrt(x) approximation. More... | |
#define | gmx_simd_rcp_r gmx_simd_rcp_f |
SIMD table lookup for 1/x approximation. More... | |
#define | gmx_simd_fabs_r gmx_simd_fabs_f |
SIMD fabs(x) for gmx_simd_real_t. More... | |
#define | gmx_simd_fneg_r gmx_simd_fneg_f |
SIMD -x for gmx_simd_real_t. More... | |
#define | gmx_simd_max_r gmx_simd_max_f |
SIMD max(a,b) for each element in gmx_simd_real_t. More... | |
#define | gmx_simd_min_r gmx_simd_min_f |
SIMD min(a,b) for each element in gmx_simd_real_t. More... | |
#define | gmx_simd_round_r gmx_simd_round_f |
Round gmx_simd_real_t to nearest int, return gmx_simd_real_t. More... | |
#define | gmx_simd_trunc_r gmx_simd_trunc_f |
Truncate gmx_simd_real_t towards 0, return gmx_simd_real_t. More... | |
#define | gmx_simd_fraction_r gmx_simd_fraction_f |
SIMD Fraction, i.e. x-trunc(x) for gmx_simd_real_t. More... | |
#define | gmx_simd_get_exponent_r gmx_simd_get_exponent_f |
Return the FP exponent of a SIMD gmx_simd_real_t as a gmx_simd_real_t. More... | |
#define | gmx_simd_get_mantissa_r gmx_simd_get_mantissa_f |
Return the FP mantissa of a SIMD gmx_simd_real_t as a gmx_simd_real_t. More... | |
#define | gmx_simd_set_exponent_r gmx_simd_set_exponent_f |
Set the exponent of a SIMD gmx_simd_real_t from a gmx_simd_real_t. More... | |
SIMD comparison, boolean, and select operations for gmx_simd_real_t | |
#define | gmx_simd_cmpeq_r gmx_simd_cmpeq_f |
SIMD a==b for gmx_simd_real_t. Returns a gmx_simd_bool_t. More... | |
#define | gmx_simd_cmplt_r gmx_simd_cmplt_f |
SIMD a<b for gmx_simd_real_t. Returns a gmx_simd_bool_t. More... | |
#define | gmx_simd_cmple_r gmx_simd_cmple_f |
SIMD a<=b for gmx_simd_real_t. Returns a gmx_simd_bool_t. More... | |
#define | gmx_simd_and_b gmx_simd_and_fb |
For each element, the result boolean is true if both arguments are true. More... | |
#define | gmx_simd_or_b gmx_simd_or_fb |
For each element, the result boolean is true if either argument is true. More... | |
#define | gmx_simd_anytrue_b gmx_simd_anytrue_fb |
Return nonzero if any element in gmx_simd_bool_t is true, otherwise 0. More... | |
#define | gmx_simd_blendzero_r gmx_simd_blendzero_f |
Selects elements from gmx_simd_real_t where boolean is true, otherwise 0. More... | |
#define | gmx_simd_blendnotzero_r gmx_simd_blendnotzero_f |
Selects elements from gmx_simd_real_t where boolean is false, otherwise 0. More... | |
#define | gmx_simd_blendv_r gmx_simd_blendv_f |
Selects from 2nd real SIMD arg where boolean is true, otherwise 1st arg. More... | |
#define | gmx_simd_reduce_r gmx_simd_reduce_f |
Return sum of all elements in SIMD floating-point variable. More... | |
SIMD integer logical operations on gmx_simd_int32_t | |
These instructions are available if GMX_SIMD_HAVE_INT32_LOGICAL is defined. | |
#define | gmx_simd_slli_i gmx_simd_slli_fi |
Shift each element in gmx_simd_int32_t left by immediate. More... | |
#define | gmx_simd_srli_i gmx_simd_srli_fi |
Shift each element in gmx_simd_int32_t right by immediate. More... | |
#define | gmx_simd_and_i gmx_simd_and_fi |
Bitwise and on two gmx_simd_int32_t. More... | |
#define | gmx_simd_andnot_i gmx_simd_andnot_fi |
Bitwise and-not on two gmx_simd_int32_t; 1st arg is complemented. More... | |
#define | gmx_simd_or_i gmx_simd_or_fi |
Bitwise or on two gmx_simd_int32_t. More... | |
#define | gmx_simd_xor_i gmx_simd_xor_fi |
Bitwise xor on two gmx_simd_int32_t. More... | |
SIMD integer arithmetic operations on gmx_simd_int32_t | |
These instructions are available if GMX_SIMD_HAVE_INT32_ARITHMETICS is defined. | |
#define | gmx_simd_add_i gmx_simd_add_fi |
SIMD a+b for two gmx_simd_int32_t. More... | |
#define | gmx_simd_sub_i gmx_simd_sub_fi |
SIMD a-b for two gmx_simd_int32_t. More... | |
#define | gmx_simd_mul_i gmx_simd_mul_fi |
SIMD a*b for two gmx_simd_int32_t. More... | |
SIMD integer comparison, booleans, and selection on gmx_simd_int32_t | |
These instructions are available if GMX_SIMD_HAVE_INT32_ARITHMETICS is defined. | |
#define | gmx_simd_cmpeq_i gmx_simd_cmpeq_fi |
Returns boolean describing whether a==b, for gmx_simd_int32_t. More... | |
#define | gmx_simd_cmplt_i gmx_simd_cmplt_fi |
Returns boolean describing whether a<b, for gmx_simd_int32_t. More... | |
#define | gmx_simd_and_ib gmx_simd_and_fib |
For each element, the result boolean is true if both arguments are true. More... | |
#define | gmx_simd_or_ib gmx_simd_or_fib |
For each element, the result boolean is true if either argument is true. More... | |
#define | gmx_simd_anytrue_ib gmx_simd_anytrue_fib |
Return nonzero if any element in gmx_simd_ibool_t is true, otherwise 0. More... | |
#define | gmx_simd_blendzero_i gmx_simd_blendzero_fi |
Selects elements from gmx_simd_int32_t where boolean is true, otherwise 0. More... | |
#define | gmx_simd_blendnotzero_i gmx_simd_blendnotzero_fi |
Selects elements from gmx_simd_int32_t where boolean is false, otherwise 0. More... | |
#define | gmx_simd_blendv_i gmx_simd_blendv_fi |
Selects from 2nd int SIMD arg where boolean is true, otherwise 1st arg. More... | |
SIMD conversion operations | |
These instructions are available when both types involved in the conversion are defined, e.g. GMX_SIMD_HAVE_REAL and GMX_SIMD_HAVE_INT32 for real-to-integer conversion. | |
#define | gmx_simd_cvt_r2i gmx_simd_cvt_f2i |
Convert gmx_simd_real_t to gmx_simd_int32_t, round to nearest integer. More... | |
#define | gmx_simd_cvtt_r2i gmx_simd_cvtt_f2i |
Convert gmx_simd_real_t to gmx_simd_int32_t, truncate towards zero. More... | |
#define | gmx_simd_cvt_i2r gmx_simd_cvt_i2f |
Convert gmx_simd_int32_t to gmx_simd_real_t. More... | |
#define | gmx_simd_cvt_b2ib gmx_simd_cvt_fb2fib |
Convert from gmx_simd_bool_t to gmx_simd_ibool_t. More... | |
#define | gmx_simd_cvt_ib2b gmx_simd_cvt_fib2fb |
Convert from gmx_simd_ibool_t to gmx_simd_bool_t. More... | |
SIMD4 - constant width-four SIMD datatypes | |
These operations are only meant to be used for a few coordinate manipulation and grid interpolation routines, so we only support a subset of operations for SIMD4. To avoid repeating all the documentation from the generic width SIMD routines, we only provide brief documentation for these operations. Follow the link to the implementation documentation or the reference to the corresponding generic SIMD routine. The format will be exactly the same, but they have SIMD replaced with SIMD4. | |
#define | gmx_simd4_real_t gmx_simd4_float_t |
SIMD real datatype guaranteed to be 4 elements wide, if available. More... | |
#define | gmx_simd4_bool_t gmx_simd4_fbool_t |
Boolean for gmx_simd4_real_t comparision/selection. | |
#define | gmx_simd4_load_r gmx_simd4_load_f |
Load aligned data to gmx_simd4_real_t. More... | |
#define | gmx_simd4_load1_r gmx_simd4_load1_f |
Load single element to gmx_simd4_real_t. More... | |
#define | gmx_simd4_set1_r gmx_simd4_set1_f |
Set gmx_simd4_real_t from scalar value. More... | |
#define | gmx_simd4_store_r gmx_simd4_store_f |
store aligned data from gmx_simd4_real_t More... | |
#define | gmx_simd4_loadu_r gmx_simd4_loadu_f |
Load unaligned data to gmx_simd4_real_t. More... | |
#define | gmx_simd4_storeu_r gmx_simd4_storeu_f |
Store unaligned data from gmx_simd4_real_t. More... | |
#define | gmx_simd4_setzero_r gmx_simd4_setzero_f |
Set all elements in gmx_simd4_real_t to 0.0. More... | |
#define | gmx_simd4_and_r gmx_simd4_and_f |
Bitwise and for two gmx_simd4_real_t. More... | |
#define | gmx_simd4_andnot_r gmx_simd4_andnot_f |
Bitwise and-not for two gmx_simd4_real_t. 1st arg is complemented. More... | |
#define | gmx_simd4_or_r gmx_simd4_or_f |
Bitwise or for two gmx_simd4_real_t. More... | |
#define | gmx_simd4_xor_r gmx_simd4_xor_f |
Bitwise xor for two gmx_simd4_real_t. More... | |
#define | gmx_simd4_add_r gmx_simd4_add_f |
a+b for gmx_simd4_real_t More... | |
#define | gmx_simd4_sub_r gmx_simd4_sub_f |
a-b for gmx_simd4_real_t More... | |
#define | gmx_simd4_mul_r gmx_simd4_mul_f |
a*b for gmx_simd4_real_t More... | |
#define | gmx_simd4_fmadd_r gmx_simd4_fmadd_f |
a*b+c for gmx_simd4_real_t More... | |
#define | gmx_simd4_fmsub_r gmx_simd4_fmsub_f |
a*b-c for gmx_simd4_real_t More... | |
#define | gmx_simd4_fnmadd_r gmx_simd4_fnmadd_f |
-a*b+c for gmx_simd4_real_t More... | |
#define | gmx_simd4_fnmsub_r gmx_simd4_fnmsub_f |
-a*b-c for gmx_simd4_real_t More... | |
#define | gmx_simd4_rsqrt_r gmx_simd4_rsqrt_f |
1/sqrt(x) approximate lookup for gmx_simd4_real_t More... | |
#define | gmx_simd4_fabs_r gmx_simd4_fabs_f |
fabs(x) for gmx_simd4_real_t More... | |
#define | gmx_simd4_fneg_r gmx_simd4_fneg_f |
Change sign (-x) for gmx_simd4_real_t. More... | |
#define | gmx_simd4_max_r gmx_simd4_max_f |
Select maximum of each pair of elements from args for gmx_simd4_real_t. More... | |
#define | gmx_simd4_min_r gmx_simd4_min_f |
Select minimum of each pair of elements from args for gmx_simd4_real_t. More... | |
#define | gmx_simd4_round_r gmx_simd4_round_f |
Round gmx_simd4_real_t to nearest integer, return gmx_simd4_real_t. More... | |
#define | gmx_simd4_trunc_r gmx_simd4_trunc_f |
Truncate gmx_simd4_real_t towards zero, return gmx_simd4_real_t. More... | |
#define | gmx_simd4_dotproduct3_r gmx_simd4_dotproduct3_f |
Scalar product of first three elements of two gmx_simd4_real_t *. More... | |
#define | gmx_simd4_cmpeq_r gmx_simd4_cmpeq_f |
Return booleans whether a==b for each element two gmx_simd4_real_t. More... | |
#define | gmx_simd4_cmplt_r gmx_simd4_cmplt_f |
Return booleans whether a<b for each element two gmx_simd4_real_t. More... | |
#define | gmx_simd4_cmple_r gmx_simd4_cmple_f |
Return booleans whether a<=b for each element two gmx_simd4_real_t. More... | |
#define | gmx_simd4_and_b gmx_simd4_and_fb |
Logical and for two gmx_simd4_bool_t. More... | |
#define | gmx_simd4_or_b gmx_simd4_or_fb |
Logical or for two gmx_simd4_bool_t. More... | |
#define | gmx_simd4_anytrue_b gmx_simd4_anytrue_fb |
Return nonzero if any element in gmx_simd4_bool_t is true, otherwise 0. More... | |
#define | gmx_simd4_blendzero_r gmx_simd4_blendzero_f |
Selects from 2nd real SIMD4 arg where boolean is true, otherwise 1st arg. More... | |
#define | gmx_simd4_blendnotzero_r gmx_simd4_blendnotzero_f |
Selects from 2nd real SIMD4 arg where boolean is false, otherwise 1st arg. More... | |
#define | gmx_simd4_blendv_r gmx_simd4_blendv_f |
Selects from 2nd real SIMD4 arg where boolean is true, otherwise 1st arg. More... | |
#define | gmx_simd4_reduce_r gmx_simd4_reduce_f |
Return sum of all elements in SIMD4 floating-point variable. More... | |
#define | gmx_simd4_align_r gmx_simd4_align_f |
Align real memory for SIMD4 usage. More... | |