cpu_detect.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  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. kAmdGenoa,
  29. kAmdRyzenV3000,
  30. kIntelCascadelakeXeon,
  31. kIntelSkylakeXeon,
  32. kIntelBroadwell,
  33. kIntelSkylake,
  34. kIntelIvybridge,
  35. kIntelSandybridge,
  36. kIntelWestmere,
  37. kArmNeoverseN1,
  38. kArmNeoverseV1,
  39. kAmpereSiryn,
  40. kArmNeoverseN2,
  41. kArmNeoverseV2
  42. };
  43. // Returns the type of host CPU this code is running on. Returns kUnknown if
  44. // the host CPU is of unknown type, or if detection otherwise fails.
  45. CpuType GetCpuType();
  46. // Returns whether the host CPU supports the CPU features needed for our
  47. // accelerated implementations. The CpuTypes enumerated above apart from
  48. // kUnknown support the required features. On unknown CPUs, we can use
  49. // this to see if it's safe to use hardware acceleration, though without any
  50. // tuning.
  51. bool SupportsArmCRC32PMULL();
  52. } // namespace crc_internal
  53. ABSL_NAMESPACE_END
  54. } // namespace absl
  55. #endif // ABSL_CRC_INTERNAL_CPU_DETECT_H_