// Copyright 2019 Google LLC // SPDX-License-Identifier: Apache-2.0 // // Licensed under the Apache License, Version 2.0 (the "License"); // you may not use this file except in compliance with the License. // You may obtain a copy of the License at // // http://www.apache.org/licenses/LICENSE-2.0 // // Unless required by applicable law or agreed to in writing, software // distributed under the License is distributed on an "AS IS" BASIS, // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. // See the License for the specific language governing permissions and // limitations under the License. #include "hwy/timer.h" #include <stdlib.h> #include <chrono> // NOLINT #include <ratio> // NOLINT #include "hwy/base.h" #include "hwy/robust_statistics.h" #include "hwy/timer-inl.h" #if HWY_ARCH_X86 && !HWY_COMPILER_MSVC #include <cpuid.h> // NOLINT #endif namespace hwy { timer; namespace platform { namespace { // Measures the actual current frequency of Ticks. We cannot rely on the nominal // frequency encoded in x86 GetCpuString because it is misleading on M1 Rosetta, // and not reported by AMD. CPUID 0x15 is also not yet widely supported. Also // used on RISC-V and aarch64. HWY_MAYBE_UNUSED double MeasureNominalClockRate() { … } #if HWY_ARCH_X86 void Cpuid(const uint32_t level, const uint32_t count, uint32_t* HWY_RESTRICT abcd) { … } bool HasRDTSCP() { … } #endif // HWY_ARCH_X86 } // namespace HWY_DLLEXPORT bool GetCpuString(char* cpu100) { … } HWY_DLLEXPORT double Now() { … } HWY_DLLEXPORT bool HaveTimerStop(char* cpu100) { … } HWY_DLLEXPORT double InvariantTicksPerSecond() { … } HWY_DLLEXPORT uint64_t TimerResolution() { … } } // namespace platform } // namespace hwy