Skip to content

Commit

Permalink
removed the XXH_X86DISPATCH_ALLOW_AVX build variable
Browse files Browse the repository at this point in the history
if the program is compiled with, for example, -mavx2,
then the resulting binary will simply require this instruction set to run.
  • Loading branch information
Cyan4973 committed Dec 27, 2024
1 parent 5a8de81 commit 5c6dd83
Showing 1 changed file with 3 additions and 31 deletions.
34 changes: 3 additions & 31 deletions xxh_x86dispatch.c
Original file line number Diff line number Diff line change
Expand Up @@ -40,9 +40,9 @@
*
* Optional add-on.
*
* **Compile this file with the default flags for your target.** Do not compile
* with flags like `-mavx*`, `-march=native`, or `/arch:AVX*`, there will be
* an error. See @ref XXH_X86DISPATCH_ALLOW_AVX for details.
* **Compile this file with the default flags for your target.**
* Note that compiling with flags like `-mavx*`, `-march=native`, or `/arch:AVX*`
* will make the resulting binary incompatible with cpus not supporting the requested instruction set.
*
* @defgroup dispatch x86 Dispatcher
* @{
Expand Down Expand Up @@ -70,34 +70,6 @@ extern "C" {
#endif
/*! @endcond */

/*!
* @def XXH_X86DISPATCH_ALLOW_AVX
* @brief Disables the AVX sanity check.
*
* xxh_x86dispatch.c is intended to be compiled for the minimum target, and
* it selectively enables SSE2, AVX2, and AVX512 when it is needed.
*
* Compiling with options like `-mavx*`, `-march=native`, or `/arch:AVX*`
* _globally_ will always enable this feature, and therefore makes it
* undefined behavior to execute on any CPU without said feature.
*
* Even if the source code isn't directly using AVX intrinsics in a function,
* the compiler can still generate AVX code from autovectorization and by
* "upgrading" SSE2 intrinsics to use the VEX prefixes (a.k.a. AVX128).
*
* Define XXH_X86DISPATCH_ALLOW_AVX to ignore this check,
* thus accepting that the produced binary will not work correctly
* on any CPU with less features than the ones stated at compilation time.
*/
#ifdef XXH_DOXYGEN
# define XXH_X86DISPATCH_ALLOW_AVX
#endif

#if defined(__AVX__) && !defined(XXH_X86DISPATCH_ALLOW_AVX)
# error "Error: if xxh_x86dispatch.c is compiled with AVX enabled, the resulting binary will crash on sse2-only cpus !! " \
"If you nonetheless want to do that, please enable the XXH_X86DISPATCH_ALLOW_AVX build variable"
#endif

/*!
* @def XXH_DISPATCH_SCALAR
* @brief Enables/dispatching the scalar code path.
Expand Down

0 comments on commit 5c6dd83

Please sign in to comment.