aboutsummaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorGravatar Ayush Dubey <ayushd@google.com>2018-10-01 15:26:59 -0700
committerGravatar TensorFlower Gardener <gardener@tensorflow.org>2018-10-01 15:33:13 -0700
commit52574f95279d8cd5ec22cfc24668b9586e41367a (patch)
tree3de4c1f67b52dce3131dac2cbb21af768d25ff12
parentcca204f12a5838f0ffdd4a80c27d451cf61d3636 (diff)
Remove jemalloc build files and dead configuration options.
PiperOrigin-RevId: 215291195
-rw-r--r--configure.py2
-rw-r--r--tensorflow/BUILD39
-rw-r--r--tensorflow/contrib/cmake/CMakeLists.txt11
-rw-r--r--tensorflow/contrib/cmake/external/jemalloc.cmake50
-rw-r--r--tensorflow/core/platform/default/build_config.bzl20
-rw-r--r--tensorflow/core/platform/posix/port.cc36
-rw-r--r--tensorflow/core/platform/windows/port.cc51
-rw-r--r--tensorflow/tools/lib_package/BUILD16
-rw-r--r--tensorflow/tools/pip_package/BUILD8
-rwxr-xr-xtensorflow/workspace.bzl12
-rw-r--r--third_party/jemalloc.BUILD356
-rw-r--r--third_party/systemlibs/jemalloc.BUILD30
-rw-r--r--third_party/systemlibs/syslibs_configure.bzl1
-rw-r--r--tools/bazel.rc1
14 files changed, 11 insertions, 622 deletions
diff --git a/configure.py b/configure.py
index 57d9574d1f..0efa11aa41 100644
--- a/configure.py
+++ b/configure.py
@@ -1493,7 +1493,6 @@ def main():
setup_python(environ_cp)
if is_windows():
- environ_cp['TF_NEED_JEMALLOC'] = '0'
environ_cp['TF_NEED_OPENCL_SYCL'] = '0'
environ_cp['TF_NEED_COMPUTECPP'] = '0'
environ_cp['TF_NEED_OPENCL'] = '0'
@@ -1507,7 +1506,6 @@ def main():
environ_cp['TF_SET_ANDROID_WORKSPACE'] = '0'
if is_macos():
- environ_cp['TF_NEED_JEMALLOC'] = '0'
environ_cp['TF_NEED_TENSORRT'] = '0'
environ_cp['TF_ENABLE_XLA'] = '0'
diff --git a/tensorflow/BUILD b/tensorflow/BUILD
index 4876b51a6f..9b62a50452 100644
--- a/tensorflow/BUILD
+++ b/tensorflow/BUILD
@@ -203,21 +203,6 @@ config_setting(
visibility = ["//visibility:public"],
)
-# TODO(jhseu): Enable on other platforms other than Linux.
-config_setting(
- name = "with_jemalloc_linux_x86_64",
- define_values = {"with_jemalloc": "true"},
- values = {"cpu": "k8"},
- visibility = ["//visibility:public"],
-)
-
-config_setting(
- name = "with_jemalloc_linux_ppc64le",
- define_values = {"with_jemalloc": "true"},
- values = {"cpu": "ppc"},
- visibility = ["//visibility:public"],
-)
-
config_setting(
name = "with_default_optimizations",
define_values = {"with_default_optimizations": "true"},
@@ -266,30 +251,6 @@ config_setting(
)
config_setting(
- name = "with_jemalloc_linux_x86_64_dynamic",
- define_values = {
- "with_jemalloc": "true",
- "framework_shared_object": "true",
- },
- values = {
- "cpu": "k8",
- },
- visibility = ["//visibility:public"],
-)
-
-config_setting(
- name = "with_jemalloc_linux_ppc64le_dynamic",
- define_values = {
- "with_jemalloc": "true",
- "framework_shared_object": "true",
- },
- values = {
- "cpu": "ppc",
- },
- visibility = ["//visibility:public"],
-)
-
-config_setting(
name = "using_cuda_clang",
define_values = {
"using_cuda_clang": "true",
diff --git a/tensorflow/contrib/cmake/CMakeLists.txt b/tensorflow/contrib/cmake/CMakeLists.txt
index c6d6f04168..f675c135f4 100644
--- a/tensorflow/contrib/cmake/CMakeLists.txt
+++ b/tensorflow/contrib/cmake/CMakeLists.txt
@@ -30,7 +30,6 @@ endif()
option(tensorflow_ENABLE_GRPC_SUPPORT "Enable gRPC support" ON)
option(tensorflow_ENABLE_HDFS_SUPPORT "Enable HDFS support" OFF)
-option(tensorflow_ENABLE_JEMALLOC_SUPPORT "Enable jemalloc support" OFF)
option(tensorflow_BUILD_CC_EXAMPLE "Build the C++ tutorial example" ON)
option(tensorflow_BUILD_PYTHON_BINDINGS "Build the Python bindings" ON)
option(tensorflow_BUILD_ALL_KERNELS "Build all OpKernels" ON)
@@ -218,10 +217,6 @@ if (tensorflow_WIN_CPU_SIMD_OPTIONS)
endif()
endif()
-if (tensorflow_ENABLE_JEMALLOC_SUPPORT)
- add_definitions(-DTENSORFLOW_USE_JEMALLOC -DJEMALLOC_EXPORT=)
-endif()
-
# External dependencies
include(zlib)
include(gif)
@@ -329,12 +324,6 @@ if(tensorflow_ENABLE_GRPC_SUPPORT)
list(APPEND tensorflow_EXTERNAL_DEPENDENCIES boringssl)
endif()
endif()
-if(tensorflow_ENABLE_JEMALLOC_SUPPORT)
- include(jemalloc)
- list(APPEND tensorflow_EXTERNAL_LIBRARIES ${jemalloc_STATIC_LIBRARIES})
- list(APPEND tensorflow_EXTERNAL_DEPENDENCIES jemalloc)
- include_directories(${jemalloc_INCLUDE_DIRS})
-endif()
if(tensorflow_ENABLE_SNAPPY_SUPPORT)
include(snappy)
list(APPEND tensorflow_EXTERNAL_LIBRARIES ${snappy_STATIC_LIBRARIES})
diff --git a/tensorflow/contrib/cmake/external/jemalloc.cmake b/tensorflow/contrib/cmake/external/jemalloc.cmake
deleted file mode 100644
index afadcc007d..0000000000
--- a/tensorflow/contrib/cmake/external/jemalloc.cmake
+++ /dev/null
@@ -1,50 +0,0 @@
-# Copyright 2017 The TensorFlow Authors. All Rights Reserved.
-#
-# 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 (ExternalProject)
-
-set(jemalloc_INCLUDE_DIRS ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/src/jemalloc/include)
-set(jemalloc_URL https://mirror.bazel.build/github.com/jemalloc/jemalloc-cmake/archive/jemalloc-cmake.4.3.1.tar.gz)
-set(jemalloc_HASH SHA256=f9be9a05fe906deb5c1c8ca818071a7d2e27d66fd87f5ba9a7bf3750bcedeaf0)
-set(jemalloc_BUILD ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/src/jemalloc)
-
-if (WIN32)
- set(jemalloc_INCLUDE_DIRS
- ${jemalloc_INCLUDE_DIRS}
- ${CMAKE_CURRENT_BINARY_DIR}/jemalloc/src/jemalloc/include/msvc_compat
- )
- if(${CMAKE_GENERATOR} MATCHES "Visual Studio.*")
- set(jemalloc_STATIC_LIBRARIES ${jemalloc_BUILD}/Release/jemalloc.lib)
- else()
- set(jemalloc_STATIC_LIBRARIES ${jemalloc_BUILD}/jemalloc.lib)
- endif()
-else()
- set(jemalloc_STATIC_LIBRARIES ${jemalloc_BUILD}/Release/jemalloc.a)
-endif()
-
-ExternalProject_Add(jemalloc
- PREFIX jemalloc
- URL ${jemalloc_URL}
- URL_HASH ${jemalloc_HASH}
- DOWNLOAD_DIR "${DOWNLOAD_LOCATION}"
- BUILD_IN_SOURCE 1
- BUILD_BYPRODUCTS ${jemalloc_STATIC_LIBRARIES}
- BUILD_COMMAND ${CMAKE_COMMAND} --build . --config Release --target jemalloc
- INSTALL_COMMAND ${CMAKE_COMMAND} -E echo "Skipping install step."
- CMAKE_CACHE_ARGS
- -DCMAKE_BUILD_TYPE:STRING=Release
- -DCMAKE_VERBOSE_MAKEFILE:BOOL=OFF
- -Dwith-jemalloc-prefix:STRING=jemalloc_
- -Dwithout-export:BOOL=ON
-)
diff --git a/tensorflow/core/platform/default/build_config.bzl b/tensorflow/core/platform/default/build_config.bzl
index 3b14757945..d884c1aa7c 100644
--- a/tensorflow/core/platform/default/build_config.bzl
+++ b/tensorflow/core/platform/default/build_config.bzl
@@ -615,11 +615,7 @@ def tf_kernel_tests_linkstatic():
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": [],
- })
+ return []
def tf_additional_lib_deps():
"""Additional dependencies needed to build TF libraries."""
@@ -631,13 +627,7 @@ def tf_additional_lib_deps():
] + if_static(
["@nsync//:nsync_cpp"],
["@nsync//:nsync_headers"],
- ) + select({
- "//tensorflow:with_jemalloc_linux_x86_64_dynamic": ["@jemalloc//:jemalloc_headers"],
- "//tensorflow:with_jemalloc_linux_ppc64le_dynamic": ["@jemalloc//:jemalloc_headers"],
- "//tensorflow:with_jemalloc_linux_x86_64": ["@jemalloc//:jemalloc_impl"],
- "//tensorflow:with_jemalloc_linux_ppc64le": ["@jemalloc//:jemalloc_impl"],
- "//conditions:default": [],
- })
+ )
def tf_additional_core_deps():
return select({
@@ -725,11 +715,7 @@ def tf_additional_binary_deps():
"//tensorflow/stream_executor:cuda_platform",
"//tensorflow/core/platform/default/build_config:cuda",
],
- ) + select({
- "//tensorflow:with_jemalloc_linux_x86_64": ["@jemalloc//:jemalloc_impl"],
- "//tensorflow:with_jemalloc_linux_ppc64le": ["@jemalloc//:jemalloc_impl"],
- "//conditions:default": [],
- }) + [
+ ) + [
# TODO(allenl): Split these out into their own shared objects (they are
# here because they are shared between contrib/ op shared objects and
# core).
diff --git a/tensorflow/core/platform/posix/port.cc b/tensorflow/core/platform/posix/port.cc
index b46b9927cd..acdd7798ea 100644
--- a/tensorflow/core/platform/posix/port.cc
+++ b/tensorflow/core/platform/posix/port.cc
@@ -13,10 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
-#ifdef TENSORFLOW_USE_JEMALLOC
-#include "jemalloc/jemalloc.h"
-#endif
-
#include "absl/base/internal/sysinfo.h"
#include "tensorflow/core/platform/cpu_info.h"
@@ -101,11 +97,7 @@ void* AlignedMalloc(size_t size, int minimum_alignment) {
// memory aligned to at least the size of a pointer.
const int required_alignment = sizeof(void*);
if (minimum_alignment < required_alignment) return Malloc(size);
-#ifdef TENSORFLOW_USE_JEMALLOC
- int err = jemalloc_posix_memalign(&ptr, minimum_alignment, size);
-#else
int err = posix_memalign(&ptr, minimum_alignment, size);
-#endif
if (err != 0) {
return nullptr;
} else {
@@ -116,29 +108,11 @@ void* AlignedMalloc(size_t size, int minimum_alignment) {
void AlignedFree(void* aligned_memory) { Free(aligned_memory); }
-void* Malloc(size_t size) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- return jemalloc_malloc(size);
-#else
- return malloc(size);
-#endif
-}
+void* Malloc(size_t size) { return malloc(size); }
-void* Realloc(void* ptr, size_t size) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- return jemalloc_realloc(ptr, size);
-#else
- return realloc(ptr, size);
-#endif
-}
+void* Realloc(void* ptr, size_t size) { return realloc(ptr, size); }
-void Free(void* ptr) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- jemalloc_free(ptr);
-#else
- free(ptr);
-#endif
-}
+void Free(void* ptr) { free(ptr); }
void* NUMAMalloc(int node, size_t size, int minimum_alignment) {
return AlignedMalloc(size, minimum_alignment);
@@ -146,9 +120,7 @@ void* NUMAMalloc(int node, size_t size, int minimum_alignment) {
void NUMAFree(void* ptr, size_t size) { Free(ptr); }
-int NUMAGetMemAffinity(const void* addr) {
- return kNUMANoAffinity;
-}
+int NUMAGetMemAffinity(const void* addr) { return kNUMANoAffinity; }
void MallocExtension_ReleaseToSystem(std::size_t num_bytes) {
// No-op.
diff --git a/tensorflow/core/platform/windows/port.cc b/tensorflow/core/platform/windows/port.cc
index 5375f56372..911ea1902f 100644
--- a/tensorflow/core/platform/windows/port.cc
+++ b/tensorflow/core/platform/windows/port.cc
@@ -13,10 +13,6 @@ See the License for the specific language governing permissions and
limitations under the License.
==============================================================================*/
-#ifdef TENSORFLOW_USE_JEMALLOC
-#include "jemalloc/jemalloc.h"
-#endif
-
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
@@ -70,55 +66,16 @@ void NUMASetThreadNodeAffinity(int node) {}
int NUMAGetThreadNodeAffinity() { return kNUMANoAffinity; }
void* AlignedMalloc(size_t size, int minimum_alignment) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- void* ptr = NULL;
- // posix_memalign requires that the requested alignment be at least
- // sizeof(void*). In this case, fall back on malloc which should return
- // memory aligned to at least the size of a pointer.
- const int required_alignment = sizeof(void*);
- if (minimum_alignment < required_alignment) return Malloc(size);
- int err = jemalloc_posix_memalign(&ptr, minimum_alignment, size);
- if (err != 0) {
- return NULL;
- } else {
- return ptr;
- }
-#else
return _aligned_malloc(size, minimum_alignment);
-#endif
}
-void AlignedFree(void* aligned_memory) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- jemalloc_free(aligned_memory);
-#else
- _aligned_free(aligned_memory);
-#endif
-}
+void AlignedFree(void* aligned_memory) { _aligned_free(aligned_memory); }
-void* Malloc(size_t size) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- return jemalloc_malloc(size);
-#else
- return malloc(size);
-#endif
-}
+void* Malloc(size_t size) { return malloc(size); }
-void* Realloc(void* ptr, size_t size) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- return jemalloc_realloc(ptr, size);
-#else
- return realloc(ptr, size);
-#endif
-}
+void* Realloc(void* ptr, size_t size) { return realloc(ptr, size); }
-void Free(void* ptr) {
-#ifdef TENSORFLOW_USE_JEMALLOC
- return jemalloc_free(ptr);
-#else
- return free(ptr);
-#endif
-}
+void Free(void* ptr) { return free(ptr); }
void* NUMAMalloc(int node, size_t size, int minimum_alignment) {
return AlignedMalloc(size, minimum_alignment);
diff --git a/tensorflow/tools/lib_package/BUILD b/tensorflow/tools/lib_package/BUILD
index b9f4902639..85514b8629 100644
--- a/tensorflow/tools/lib_package/BUILD
+++ b/tensorflow/tools/lib_package/BUILD
@@ -137,14 +137,6 @@ genrule(
"@snappy//:COPYING",
"@zlib_archive//:zlib.h",
] + select({
- "//tensorflow:with_jemalloc_linux_x86_64": [
- "@jemalloc//:COPYING",
- ],
- "//tensorflow:with_jemalloc_linux_ppc64le": [
- "@jemalloc//:COPYING",
- ],
- "//conditions:default": [],
- }) + select({
"//tensorflow/core/kernels:xsmm": [
"@libxsmm_archive//:LICENSE.md",
],
@@ -202,14 +194,6 @@ genrule(
"@snappy//:COPYING",
"@zlib_archive//:zlib.h",
] + select({
- "//tensorflow:with_jemalloc_linux_x86_64": [
- "@jemalloc//:COPYING",
- ],
- "//tensorflow:with_jemalloc_linux_ppc64le": [
- "@jemalloc//:COPYING",
- ],
- "//conditions:default": [],
- }) + select({
"//tensorflow/core/kernels:xsmm": [
"@libxsmm_archive//:LICENSE.md",
],
diff --git a/tensorflow/tools/pip_package/BUILD b/tensorflow/tools/pip_package/BUILD
index c621812535..3a1c4a45d4 100644
--- a/tensorflow/tools/pip_package/BUILD
+++ b/tensorflow/tools/pip_package/BUILD
@@ -167,14 +167,6 @@ filegroup(
"@zlib_archive//:zlib.h",
"@org_python_pypi_backports_weakref//:LICENSE",
] + select({
- "//tensorflow:with_jemalloc_linux_x86_64": [
- "@jemalloc//:COPYING",
- ],
- "//tensorflow:with_jemalloc_linux_ppc64le": [
- "@jemalloc//:COPYING",
- ],
- "//conditions:default": [],
- }) + select({
"//tensorflow/core/kernels:xsmm": [
"@libxsmm_archive//:LICENSE.md",
],
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index 9b4b698874..bcc89ef729 100755
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -642,18 +642,6 @@ def tf_workspace(path_prefix = "", tf_repo_name = ""):
testonly_ = True,
)
- tf_http_archive(
- name = "jemalloc",
- build_file = clean_dep("//third_party:jemalloc.BUILD"),
- sha256 = "3c8f25c02e806c3ce0ab5fb7da1817f89fc9732709024e2a81b6b82f7cc792a8",
- strip_prefix = "jemalloc-4.4.0",
- system_build_file = clean_dep("//third_party/systemlibs:jemalloc.BUILD"),
- urls = [
- "https://mirror.bazel.build/github.com/jemalloc/jemalloc/archive/4.4.0.tar.gz",
- "https://github.com/jemalloc/jemalloc/archive/4.4.0.tar.gz",
- ],
- )
-
java_import_external(
name = "com_google_testing_compile",
jar_sha256 = "edc180fdcd9f740240da1a7a45673f46f59c5578d8cd3fbc912161f74b5aebb8",
diff --git a/third_party/jemalloc.BUILD b/third_party/jemalloc.BUILD
deleted file mode 100644
index 1b0829b8fe..0000000000
--- a/third_party/jemalloc.BUILD
+++ /dev/null
@@ -1,356 +0,0 @@
-# Description:
-# jemalloc - a general-purpose scalable concurrent malloc implementation
-
-licenses(["notice"]) # BSD
-
-exports_files(["COPYING"])
-
-load("@org_tensorflow//third_party:common.bzl", "template_rule")
-
-cc_library(
- name = "jemalloc_headers",
- hdrs = ["include/jemalloc/jemalloc.h"],
- includes = ["include"],
- visibility = ["//visibility:public"],
-)
-
-cc_library(
- name = "jemalloc_impl",
- srcs = [
- "src/arena.c",
- "src/atomic.c",
- "src/base.c",
- "src/bitmap.c",
- "src/chunk.c",
- "src/chunk_dss.c",
- "src/chunk_mmap.c",
- "src/ckh.c",
- "src/ctl.c",
- "src/extent.c",
- "src/hash.c",
- "src/huge.c",
- "src/jemalloc.c",
- "src/mb.c",
- "src/mutex.c",
- "src/nstime.c",
- "src/pages.c",
- "src/prng.c",
- "src/prof.c",
- "src/quarantine.c",
- "src/rtree.c",
- "src/spin.c",
- "src/stats.c",
- "src/tcache.c",
- "src/tsd.c",
- "src/util.c",
- "src/witness.c",
- ],
- hdrs = [
- "include/jemalloc/internal/arena.h",
- "include/jemalloc/internal/assert.h",
- "include/jemalloc/internal/atomic.h",
- "include/jemalloc/internal/base.h",
- "include/jemalloc/internal/bitmap.h",
- "include/jemalloc/internal/chunk.h",
- "include/jemalloc/internal/chunk_dss.h",
- "include/jemalloc/internal/chunk_mmap.h",
- "include/jemalloc/internal/ckh.h",
- "include/jemalloc/internal/ctl.h",
- "include/jemalloc/internal/extent.h",
- "include/jemalloc/internal/hash.h",
- "include/jemalloc/internal/huge.h",
- "include/jemalloc/internal/jemalloc_internal.h",
- "include/jemalloc/internal/jemalloc_internal_decls.h",
- "include/jemalloc/internal/jemalloc_internal_defs.h",
- "include/jemalloc/internal/jemalloc_internal_macros.h",
- "include/jemalloc/internal/mb.h",
- "include/jemalloc/internal/mutex.h",
- "include/jemalloc/internal/nstime.h",
- "include/jemalloc/internal/pages.h",
- "include/jemalloc/internal/ph.h",
- "include/jemalloc/internal/private_namespace.h",
- "include/jemalloc/internal/prng.h",
- "include/jemalloc/internal/prof.h",
- "include/jemalloc/internal/ql.h",
- "include/jemalloc/internal/qr.h",
- "include/jemalloc/internal/quarantine.h",
- "include/jemalloc/internal/rb.h",
- "include/jemalloc/internal/rtree.h",
- "include/jemalloc/internal/size_classes.h",
- "include/jemalloc/internal/smoothstep.h",
- "include/jemalloc/internal/spin.h",
- "include/jemalloc/internal/stats.h",
- "include/jemalloc/internal/tcache.h",
- "include/jemalloc/internal/ticker.h",
- "include/jemalloc/internal/tsd.h",
- "include/jemalloc/internal/util.h",
- "include/jemalloc/internal/valgrind.h",
- "include/jemalloc/internal/witness.h",
- ],
- # Same flags that jemalloc uses to build.
- copts = [
- "-O3",
- "-funroll-loops",
- "-D_GNU_SOURCE",
- "-D_REENTRANT",
- ],
- includes = ["include"],
- # pthread_atfork() is called for PPC.
- linkopts = select({
- "@org_tensorflow//tensorflow:linux_ppc64le": [
- "-lpthread",
- ],
- "@org_tensorflow//tensorflow:linux_x86_64": [
- "-lpthread",
- ],
- "//conditions:default": [
- ],
- }),
- visibility = ["//visibility:public"],
- deps = [":jemalloc_headers"],
-)
-
-sh_binary(
- name = "jemalloc_sh",
- srcs = ["include/jemalloc/jemalloc.sh"],
-)
-
-genrule(
- name = "jemalloc_h",
- srcs = [
- ":jemalloc_defs_h",
- ":jemalloc_macros_h",
- ":jemalloc_mangle_h",
- ":jemalloc_protos_h",
- ":jemalloc_rename_h",
- ":jemalloc_typedefs_h",
- ],
- outs = ["include/jemalloc/jemalloc.h"],
- cmd = "$(location :jemalloc_sh) $$(dirname $(location :jemalloc_defs_h))/../../ >$@",
- tools = [":jemalloc_sh"],
-)
-
-# Add to this list if you want to export more symbols from jemalloc.
-genrule(
- name = "public_symbols_txt",
- outs = ["include/jemalloc/internal/public_symbols.txt"],
- cmd = "\n".join([
- "cat <<'EOF' > $@",
- "free:jemalloc_free",
- "malloc:jemalloc_malloc",
- "posix_memalign:jemalloc_posix_memalign",
- "realloc:jemalloc_realloc",
- "EOF",
- ]),
-)
-
-sh_binary(
- name = "jemalloc_mangle_sh",
- srcs = ["include/jemalloc/jemalloc_mangle.sh"],
-)
-
-genrule(
- name = "jemalloc_mangle_h",
- srcs = [":public_symbols_txt"],
- outs = ["include/jemalloc/jemalloc_mangle.h"],
- cmd = "$(location :jemalloc_mangle_sh) $(location :public_symbols_txt) je_ >$@",
- tools = [":jemalloc_mangle_sh"],
-)
-
-sh_binary(
- name = "jemalloc_rename_sh",
- srcs = ["include/jemalloc/jemalloc_rename.sh"],
-)
-
-genrule(
- name = "jemalloc_rename_h",
- srcs = [":public_symbols_txt"],
- outs = ["include/jemalloc/jemalloc_rename.h"],
- cmd = "$(location :jemalloc_rename_sh) $(location :public_symbols_txt) >$@",
- tools = [":jemalloc_rename_sh"],
-)
-
-sh_binary(
- name = "private_namespace_sh",
- srcs = ["include/jemalloc/internal/private_namespace.sh"],
-)
-
-genrule(
- name = "private_namespace_h",
- srcs = ["include/jemalloc/internal/private_symbols.txt"],
- outs = ["include/jemalloc/internal/private_namespace.h"],
- cmd = "$(location :private_namespace_sh) $(location include/jemalloc/internal/private_symbols.txt) >$@",
- tools = [":private_namespace_sh"],
-)
-
-sh_binary(
- name = "public_namespace_sh",
- srcs = ["include/jemalloc/internal/public_namespace.sh"],
-)
-
-genrule(
- name = "public_namespace_h",
- srcs = [":public_symbols_txt"],
- outs = ["include/jemalloc/internal/public_namespace.h"],
- cmd = "$(location :public_namespace_sh) $(location :public_symbols_txt) >$@",
- tools = [":public_namespace_sh"],
-)
-
-sh_binary(
- name = "size_classes_sh",
- srcs = ["include/jemalloc/internal/size_classes.sh"],
-)
-
-# Size classes for Linux x86_64 and ppc64le. Update if adding builds for other
-# architectures. See size_classes.sh for details on the arguments.
-# For default case, kept the arguments same as that of x86_64 for now.
-genrule(
- name = "size_classes_h",
- outs = ["include/jemalloc/internal/size_classes.h"],
- cmd = select({
- "@org_tensorflow//tensorflow:linux_ppc64le": "$(location :size_classes_sh) \"3 4\" 3 16 2 >$@",
- "@org_tensorflow//tensorflow:linux_x86_64": "$(location :size_classes_sh) \"3 4\" 3 12 2 >$@",
- "//conditions:default": "$(location :size_classes_sh) \"3 4\" 3 12 2 >$@",
- }),
- tools = [":size_classes_sh"],
-)
-
-template_rule(
- name = "jemalloc_internal_h",
- src = "include/jemalloc/internal/jemalloc_internal.h.in",
- out = "include/jemalloc/internal/jemalloc_internal.h",
- substitutions = {
- "@private_namespace@": "je_",
- "@install_suffix@": "",
- },
-)
-
-template_rule(
- name = "jemalloc_internal_defs_h",
- src = "include/jemalloc/internal/jemalloc_internal_defs.h.in",
- out = "include/jemalloc/internal/jemalloc_internal_defs.h",
- substitutions = {
- "#undef JEMALLOC_PREFIX": "#define JEMALLOC_PREFIX \"jemalloc_\"",
- "#undef JEMALLOC_CPREFIX": "#define JEMALLOC_CPREFIX \"JEMALLOC_\"",
- "#undef JEMALLOC_PRIVATE_NAMESPACE": "#define JEMALLOC_PRIVATE_NAMESPACE je_",
- "#undef CPU_SPINWAIT": "\n".join([
- "#if defined(__powerpc64__) || defined(__powerpc__)",
- "#define CPU_SPINWAIT __asm__ volatile(\"or 27,27,27\")",
- "#else",
- "#define CPU_SPINWAIT __asm__ volatile(\"pause\")",
- "#endif",
- ]),
- "#undef JEMALLOC_HAVE_BUILTIN_CLZ": "#define JEMALLOC_HAVE_BUILTIN_CLZ",
- "#undef JEMALLOC_USE_SYSCALL": "#define JEMALLOC_USE_SYSCALL",
- "#undef JEMALLOC_HAVE_SECURE_GETENV": "#define JEMALLOC_HAVE_SECURE_GETENV",
- "#undef JEMALLOC_HAVE_PTHREAD_ATFORK": "#define JEMALLOC_HAVE_PTHREAD_ATFORK",
- "#undef JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE": "#define JEMALLOC_HAVE_CLOCK_MONOTONIC_COARSE 1",
- # Newline required because of substitution conflicts.
- "#undef JEMALLOC_HAVE_CLOCK_MONOTONIC\n": "#define JEMALLOC_HAVE_CLOCK_MONOTONIC 1\n",
- "#undef JEMALLOC_THREADED_INIT": "#define JEMALLOC_THREADED_INIT",
- "#undef JEMALLOC_TLS_MODEL": "#define JEMALLOC_TLS_MODEL __attribute__((tls_model(\"initial-exec\")))",
- "#undef JEMALLOC_CC_SILENCE": "#define JEMALLOC_CC_SILENCE",
- "#undef JEMALLOC_STATS": "#define JEMALLOC_STATS",
- "#undef JEMALLOC_TCACHE": "#define JEMALLOC_TCACHE",
- "#undef JEMALLOC_DSS": "#define JEMALLOC_DSS",
- "#undef JEMALLOC_FILL": "#define JEMALLOC_FILL",
- "#undef LG_TINY_MIN": "#define LG_TINY_MIN 3",
- "#undef LG_PAGE": "\n".join([
- "#if defined(__powerpc64__) || defined(__powerpc__)",
- "#define LG_PAGE 16",
- "#else",
- "#define LG_PAGE 12",
- "#endif",
- ]),
- "#undef JEMALLOC_MAPS_COALESCE": "#define JEMALLOC_MAPS_COALESCE",
- "#undef JEMALLOC_TLS": "#define JEMALLOC_TLS",
- "#undef JEMALLOC_INTERNAL_UNREACHABLE": "#define JEMALLOC_INTERNAL_UNREACHABLE __builtin_unreachable",
- "#undef JEMALLOC_INTERNAL_FFSLL": "#define JEMALLOC_INTERNAL_FFSLL __builtin_ffsll",
- # Newline required because of substitution conflicts.
- "#undef JEMALLOC_INTERNAL_FFSL\n": "#define JEMALLOC_INTERNAL_FFSL __builtin_ffsl\n",
- "#undef JEMALLOC_INTERNAL_FFS\n": "#define JEMALLOC_INTERNAL_FFS __builtin_ffs\n",
- "#undef JEMALLOC_CACHE_OBLIVIOUS": "#define JEMALLOC_CACHE_OBLIVIOUS",
- "#undef JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY": "#define JEMALLOC_PROC_SYS_VM_OVERCOMMIT_MEMORY",
- "#undef JEMALLOC_HAVE_MADVISE": "#define JEMALLOC_HAVE_MADVISE",
- "#undef JEMALLOC_PURGE_MADVISE_DONTNEED": "#define JEMALLOC_PURGE_MADVISE_DONTNEED",
- "#undef JEMALLOC_THP": "#define JEMALLOC_THP",
- "#undef JEMALLOC_HAS_ALLOCA_H": "#define JEMALLOC_HAS_ALLOCA_H 1",
- # Newline required because of substitution conflicts.
- "#undef LG_SIZEOF_INT\n": "#define LG_SIZEOF_INT 2\n",
- "#undef LG_SIZEOF_LONG\n": "#define LG_SIZEOF_LONG 3\n",
- "#undef LG_SIZEOF_LONG_LONG": "#define LG_SIZEOF_LONG_LONG 3",
- "#undef LG_SIZEOF_INTMAX_T": "#define LG_SIZEOF_INTMAX_T 3",
- "#undef JEMALLOC_GLIBC_MALLOC_HOOK": "#define JEMALLOC_GLIBC_MALLOC_HOOK",
- "#undef JEMALLOC_GLIBC_MEMALIGN_HOOK": "#define JEMALLOC_GLIBC_MEMALIGN_HOOK",
- "#undef JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP": "#define JEMALLOC_HAVE_PTHREAD_MUTEX_ADAPTIVE_NP",
- "#undef JEMALLOC_CONFIG_MALLOC_CONF": "#define JEMALLOC_CONFIG_MALLOC_CONF \"\"",
- },
-)
-
-template_rule(
- name = "jemalloc_defs_h",
- src = "include/jemalloc/jemalloc_defs.h.in",
- out = "include/jemalloc/jemalloc_defs.h",
- substitutions = {
- "#undef JEMALLOC_HAVE_ATTR": "#define JEMALLOC_HAVE_ATTR",
- "#undef JEMALLOC_HAVE_ATTR_ALLOC_SIZE": "#define JEMALLOC_HAVE_ATTR_ALLOC_SIZE",
- "#undef JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF": "#define JEMALLOC_HAVE_ATTR_FORMAT_GNU_PRINTF",
- "#undef JEMALLOC_HAVE_ATTR_FORMAT_PRINTF": "#define JEMALLOC_HAVE_ATTR_FORMAT_PRINTF",
- "#undef JEMALLOC_OVERRIDE_MEMALIGN": "#define JEMALLOC_OVERRIDE_MEMALIGN",
- "#undef JEMALLOC_OVERRIDE_VALLOC": "#define JEMALLOC_OVERRIDE_VALLOC",
- "#undef JEMALLOC_USABLE_SIZE_CONST": "#define JEMALLOC_USABLE_SIZE_CONST",
- "#undef JEMALLOC_USE_CXX_THROW": "#define JEMALLOC_USE_CXX_THROW",
- "#undef LG_SIZEOF_PTR": "#define LG_SIZEOF_PTR 3",
- },
-)
-
-template_rule(
- name = "jemalloc_macros_h",
- src = "include/jemalloc/jemalloc_macros.h.in",
- out = "include/jemalloc/jemalloc_macros.h",
- substitutions = {
- "@jemalloc_version@": "0.0.0",
- "@jemalloc_version_major@": "0",
- "@jemalloc_version_minor@": "0",
- "@jemalloc_version_bugfix@": "0",
- "@jemalloc_version_nrev@": "0",
- "@jemalloc_version_gid@": "0000000000000000000000000000000000000000",
- },
-)
-
-template_rule(
- name = "jemalloc_protos_h",
- src = "include/jemalloc/jemalloc_protos.h.in",
- out = "include/jemalloc/jemalloc_protos.h",
- substitutions = {
- "@aligned_alloc": "aligned_alloc",
- "@calloc": "calloc",
- "@cbopaque": "cbopaque",
- "@dallocx": "dallocx",
- "@free": "free",
- "@je": "je",
- "@mallctl": "mallctl",
- "@mallctlnametomib": "mallctlnametomib",
- "@mallctlbymib": "mallctlbymib",
- "@malloc_stats_print": "malloc_stats_print",
- "@malloc_usable_size": "malloc_usable_size",
- "@malloc": "malloc",
- "@mallocx": "mallocx",
- "@memalign": "memalign",
- "@nallocx": "nallocx",
- "@posix_memalign": "posix_memalign",
- "@rallocx": "rallocx",
- "@realloc": "realloc",
- "@sallocx": "sallocx",
- "@sdallocx": "sdallocx",
- "@valloc": "valloc",
- "@xallocx": "xallocx",
- },
-)
-
-template_rule(
- name = "jemalloc_typedefs_h",
- src = "include/jemalloc/jemalloc_typedefs.h.in",
- out = "include/jemalloc/jemalloc_typedefs.h",
- substitutions = {},
-)
diff --git a/third_party/systemlibs/jemalloc.BUILD b/third_party/systemlibs/jemalloc.BUILD
deleted file mode 100644
index 6a48d582ba..0000000000
--- a/third_party/systemlibs/jemalloc.BUILD
+++ /dev/null
@@ -1,30 +0,0 @@
-licenses(["notice"]) # BSD
-
-filegroup(
- name = "COPYING",
- visibility = ["//visibility:public"],
-)
-
-cc_library(
- name = "jemalloc_headers",
- defines = [
- "jemalloc_posix_memalign=posix_memalign",
- "jemalloc_malloc=malloc",
- "jemalloc_realloc=realloc",
- "jemalloc_free=free",
- ],
- visibility = ["//visibility:public"],
-)
-
-cc_library(
- name = "jemalloc_impl",
- linkopts = ["-ljemalloc"],
- defines = [
- "jemalloc_posix_memalign=posix_memalign",
- "jemalloc_malloc=malloc",
- "jemalloc_realloc=realloc",
- "jemalloc_free=free",
- ],
- visibility = ["//visibility:public"],
- deps = [":jemalloc_headers"],
-)
diff --git a/third_party/systemlibs/syslibs_configure.bzl b/third_party/systemlibs/syslibs_configure.bzl
index 8b0ab39eaf..b03d3380d7 100644
--- a/third_party/systemlibs/syslibs_configure.bzl
+++ b/third_party/systemlibs/syslibs_configure.bzl
@@ -23,7 +23,6 @@ VALID_LIBS = [
"gast_archive",
"gif_archive",
"grpc",
- "jemalloc",
"jpeg",
"jsoncpp_git",
"lmdb",
diff --git a/tools/bazel.rc b/tools/bazel.rc
index 0cd148ed87..3734fab715 100644
--- a/tools/bazel.rc
+++ b/tools/bazel.rc
@@ -73,7 +73,6 @@ build --define=grpc_no_ares=true
build --spawn_strategy=standalone
build --genrule_strategy=standalone
build -c opt
-build --define=with_jemalloc=false
# Other build flags.
build --define=grpc_no_ares=true