cpu_detect.h 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. // Copyright 2022 The Abseil Authors
  2. //
  3. // Licensed under the Apache License, Version 2.0 (the "License");
  4. // you may not use this file except in compliance with the License.
  5. // You may obtain a copy of the License at
  6. //
  7. // https://www.apache.org/licenses/LICENSE-2.0
  8. //
  9. // Unless required by applicable law or agreed to in writing, software
  10. // distributed under the License is distributed on an "AS IS" BASIS,
  11. // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  12. // See the License for the specific language governing permissions and
  13. // limitations under the License.
  14. #ifndef ABSL_CRC_INTERNAL_CPU_DETECT_H_
  15. #define ABSL_CRC_INTERNAL_CPU_DETECT_H_
  16. #include "absl/base/config.h"
  17. namespace absl {
  18. ABSL_NAMESPACE_BEGIN
  19. namespace crc_internal {
  20. // Enumeration of architectures that we have special-case tuning parameters for.
  21. // This set may change over time.
  22. enum class CpuType {
  23. kUnknown,
  24. kIntelHaswell,
  25. kAmdRome,
  26. kAmdNaples,
  27. kAmdMilan,
  28. kIntelCascadelakeXeon,
  29. kIntelSkylakeXeon,
  30. kIntelBroadwell,
  31. kIntelSkylake,
  32. kIntelIvybridge,
  33. kIntelSandybridge,
  34. kIntelWestmere,
  35. kArmNeoverseN1,
  36. };
  37. // Returns the type of host CPU this code is running on. Returns kUnknown if
  38. // the host CPU is of unknown type, or if detection otherwise fails.
  39. CpuType GetCpuType();
  40. // Returns whether the host CPU supports the CPU features needed for our
  41. // accelerated implementations. The CpuTypes enumerated above apart from
  42. // kUnknown support the required features. On unknown CPUs, we can use
  43. // this to see if it's safe to use hardware acceleration, though without any
  44. // tuning.
  45. bool SupportsArmCRC32PMULL();
  46. } // namespace crc_internal
  47. ABSL_NAMESPACE_END
  48. } // namespace absl
  49. #endif // ABSL_CRC_INTERNAL_CPU_DETECT_H_