aboutsummaryrefslogtreecommitdiffhomepage
path: root/tensorflow/core/platform
diff options
context:
space:
mode:
authorGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-31 16:06:58 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-07-31 16:06:58 -0700
commit4f656df0c0897f9f50931824298e4bfc7f757707 (patch)
treecc714d97c038f919d548eaa3c9b07fc1985445f0 /tensorflow/core/platform
parent43a465f93a5f21d5015d3d39e028dc5269585c4a (diff)
parent88baf39926be6969611d793978f0482215278d26 (diff)
Merge pull request #20686 from rongjiecomputer:profile
PiperOrigin-RevId: 206843515
Diffstat (limited to 'tensorflow/core/platform')
-rw-r--r--tensorflow/core/platform/profile_utils/cpu_utils.cc8
-rw-r--r--tensorflow/core/platform/profile_utils/cpu_utils.h7
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));