diff options
author | Loo Rong Jie <loorongjie@gmail.com> | 2018-07-11 13:39:35 +0800 |
---|---|---|
committer | Loo Rong Jie <loorongjie@gmail.com> | 2018-07-11 13:39:35 +0800 |
commit | 88baf39926be6969611d793978f0482215278d26 (patch) | |
tree | ebc7b6e983d981ebfcdf6e8f49e4c2e41e44ae75 /tensorflow/core/platform | |
parent | b9827002dc5ab01b183773c4dc5551e04058357a (diff) |
Implement GetCurrentClockCycle and GetCycleCounterFrequencyImpl for Windows
Diffstat (limited to 'tensorflow/core/platform')
-rw-r--r-- | tensorflow/core/platform/profile_utils/cpu_utils.cc | 8 | ||||
-rw-r--r-- | tensorflow/core/platform/profile_utils/cpu_utils.h | 7 |
2 files changed, 15 insertions, 0 deletions
diff --git a/tensorflow/core/platform/profile_utils/cpu_utils.cc b/tensorflow/core/platform/profile_utils/cpu_utils.cc index b0136b52f4..664412565f 100644 --- a/tensorflow/core/platform/profile_utils/cpu_utils.cc +++ b/tensorflow/core/platform/profile_utils/cpu_utils.cc @@ -19,6 +19,10 @@ limitations under the License. #include <limits> #include <mutex> +#if defined(_WIN32) +#include <windows.h> +#endif + #include "tensorflow/core/platform/logging.h" #include "tensorflow/core/platform/profile_utils/android_armv7a_cpu_utils_helper.h" @@ -110,6 +114,10 @@ static ICpuUtilsHelper* cpu_utils_helper_instance_ = nullptr; return INVALID_FREQUENCY; } return freq_hz; +#elif defined(_WIN32) + LARGE_INTEGER freq; + QueryPerformanceFrequency(&freq); + return freq.QuadPart; #else // TODO(satok): Support other OS if needed // Return INVALID_FREQUENCY on unsupported OS diff --git a/tensorflow/core/platform/profile_utils/cpu_utils.h b/tensorflow/core/platform/profile_utils/cpu_utils.h index 7b580c8bf6..8f06290303 100644 --- a/tensorflow/core/platform/profile_utils/cpu_utils.h +++ b/tensorflow/core/platform/profile_utils/cpu_utils.h @@ -28,6 +28,10 @@ limitations under the License. #include <sys/time.h> #endif +#if defined(_WIN32) +#include <intrin.h> +#endif + namespace tensorflow { namespace profile_utils { @@ -55,6 +59,9 @@ class CpuUtils { #if defined(__ANDROID__) return GetCpuUtilsHelperSingletonInstance().GetCurrentClockCycle(); // ---------------------------------------------------------------- +#elif defined(_WIN32) + return __rdtsc(); +// ---------------------------------------------------------------- #elif defined(__x86_64__) || defined(__amd64__) uint64_t high, low; __asm__ volatile("rdtsc" : "=a"(low), "=d"(high)); |