isadetection.h 1.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #ifndef ROARING_ISADETECTION_H
  2. #define ROARING_ISADETECTION_H
  3. #if defined(__x86_64__) || defined(_M_AMD64) // x64
  4. #ifndef CROARING_COMPILER_SUPPORTS_AVX512
  5. #ifdef __has_include
  6. // We want to make sure that the AVX-512 functions are only built on compilers
  7. // fully supporting AVX-512.
  8. #if __has_include(<avx512vbmi2intrin.h>)
  9. #define CROARING_COMPILER_SUPPORTS_AVX512 1
  10. #endif // #if __has_include(<avx512vbmi2intrin.h>)
  11. #endif // #ifdef __has_include
  12. // Visual Studio 2019 and up support AVX-512
  13. #ifdef _MSC_VER
  14. #if _MSC_VER >= 1920
  15. #define CROARING_COMPILER_SUPPORTS_AVX512 1
  16. #endif // #if _MSC_VER >= 1920
  17. #endif // #ifdef _MSC_VER
  18. #ifndef CROARING_COMPILER_SUPPORTS_AVX512
  19. #define CROARING_COMPILER_SUPPORTS_AVX512 0
  20. #endif // #ifndef CROARING_COMPILER_SUPPORTS_AVX512
  21. #endif // #ifndef CROARING_COMPILER_SUPPORTS_AVX512
  22. #ifdef __cplusplus
  23. extern "C" {
  24. namespace roaring {
  25. namespace internal {
  26. #endif
  27. enum {
  28. ROARING_SUPPORTS_AVX2 = 1,
  29. ROARING_SUPPORTS_AVX512 = 2,
  30. };
  31. int croaring_hardware_support(void);
  32. #ifdef __cplusplus
  33. }
  34. }
  35. } // extern "C" { namespace roaring { namespace internal {
  36. #endif
  37. #endif // x64
  38. #endif // ROARING_ISADETECTION_H