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 15 #ifndef ABSL_CRC_INTERNAL_CPU_DETECT_H_ 16 #define ABSL_CRC_INTERNAL_CPU_DETECT_H_ 17 18 #include "absl/base/config.h" 19 20 namespace absl { 21 ABSL_NAMESPACE_BEGIN 22 namespace crc_internal { 23 24 // Enumeration of architectures that we have special-case tuning parameters for. 25 // This set may change over time. 26 enum class CpuType { 27 kUnknown, 28 kIntelHaswell, 29 kAmdRome, 30 kAmdNaples, 31 kAmdMilan, 32 kIntelCascadelakeXeon, 33 kIntelSkylakeXeon, 34 kIntelBroadwell, 35 kIntelSkylake, 36 kIntelIvybridge, 37 kIntelSandybridge, 38 kIntelWestmere, 39 kArmNeoverseN1, 40 }; 41 42 // Returns the type of host CPU this code is running on. Returns kUnknown if 43 // the host CPU is of unknown type, or if detection otherwise fails. 44 CpuType GetCpuType(); 45 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 53 } // namespace crc_internal 54 ABSL_NAMESPACE_END 55 } // namespace absl 56 57 #endif // ABSL_CRC_INTERNAL_CPU_DETECT_H_ 58