From 4aa12a8965660afa940dc27286ad0a90cca6f8fb Mon Sep 17 00:00:00 2001 From: Charly Chevalier Date: Mon, 20 Jul 2015 11:02:21 +0200 Subject: [PATCH] Refactor x86 (AMD) SIMD detection + Add _VERSION(s) for x86 (AMD) family --- include/boost/predef/hardware/simd/x86_amd.h | 76 +++++++++++++++++++ .../predef/hardware/simd/x86_amd/versions.h | 48 ++++++++++++ 2 files changed, 124 insertions(+) create mode 100644 include/boost/predef/hardware/simd/x86_amd.h create mode 100644 include/boost/predef/hardware/simd/x86_amd/versions.h diff --git a/include/boost/predef/hardware/simd/x86_amd.h b/include/boost/predef/hardware/simd/x86_amd.h new file mode 100644 index 0000000..7fea531 --- /dev/null +++ b/include/boost/predef/hardware/simd/x86_amd.h @@ -0,0 +1,76 @@ +/* +Copyright Charly Chevalier 2015 +Copyright Joel Falcou 2015 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) +*/ + +#ifndef BOOST_PREDEF_HARDWARE_SIMD_X86_AMD_H +#define BOOST_PREDEF_HARDWARE_SIMD_X86_AMD_H + +#include +#include +#include + +/*` + [heading `BOOST_HW_SIMD_X86_AMD`] + + The SIMD extension for x86 (AMD) (if detected). + Version number depends on the most recent detected extension. + + [note This predef includes every other x86 SIMD extensions and also has other + more specific extensions (FMA4, XOP, SSE4a). You should use this predef + instead of `BOOST_HW_SIMD_X86` to test if those specific extensions have + been detected.] + + [table + [[__predef_symbol__] [__predef_version__]] + + [[`__SSE4A__`] [BOOST_HW_SIMD_x86_SSE4A_VERSION]] + + [[`__FMA4__`] [BOOST_HW_SIMD_x86_FMA4_VERSION]] + + [[`__XOP__`] [BOOST_HW_SIMD_x86_XOP_VERSION]] + + [[`BOOST_HW_SIMD_X86`] [BOOST_HW_SIMD_x86]] + ] + + [include x86_amd/versions.h] + */ + +#define BOOST_HW_SIMD_X86_AMD BOOST_VERSION_NUMBER_NOT_AVAILABLE + +// AMD CPUs also use x86 architecture. We first try to detect if any AMD +// specific extension are detected, if yes, then try to detect more recent x86 +// common extensions. + +#undef BOOST_HW_SIMD_X86_AMD +#if !defined(BOOST_HW_SIMD_X86_AMD) && defined(__SSE4A__) +# define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86_AMD_SSE4A_VERSION +#endif +#if !defined(BOOST_HW_SIMD_X86_AMD) && defined(__FMA4__) +# define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86_AMD_FMA4_VERSION +#endif +#if !defined(BOOST_HW_SIMD_X86_AMD) && defined(__XOP__) +# define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86_AMD_XOP_VERSION +#endif + +#if !defined(BOOST_HW_SIMD_X86_AMD) +# define BOOST_HW_SIMD_X86_AMD BOOST_VERSION_NUMBER_NOT_AVAILABLE +#else + // At this point, we know that we have an AMD CPU, we do need to check for + // other x86 extensions to determine the final version number. +# include +# if BOOST_HW_SIMD_X86 > BOOST_HW_SIMD_X86_AMD +# undef BOOST_HW_SIMD_X86_AMD +# define BOOST_HW_SIMD_X86_AMD BOOST_HW_SIMD_X86 +# endif +#endif + +#define BOOST_HW_SIMD_X86_AMD_NAME "x86 (AMD) SIMD" + +#endif + +#include +BOOST_PREDEF_DECLARE_TEST(BOOST_HW_SIMD_X86_AMD, BOOST_HW_SIMD_X86_AMD_NAME) diff --git a/include/boost/predef/hardware/simd/x86_amd/versions.h b/include/boost/predef/hardware/simd/x86_amd/versions.h new file mode 100644 index 0000000..4e430b5 --- /dev/null +++ b/include/boost/predef/hardware/simd/x86_amd/versions.h @@ -0,0 +1,48 @@ +/* +Copyright Charly Chevalier 2015 +Copyright Joel Falcou 2015 +Distributed under the Boost Software License, Version 1.0. +(See accompanying file LICENSE_1_0.txt or copy at +http://www.boost.org/LICENSE_1_0.txt) +*/ + +#ifndef BOOST_PREDEF_HARDWARE_SIMD_X86_AMD_VERSIONS_H +#define BOOST_PREDEF_HARDWARE_SIMD_X86_AMD_VERSIONS_H + +#include + +/*` + [heading `BOOST_HW_SIMD_X86_AMD_*_VERSION`] + + [note Those defines represent x86 (AMD specific) SIMD extensions versions. You + can compare them with the predef BOOST_HW_SIMD_X86_AMD.] + */ + +// --------------------------------- + +/*` + [heading `BOOST_HW_SIMD_X86_SSE4A`] + + [@https://en.wikipedia.org/wiki/SSE4##SSE4A SSE4A] x86 extension (AMD specific). + Version number is: 4.0.0. + */ +#define BOOST_HW_SIMD_x86_AMD_SSE4A_VERSION BOOST_VERSION_NUMBER(4, 0, 0) + +/*` + [heading `BOOST_HW_SIMD_X86_XOP`] + + [@https://en.wikipedia.org/wiki/XOP_instruction_set XOP] x86 extension (AMD specific). + Version number is: 5.1.1. + */ +#define BOOST_HW_SIMD_x86_AMD_FMA4_VERSION BOOST_VERSION_NUMBER(5, 1, 0) + +/*` + [heading `BOOST_HW_SIMD_X86_XOP`] + + [@https://en.wikipedia.org/wiki/XOP_instruction_set XOP] x86 extension (AMD specific). + Version number is: 5.1.1. + */ +#define BOOST_HW_SIMD_x86_AMD_XOP_VERSION BOOST_VERSION_NUMBER(5, 1, 1) + + +#endif