/* SPDX-License-Identifier: MIT * * Permission is hereby granted, free of charge, to any person * obtaining a copy of this software and associated documentation * files (the "Software"), to deal in the Software without * restriction, including without limitation the rights to use, copy, * modify, merge, publish, distribute, sublicense, and/or sell copies * of the Software, and to permit persons to whom the Software is * furnished to do so, subject to the following conditions: * * The above copyright notice and this permission notice shall be * included in all copies or substantial portions of the Software. * * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND * NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS * BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN * ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE * SOFTWARE. * * Copyright: * 2017-2020 Evan Nemerson <evan@nemerson.com>
*/
#define SIMDE_VERSION_MAJOR 0 #define SIMDE_VERSION_MINOR 7 #define SIMDE_VERSION_MICRO 6 #define SIMDE_VERSION HEDLEY_VERSION_ENCODE(SIMDE_VERSION_MAJOR, SIMDE_VERSION_MINOR, SIMDE_VERSION_MICRO) // Also update meson.build in the root directory of the repository
/* In some situations, SIMDe has to make large performance sacrifices * for small increases in how faithfully it reproduces an API, but * only a relatively small number of users will actually need the API * to be completely accurate. The SIMDE_FAST_* options can be used to * disable these trade-offs. * * They can be enabled by passing -DSIMDE_FAST_MATH to the compiler, or * the individual defines (e.g., -DSIMDE_FAST_NANS) if you only want to * enable some optimizations. Using -ffast-math and/or * -ffinite-math-only will also enable the relevant options. If you
* don't want that you can pass -DSIMDE_NO_FAST_* to disable them. */
/* Most programs avoid NaNs by never passing values which can result in * a NaN; for example, if you only pass non-negative values to the sqrt * functions, it won't generate a NaN. On some platforms, similar * functions handle NaNs differently; for example, the _mm_min_ps SSE * function will return 0.0 if you pass it (0.0, NaN), but the NEON * vminq_f32 function will return NaN. Making them behave like one * another is expensive; it requires generating a mask of all lanes * with NaNs, then performing the operation (e.g., vminq_f32), then * blending together the result with another vector using the mask. * * If you don't want SIMDe to worry about the differences between how * NaNs are handled on the two platforms, define this (or pass
* -ffinite-math-only) */ #if !defined(SIMDE_FAST_MATH) && !defined(SIMDE_NO_FAST_MATH) && defined(__FAST_MATH__) #define SIMDE_FAST_MATH #endif
/* Many functions are defined as using the current rounding mode * (i.e., the SIMD version of fegetround()) when converting to * an integer. For example, _mm_cvtpd_epi32. Unfortunately, * on some platforms (such as ARMv8+ where round-to-nearest is * always used, regardless of the FPSCR register) this means we * have to first query the current rounding mode, then choose * the proper function (rounnd
, ceil, floor, etc.) */ #if !defined(SIMDE_FAST_ROUND_MODE) && !defined(SIMDE_NO_FAST_ROUND_MODE) && defined(SIMDE_FAST_MATH) #define SIMDE_FAST_ROUND_MODE #endif
/* This controls how ties are rounded. For example, does 10.5 round to * 10 or 11? IEEE 754 specifies round-towards-even, but ARMv7 (for * example) doesn't support it and it must be emulated (which is rather * slow). If you're okay with just using the default for whatever arch * you're on, you should definitely define this. * * Note that we don't use this macro to avoid correct implementations * in functions which are explicitly about rounding (such as vrnd* on * NEON, _mm_round_* on x86, etc.); it is only used for code where * rounding is a component in another function, and even then it isn't * usually a problem since such functions will use the current rounding
* mode. */ #if !defined(SIMDE_FAST_ROUND_TIES) && !defined(SIMDE_NO_FAST_ROUND_TIES) && defined(SIMDE_FAST_MATH) #define SIMDE_FAST_ROUND_TIES #endif
/* For functions which convert from one type to another (mostly from * floating point to integer types), sometimes we need to do a range * check and potentially return a different result if the value * falls outside that range. Skipping this check can provide a * performance boost, at the expense of faithfulness to the API we're
* emulating. */ #if !defined(SIMDE_FAST_CONVERSION_RANGE) && !defined(SIMDE_NO_FAST_CONVERSION_RANGE) && defined(SIMDE_FAST_MATH) #define SIMDE_FAST_CONVERSION_RANGE #endif
/* Due to differences across platforms, sometimes it can be much * faster for us to allow spurious floating point exceptions,
* or to no generate them when we should. */ #if !defined(SIMDE_FAST_EXCEPTIONS) && !defined(SIMDE_NO_FAST_EXCEPTIONS) && defined(SIMDE_FAST_MATH) #define SIMDE_FAST_EXCEPTIONS #endif
/* A copy of HEDLEY_STATIC_ASSERT, except we don't define an empty * fallback if we can't find an implementation; instead we have to
* check if SIMDE_STATIC_ASSERT is defined before using it. */ #if \
!defined(__cplusplus) && ( \
(defined(__STDC_VERSION__) && (__STDC_VERSION__ >= 201112L)) || \
HEDLEY_HAS_FEATURE(c_static_assert) || \
HEDLEY_GCC_VERSION_CHECK(6,0,0) || \
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \ defined(_Static_assert) \
) /* Sometimes _Static_assert is defined (in cdefs.h) using a symbol which * starts with a double-underscore. This is a system header so we have no * control over it, but since it's a macro it will emit a diagnostic which
* prevents compilation with -Werror. */ #if HEDLEY_HAS_WARNING("-Wreserved-identifier") #define SIMDE_STATIC_ASSERT(expr, message) (__extension__({ \
HEDLEY_DIAGNOSTIC_PUSH \
_Pragma("clang diagnostic ignored \"-Wreserved-identifier\"") \
_Static_assert(expr, message); \
HEDLEY_DIAGNOSTIC_POP \
})) #else #define SIMDE_STATIC_ASSERT(expr, message) _Static_assert(expr, message) #endif #elif \
(defined(__cplusplus) && (__cplusplus >= 201103L)) || \
HEDLEY_MSVC_VERSION_CHECK(16,0,0) #define SIMDE_STATIC_ASSERT(expr, message) HEDLEY_DIAGNOSTIC_DISABLE_CPP98_COMPAT_WRAP_(static_assert(expr, message)) #endif
/* This is just a convenience macro to make it easy to call a single
* function with a specific diagnostic disabled. */ #ifdefined(SIMDE_STATEMENT_EXPR_) #define SIMDE_DISABLE_DIAGNOSTIC_EXPR_(diagnostic, expr) \
SIMDE_STATEMENT_EXPR_(({ \
HEDLEY_DIAGNOSTIC_PUSH \
diagnostic \
(expr); \
HEDLEY_DIAGNOSTIC_POP \
})) #endif
#ifdefined(SIMDE_CHECK_CONSTANT_) && defined(SIMDE_STATIC_ASSERT) #define SIMDE_ASSERT_CONSTANT_(v) SIMDE_STATIC_ASSERT(SIMDE_CHECK_CONSTANT_(v), #v" must be constant.") #endif
/* Lots of compilers support GCC-style vector extensions, but many don't support all the features. Define different macros depending on support for
* SIMDE_VECTOR - Declaring a vector. * SIMDE_VECTOR_OPS - basic operations (binary and unary). * SIMDE_VECTOR_NEGATE - negating a vector * SIMDE_VECTOR_SCALAR - For binary operators, the second argument can be a scalar, in which case the result is as if that scalar had been broadcast to all lanes of a vector. * SIMDE_VECTOR_SUBSCRIPT - Supports array subscript notation for extracting/inserting a single element.=
SIMDE_VECTOR can be assumed if any others are defined, the
others are independent. */ #if !defined(SIMDE_NO_VECTOR) # if \
HEDLEY_GCC_VERSION_CHECK(4,8,0) # define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) # define SIMDE_VECTOR_OPS # define SIMDE_VECTOR_NEGATE # define SIMDE_VECTOR_SCALAR # define SIMDE_VECTOR_SUBSCRIPT # elif HEDLEY_INTEL_VERSION_CHECK(16,0,0) # define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) # define SIMDE_VECTOR_OPS # define SIMDE_VECTOR_NEGATE /* ICC only supports SIMDE_VECTOR_SCALAR for constants */ # define SIMDE_VECTOR_SUBSCRIPT # elif \
HEDLEY_GCC_VERSION_CHECK(4,1,0) || \
HEDLEY_INTEL_VERSION_CHECK(13,0,0) || \
HEDLEY_MCST_LCC_VERSION_CHECK(1,25,10) # define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) # define SIMDE_VECTOR_OPS # elif HEDLEY_SUNPRO_VERSION_CHECK(5,12,0) # define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) # elif HEDLEY_HAS_ATTRIBUTE(vector_size) # define SIMDE_VECTOR(size) __attribute__((__vector_size__(size))) # define SIMDE_VECTOR_OPS # define SIMDE_VECTOR_NEGATE # define SIMDE_VECTOR_SUBSCRIPT # if SIMDE_DETECT_CLANG_VERSION_CHECK(5,0,0) # define SIMDE_VECTOR_SCALAR # endif # endif
/* GCC and clang have built-in functions to handle shuffling and converting of vectors, but the implementations are slightly different. This macro is just an abstraction over them. Note that
elem_size is in bits but vec_size is in bytes. */ # if !defined(SIMDE_NO_SHUFFLE_VECTOR) && defined(SIMDE_VECTOR_SUBSCRIPT)
HEDLEY_DIAGNOSTIC_PUSH /* We don't care about -Wvariadic-macros; all compilers that support
* shufflevector/shuffle support them. */ # if HEDLEY_HAS_WARNING("-Wc++98-compat-pedantic") # pragma clang diagnostic ignored "-Wc++98-compat-pedantic" # endif # if HEDLEY_HAS_WARNING("-Wvariadic-macros") || HEDLEY_GCC_VERSION_CHECK(4,0,0) # pragma GCC diagnostic ignored "-Wvariadic-macros" # endif
/* TODO: this actually works on XL C/C++ without SIMDE_VECTOR_SUBSCRIPT
but the code needs to be refactored a bit to take advantage. */ # if !defined(SIMDE_NO_CONVERT_VECTOR) && defined(SIMDE_VECTOR_SUBSCRIPT) # if HEDLEY_HAS_BUILTIN(__builtin_convertvector) || HEDLEY_GCC_VERSION_CHECK(9,0,0) # if HEDLEY_GCC_VERSION_CHECK(9,0,0) && !HEDLEY_GCC_VERSION_CHECK(9,3,0) /* https://gcc.gnu.org/bugzilla/show_bug.cgi?id=93557 */ # define SIMDE_CONVERT_VECTOR_(to, from) ((to) = (__extension__({ \
__typeof__(from) from_ = (from); \
((void) from_); \
__builtin_convertvector(from_, __typeof__(to)); \
}))) # else # define SIMDE_CONVERT_VECTOR_(to, from) ((to) = __builtin_convertvector((from), __typeof__(to))) # endif # endif # endif #endif
/* Since we currently require SUBSCRIPT before using a vector in a union, we define these as dependencies of SUBSCRIPT. They are likely to disappear in the future, once SIMDe learns how to make use of vectors without using the union members. Do not use them in your code unless you're okay with it breaking when SIMDe
changes. */ #ifdefined(SIMDE_VECTOR_SUBSCRIPT) # ifdefined(SIMDE_VECTOR_OPS) # define SIMDE_VECTOR_SUBSCRIPT_OPS # endif # ifdefined(SIMDE_VECTOR_SCALAR) # define SIMDE_VECTOR_SUBSCRIPT_SCALAR # endif #endif
/* Intended for checking coverage, you should never use this in
production. */ #ifdefined(SIMDE_NO_INLINE) # define SIMDE_FUNCTION_ATTRIBUTES HEDLEY_NEVER_INLINE static #else # define SIMDE_FUNCTION_ATTRIBUTES HEDLEY_ALWAYS_INLINE static #endif
#if !defined(SIMDE_NO_STRING_H) #include <string.h> #if !defined(simde_memcpy) #define simde_memcpy(dest, src, n) memcpy(dest, src, n) #endif #if !defined(simde_memset) #define simde_memset(s, c, n) memset(s, c, n) #endif #if !defined(simde_memcmp) #define simde_memcmp(s1, s2, n) memcmp(s1, s2, n) #endif #else /* These are meant to be portable, not fast. If you're hitting them you * should think about providing your own (by defining the simde_memcpy * macro prior to including any SIMDe files) or submitting a patch to * SIMDe so we can detect your system-provided memcpy/memset, like by * adding your compiler to the checks for __builtin_memcpy and/or
* __builtin_memset. */ #if !defined(simde_memcpy)
SIMDE_FUNCTION_ATTRIBUTES void
simde_memcpy_(void* dest, constvoid* src, size_t len) { char* dest_ = HEDLEY_STATIC_CAST(char*, dest); char* src_ = HEDLEY_STATIC_CAST(constchar*, src); for (size_t i = 0 ; i < len ; i++) {
dest_[i] = src_[i];
}
} #define simde_memcpy(dest, src, n) simde_memcpy_(dest, src, n) #endif
#if !defined(simde_memset)
SIMDE_FUNCTION_ATTRIBUTES void
simde_memset_(void* s, int c, size_t len) { char* s_ = HEDLEY_STATIC_CAST(char*, s); char c_ = HEDLEY_STATIC_CAST(char, c); for (size_t i = 0 ; i < len ; i++) {
s_[i] = c_[i];
}
} #define simde_memset(s, c, n) simde_memset_(s, c, n) #endif
#if !defined(simde_memcmp)
SIMDE_FUCTION_ATTRIBUTES int
simde_memcmp_(constvoid *s1, constvoid *s2, size_t n) { unsignedchar* s1_ = HEDLEY_STATIC_CAST(unsignedchar*, s1); unsignedchar* s2_ = HEDLEY_STATIC_CAST(unsignedchar*, s2); for (size_t i = 0 ; i < len ; i++) { if (s1_[i] != s2_[i]) { return (int) (s1_[i] - s2_[i]);
}
} return 0;
} #define simde_memcmp(s1, s2, n) simde_memcmp_(s1, s2, n) #endif #endif #endif
/* GCC/clang have a bunch of functionality in builtins which we would * like to access, but the suffixes indicate whether the operate on * int, long, or long long, not fixed width types (e.g., int32_t). * we use these macros to attempt to map from fixed-width to the * names GCC uses. Note that you should still cast the input(s) and * return values (to/from SIMDE_BUILTIN_TYPE_*_) since often even if * types are the same size they may not be compatible according to the * compiler. For example, on x86 long and long lonsg are generally * both 64 bits, but platforms vary on whether an int64_t is mapped
* to a long or long long. */
/* Sometimes we run into problems with specific versions of compilers which make the native versions unusable for us. Often this is due to missing functions, sometimes buggy implementations, etc. These macros are how we check for specific bugs. As they are fixed we'll
start only defining them for problematic compiler versions. */
/* GCC and Clang both have the same issue: * https://gcc.gnu.org/bugzilla/show_bug.cgi?id=95144 * https://bugs.llvm.org/show_bug.cgi?id=45931 * This is just an easy way to work around it.
*/ #if \
(HEDLEY_HAS_WARNING("-Wsign-conversion") && SIMDE_DETECT_CLANG_VERSION_NOT(11,0,0)) || \
HEDLEY_GCC_VERSION_CHECK(4,3,0) # define SIMDE_BUG_IGNORE_SIGN_CONVERSION(expr) (__extension__ ({ \
HEDLEY_DIAGNOSTIC_PUSH \
_Pragma("GCC diagnostic ignored \"-Wsign-conversion\"") \
__typeof__(expr) simde_bug_ignore_sign_conversion_v_= (expr); \
HEDLEY_DIAGNOSTIC_POP \
simde_bug_ignore_sign_conversion_v_; \
})) #else # define SIMDE_BUG_IGNORE_SIGN_CONVERSION(expr) (expr) #endif
/* Usually the shift count is signed (for example, NEON or SSE). * OTOH, unsigned is good for PPC (vec_srl uses unsigned), and the only option for E2K. * Further info: https://github.com/simd-everywhere/simde/pull/700
*/ #ifdefined(SIMDE_ARCH_E2K) || defined(SIMDE_ARCH_POWER) #define SIMDE_CAST_VECTOR_SHIFT_COUNT(width, value) HEDLEY_STATIC_CAST(uint##width##_t, (value)) #else #define SIMDE_CAST_VECTOR_SHIFT_COUNT(width, value) HEDLEY_STATIC_CAST(int##width##_t, (value)) #endif
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.