simd.h 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119
  1. /*
  2. Copyright Charly Chevalier 2015
  3. Copyright Joel Falcou 2015
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. */
  8. #include <boost/predef/hardware/simd/x86.h>
  9. #include <boost/predef/hardware/simd/x86_amd.h>
  10. #include <boost/predef/hardware/simd/arm.h>
  11. #include <boost/predef/hardware/simd/ppc.h>
  12. #ifndef BOOST_PREDEF_HARDWARE_SIMD_H
  13. #define BOOST_PREDEF_HARDWARE_SIMD_H
  14. #include <boost/predef/version_number.h>
  15. /*`
  16. [section Using the `BOOST_HW_SIMD_*` predefs]
  17. [include ../doc/hardware_simd.qbk]
  18. [endsect]
  19. [/ --------------------------- ]
  20. [section `BOOST_HW_SIMD_*`]
  21. [heading `BOOST_HW_SIMD`]
  22. The SIMD extension detected for a specific architectures.
  23. Version number depends on the detected extension.
  24. [table
  25. [[__predef_symbol__] [__predef_version__]]
  26. [[`BOOST_HW_SIMD_X86_AVAILABLE`] [__predef_detection__]]
  27. [[`BOOST_HW_SIMD_X86_AMD_AVAILABLE`] [__predef_detection__]]
  28. [[`BOOST_HW_SIMD_ARM_AVAILABLE`] [__predef_detection__]]
  29. [[`BOOST_HW_SIMD_PPC_AVAILABLE`] [__predef_detection__]]
  30. ]
  31. [include ../include/boost/predef/hardware/simd/x86.h]
  32. [include ../include/boost/predef/hardware/simd/x86_amd.h]
  33. [include ../include/boost/predef/hardware/simd/arm.h]
  34. [include ../include/boost/predef/hardware/simd/ppc.h]
  35. [endsect]
  36. [/ --------------------------- ]
  37. [section `BOOST_HW_SIMD_X86_*_VERSION`]
  38. [include ../include/boost/predef/hardware/simd/x86/versions.h]
  39. [endsect]
  40. [section `BOOST_HW_SIMD_X86_AMD_*_VERSION`]
  41. [include ../include/boost/predef/hardware/simd/x86_amd/versions.h]
  42. [endsect]
  43. [section `BOOST_HW_SIMD_ARM_*_VERSION`]
  44. [include ../include/boost/predef/hardware/simd/arm/versions.h]
  45. [endsect]
  46. [section `BOOST_HW_SIMD_PPC_*_VERSION`]
  47. [include ../include/boost/predef/hardware/simd/ppc/versions.h]
  48. [endsect]
  49. */
  50. // We check if SIMD extension of multiples architectures have been detected,
  51. // if yes, then this is an error!
  52. //
  53. // NOTE: _X86_AMD implies _X86, so there is no need to check for it here!
  54. //
  55. #if defined(BOOST_HW_SIMD_ARM_AVAILABLE) && defined(BOOST_HW_SIMD_PPC_AVAILABLE) ||\
  56. defined(BOOST_HW_SIMD_ARM_AVAILABLE) && defined(BOOST_HW_SIMD_X86_AVAILABLE) ||\
  57. defined(BOOST_HW_SIMD_PPC_AVAILABLE) && defined(BOOST_HW_SIMD_X86_AVAILABLE)
  58. # error "Multiple SIMD architectures detected, this cannot happen!"
  59. #endif
  60. #if defined(BOOST_HW_SIMD_X86_AVAILABLE) && defined(BOOST_HW_SIMD_X86_AMD_AVAILABLE)
  61. // If both standard _X86 and _X86_AMD are available,
  62. // then take the biggest version of the two!
  63. # if BOOST_HW_SIMD_X86 >= BOOST_HW_SIMD_X86_AMD
  64. # define BOOST_HW_SIMD BOOST_HW_SIMD_X86
  65. # else
  66. # define BOOST_HW_SIMD BOOST_HW_SIMD_X86_AMD
  67. # endif
  68. #endif
  69. #if !defined(BOOST_HW_SIMD)
  70. // At this point, only one of these two is defined
  71. # if defined(BOOST_HW_SIMD_X86_AVAILABLE)
  72. # define BOOST_HW_SIMD BOOST_HW_SIMD_X86
  73. # endif
  74. # if defined(BOOST_HW_SIMD_X86_AMD_AVAILABLE)
  75. # define BOOST_HW_SIMD BOOST_HW_SIMD_X86_AMD
  76. # endif
  77. #endif
  78. #if defined(BOOST_HW_SIMD_ARM_AVAILABLE)
  79. # define BOOST_HW_SIMD BOOST_HW_SIMD_ARM
  80. #endif
  81. #if defined(BOOST_HW_SIMD_PPC_AVAILABLE)
  82. # define BOOST_HW_SIMD BOOST_HW_SIMD_PPC
  83. #endif
  84. #if defined(BOOST_HW_SIMD)
  85. # define BOOST_HW_SIMD_AVAILABLE
  86. #else
  87. # define BOOST_HW_SIMD BOOST_VERSION_NUMBER_NOT_AVAILABLE
  88. #endif
  89. #define BOOST_HW_SIMD_NAME "Hardware SIMD"
  90. #endif
  91. #include <boost/predef/detail/test.h>
  92. BOOST_PREDEF_DECLARE_TEST(BOOST_HW_SIMD, BOOST_HW_SIMD_NAME)