Implemented tensorflow::port::NominalCPUFrequency()

PiperOrigin-RevId: 174041196
This commit is contained in:
Benoit Steiner 2017-10-31 08:44:48 -07:00 committed by TensorFlower Gardener
parent c2ff8a5abf
commit 0d118e4dca
4 changed files with 25 additions and 3 deletions

View File

@ -26,6 +26,7 @@ NSYNC_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/nsync/.*tar\.
PROTOBUF_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/protobuf/.*tar\.gz' "${BZL_FILE_PATH}" | head -n1)"
RE2_URL="$(grep -o 'https://mirror.bazel.build/github.com/google/re2/.*tar\.gz' "${BZL_FILE_PATH}" | head -n1)"
FFT2D_URL="$(grep -o 'http.*fft\.tgz' "${BZL_FILE_PATH}" | grep -v bazel-mirror | head -n1)"
ABSL_URL="$(grep -o 'https://github.com/abseil/abseil-cpp/.*tar.gz' "${BZL_FILE_PATH}" | head -n1)"
# TODO(petewarden): Some new code in Eigen triggers a clang bug with iOS arm64,
# so work around it by patching the source.
@ -73,6 +74,7 @@ download_and_extract "${NSYNC_URL}" "${DOWNLOADS_DIR}/nsync"
download_and_extract "${PROTOBUF_URL}" "${DOWNLOADS_DIR}/protobuf"
download_and_extract "${RE2_URL}" "${DOWNLOADS_DIR}/re2"
download_and_extract "${FFT2D_URL}" "${DOWNLOADS_DIR}/fft2d"
download_and_extract "${ABSL_URL}" "${DOWNLOADS_DIR}/absl"
replace_by_sed 's#static uint32x4_t p4ui_CONJ_XOR = vld1q_u32( conj_XOR_DATA );#static uint32x4_t p4ui_CONJ_XOR; // = vld1q_u32( conj_XOR_DATA ); - Removed by script#' \
"${DOWNLOADS_DIR}/eigen/Eigen/src/Core/arch/NEON/Complex.h"

View File

@ -436,14 +436,16 @@ def tf_kernel_tests_linkstatic():
return 0
def tf_additional_lib_defines():
"""Additional defines needed to build TF libraries."""
return select({
"//tensorflow:with_jemalloc_linux_x86_64": ["TENSORFLOW_USE_JEMALLOC"],
"//tensorflow:with_jemalloc_linux_ppc64le":["TENSORFLOW_USE_JEMALLOC"],
"//conditions:default": [],
})
}) + if_not_mobile(["TENSORFLOW_USE_ABSL"])
def tf_additional_lib_deps():
return if_static(
"""Additional dependencies needed to build TF libraries."""
return if_not_mobile(["@com_google_absl//absl/base:base"]) + if_static(
["@nsync//:nsync_cpp"],
["@nsync//:nsync_headers"]
) + select({

View File

@ -17,11 +17,16 @@ limitations under the License.
#include "jemalloc/jemalloc.h"
#endif
#ifdef TENSORFLOW_USE_ABSL
#include "absl/base/internal/sysinfo.h"
#endif
#include "tensorflow/core/platform/cpu_info.h"
#include "tensorflow/core/platform/logging.h"
#include "tensorflow/core/platform/mem.h"
#include "tensorflow/core/platform/snappy.h"
#include "tensorflow/core/platform/types.h"
#if defined(__linux__) && !defined(__ANDROID__)
#include <sched.h>
#endif
@ -157,8 +162,11 @@ bool Snappy_Uncompress(const char* input, size_t length, char* output) {
string Demangle(const char* mangled) { return mangled; }
double NominalCPUFrequency() {
// TODO(yuefengz): implement it for this platform.
#ifdef TENSORFLOW_USE_ABSL
return absl::base_internal::NominalCPUFrequency();
#else
return 1.0;
#endif
}
} // namespace port

View File

@ -181,6 +181,16 @@ def tf_workspace(path_prefix="", tf_repo_name=""):
build_file = str(Label("//third_party/mkl_dnn:mkldnn.BUILD")),
)
native.http_archive(
name = "com_google_absl",
urls = [
"https://mirror.bazel.build/github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
"https://github.com/abseil/abseil-cpp/archive/cc4bed2d74f7c8717e31f9579214ab52a9c9c610.tar.gz",
],
sha256 = "f1a7349f88d2846210c42e2f7271dabeee404c2a3b4198e34a797993e3569b03",
strip_prefix = "abseil-cpp-cc4bed2d74f7c8717e31f9579214ab52a9c9c610",
)
native.new_http_archive(
name = "eigen_archive",
urls = [