Removed MKL binary blob and replaced openmp with opensource lib.
diff --git a/tensorflow/tensorflow.bzl b/tensorflow/tensorflow.bzl
index 8ed1213..a364143 100644
--- a/tensorflow/tensorflow.bzl
+++ b/tensorflow/tensorflow.bzl
@@ -331,8 +331,7 @@
if_tpu(["-DLIBTFTPU"]) +
if_xla_available(["-DTENSORFLOW_USE_XLA=1"]) +
if_tensorrt(["-DGOOGLE_TENSORRT=1"]) +
- if_mkl(["-DINTEL_MKL=1", "-DENABLE_MKLDNN_V1", "-DENABLE_INTEL_MKL_BFLOAT16"]) +
- if_mkl_open_source_only(["-DINTEL_MKL_DNN_ONLY"]) +
+ if_mkl(["-DINTEL_MKL=1", "-DENABLE_MKLDNN_V1", "-DENABLE_INTEL_MKL_BFLOAT16","-DINTEL_MKL_DNN_ONLY"]) +
if_mkldnn_threadpool(["-DENABLE_MKLDNN_THREADPOOL"]) +
if_enable_mkl(["-DENABLE_MKL"]) +
if_ngraph(["-DINTEL_NGRAPH=1"]) +
diff --git a/tensorflow/workspace.bzl b/tensorflow/workspace.bzl
index eafc52a..78dd4b4 100755
--- a/tensorflow/workspace.bzl
+++ b/tensorflow/workspace.bzl
@@ -126,16 +126,6 @@
)
mkl_repository(
- name = "mkl_linux",
- build_file = clean_dep("//third_party/mkl:mkl.BUILD"),
- sha256 = "a936d6b277a33d2a027a024ea8e65df62bd2e162c7ca52c48486ed9d5dc27160",
- strip_prefix = "mklml_lnx_2019.0.5.20190502",
- urls = [
- "https://storage.googleapis.com/mirror.tensorflow.org/github.com/intel/mkl-dnn/releases/download/v0.21/mklml_lnx_2019.0.5.20190502.tgz",
- "https://github.com/intel/mkl-dnn/releases/download/v0.21/mklml_lnx_2019.0.5.20190502.tgz",
- ],
- )
- mkl_repository(
name = "mkl_windows",
build_file = clean_dep("//third_party/mkl:mkl.BUILD"),
sha256 = "33cc27652df3b71d7cb84b26718b5a2e8965e2c864a502347db02746d0430d57",
@@ -730,6 +720,18 @@
},
)
+ # Intel openMP that is part of LLVM sources.
+ tf_http_archive(
+ name = "llvm-openmp",
+ build_file = clean_dep("//third_party/llvm-openmp:BUILD"),
+ sha256 = "d19f728c8e04fb1e94566c8d76aef50ec926cd2f95ef3bf1e0a5de4909b28b44",
+ strip_prefix = "openmp-10.0.1.src",
+ urls = [
+ "https://storage.googleapis.com/mirror.tensorflow.org/github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/openmp-10.0.1.src.tar.xz",
+ "https://github.com/llvm/llvm-project/releases/download/llvmorg-10.0.1/openmp-10.0.1.src.tar.xz",
+ ],
+ )
+
tf_http_archive(
name = "lmdb",
build_file = clean_dep("//third_party:lmdb.BUILD"),
diff --git a/third_party/llvm-openmp/BUILD b/third_party/llvm-openmp/BUILD
new file mode 100644
index 0000000..ee35576
--- /dev/null
+++ b/third_party/llvm-openmp/BUILD
@@ -0,0 +1,124 @@
+# Build file for OpenMP library that is part of llvm
+
+exports_files(["LICENSE.txt"])
+
+load(
+ "@org_tensorflow//third_party/llvm:llvm.bzl",
+ "cmake_var_string",
+ "dict_add",
+ "expand_cmake_vars",
+)
+load(
+ "@org_tensorflow//third_party:common.bzl",
+ "template_rule",
+)
+
+genrule(
+ name = "il8n_id",
+ srcs = [
+ "runtime/tools/message-converter.pl",
+ "runtime/src/i18n/en_US.txt",
+ ],
+ outs = ["include/kmp_i18n_id.inc"],
+ cmd = "$(location runtime/tools/message-converter.pl) --os=lin --prefix=kmp_i18n --enum=$@ $(location runtime/src/i18n/en_US.txt)",
+)
+
+genrule(
+ name = "kmp_i18n_default",
+ srcs = [
+ "runtime/tools/message-converter.pl",
+ "runtime/src/i18n/en_US.txt",
+ ],
+ outs = ["include/kmp_i18n_default.inc"],
+ cmd = "perl $(location runtime/tools/message-converter.pl) --os=lin --prefix=kmp_i18n --default=$@ $(location runtime/src/i18n/en_US.txt)",
+)
+
+# Bazel doesn't accept .txt as an input, rename the ldscript to .inc to workaround.
+genrule(
+ name = "ldscript",
+ srcs = ["runtime/src/exports_so.txt"],
+ outs = ["exports_so.inc"],
+ cmd = "cp $(location runtime/src/exports_so.txt) $@",
+)
+
+# Cmake vars to replace.
+omp_vars = {
+ "LIBOMP_USE_VERSION_SYMBOLS": 1,
+ "LIBOMP_HAVE_WEAK_ATTRIBUTE": 1,
+ "LIBOMP_USE_ADAPTIVE_LOCKS": 1,
+ "LIBOMP_ENABLE_ASSERTIONS": 1,
+ "LIBOMP_ENABLE_SHARED": 1,
+ "LIBOMP_LEGAL_ARCH": "Intel(R) 64",
+ "LIBOMP_LIB_FILE": "libiomp5.so",
+ "LIBOMP_VERSION_MAJOR": 5,
+ "LIBOMP_VERSION_MINOR": 0,
+}
+
+omp_all_cmake_vars = cmake_var_string(dict_add(omp_vars))
+
+expand_cmake_vars(
+ name = "config_kmp",
+ src = "runtime/src/kmp_config.h.cmake",
+ cmake_vars = omp_all_cmake_vars,
+ dst = "include/kmp_config.h",
+)
+
+expand_cmake_vars(
+ name = "config_omp",
+ src = "runtime/src/include/omp.h.var",
+ cmake_vars = omp_all_cmake_vars,
+ dst = "include/omp.h",
+)
+
+cc_binary(
+ name = "libiomp5.so",
+ srcs = glob([
+ "runtime/src/*.h",
+ "runtime/src/kmp_alloc.cpp",
+ "runtime/src/kmp_atomic.cpp",
+ "runtime/src/kmp_csupport.cpp",
+ "runtime/src/kmp_debug.cpp",
+ "runtime/src/kmp_itt.cpp",
+ "runtime/src/kmp_environment.cpp",
+ "runtime/src/kmp_error.cpp",
+ "runtime/src/kmp_global.cpp",
+ "runtime/src/kmp_i18n.cpp",
+ "runtime/src/kmp_io.cpp",
+ "runtime/src/kmp_runtime.cpp",
+ "runtime/src/kmp_settings.cpp",
+ "runtime/src/kmp_str.cpp",
+ "runtime/src/kmp_tasking.cpp",
+ "runtime/src/kmp_threadprivate.cpp",
+ "runtime/src/kmp_utility.cpp",
+ "runtime/src/kmp_barrier.cpp",
+ "runtime/src/kmp_wait_release.cpp",
+ "runtime/src/kmp_affinity.cpp",
+ "runtime/src/kmp_dispatch.cpp",
+ "runtime/src/kmp_lock.cpp",
+ "runtime/src/kmp_sched.cpp",
+ "runtime/src/kmp_taskdeps.cpp",
+ "runtime/src/kmp_cancel.cpp",
+ "runtime/src/kmp_ftn_cdecl.cpp",
+ "runtime/src/kmp_ftn_extra.cpp",
+ "runtime/src/kmp_version.cpp",
+
+ #linux specific files
+ "runtime/src/z_Linux_util.cpp",
+ "runtime/src/kmp_gsupport.cpp",
+ "runtime/src/z_Linux_asm.S",
+ ]) + [
+ ":config_kmp",
+ ":config_omp",
+ ":il8n_id",
+ ":kmp_i18n_default",
+ ":ldscript",
+ ],
+ copts = ["-Domp_EXPORTS -D_GNU_SOURCE -D_REENTRANT"],
+ includes = [
+ "include/",
+ "runtime/src/",
+ ],
+ linkopts = ["-lpthread -ldl -Wl,--version-script=$(location :ldscript)"],
+ linkshared = True,
+ visibility = ["//visibility:public"],
+)
diff --git a/third_party/llvm/BUILD b/third_party/llvm/BUILD
index 1a5634a..f2e079a 100644
--- a/third_party/llvm/BUILD
+++ b/third_party/llvm/BUILD
@@ -2,5 +2,5 @@
name = "expand_cmake_vars",
srcs = ["expand_cmake_vars.py"],
srcs_version = "PY2AND3",
- visibility = ["@llvm-project//:__subpackages__"],
+ visibility = ["//visibility:public"],
)
diff --git a/third_party/llvm/expand_cmake_vars.py b/third_party/llvm/expand_cmake_vars.py
index ffc6a25..73f071a 100644
--- a/third_party/llvm/expand_cmake_vars.py
+++ b/third_party/llvm/expand_cmake_vars.py
@@ -25,6 +25,7 @@
_CMAKE_DEFINE_REGEX = re.compile(r"\s*#cmakedefine\s+([A-Za-z_0-9]*)(\s.*)?$")
_CMAKE_DEFINE01_REGEX = re.compile(r"\s*#cmakedefine01\s+([A-Za-z_0-9]*)")
_CMAKE_VAR_REGEX = re.compile(r"\${([A-Za-z_0-9]*)}")
+_CMAKE_ATVAR_REGEX = re.compile(r"\@([A-Za-z_0-9]*)@")
def _parse_args(argv):
@@ -50,7 +51,7 @@
if match.group(1) in cmake_vars:
return cmake_vars[match.group(1)]
return ""
- return _CMAKE_VAR_REGEX.sub(replace, input_str)
+ return _CMAKE_ATVAR_REGEX.sub(replace,_CMAKE_VAR_REGEX.sub(replace, input_str))
def _expand_cmakedefines(line, cmake_vars):
diff --git a/third_party/llvm/llvm.bzl b/third_party/llvm/llvm.bzl
index dcbaab9..c2be9dc 100644
--- a/third_party/llvm/llvm.bzl
+++ b/third_party/llvm/llvm.bzl
@@ -7,7 +7,7 @@
correctly understood by the build system.
"""
-def _dict_add(*dictionaries):
+def dict_add(*dictionaries):
"""Returns a new `dict` that has all the entries of the given dictionaries.
If the same key is present in more than one of the input dictionaries, the
@@ -305,7 +305,7 @@
# than hardcoding x86_64.
llvm_all_cmake_vars = select({
"@org_tensorflow//tensorflow:macos": cmake_var_string(
- _dict_add(
+ dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-apple-darwin"),
posix_cmake_vars,
@@ -313,7 +313,7 @@
),
),
"@org_tensorflow//tensorflow:linux_ppc64le": cmake_var_string(
- _dict_add(
+ dict_add(
cmake_vars,
llvm_target_cmake_vars("PowerPC", "powerpc64le-unknown-linux_gnu"),
posix_cmake_vars,
@@ -321,21 +321,21 @@
),
),
"@org_tensorflow//tensorflow:windows": cmake_var_string(
- _dict_add(
+ dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-pc-win32"),
win32_cmake_vars,
),
),
"@org_tensorflow//tensorflow:freebsd": cmake_var_string(
- _dict_add(
+ dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-unknown-freebsd"),
posix_cmake_vars,
),
),
"@org_tensorflow//tensorflow:linux_s390x": cmake_var_string(
- _dict_add(
+ dict_add(
cmake_vars,
llvm_target_cmake_vars("SystemZ", "systemz-unknown-linux_gnu"),
posix_cmake_vars,
@@ -343,7 +343,7 @@
),
),
"//conditions:default": cmake_var_string(
- _dict_add(
+ dict_add(
cmake_vars,
llvm_target_cmake_vars("X86", "x86_64-unknown-linux_gnu"),
posix_cmake_vars,
diff --git a/third_party/mkl/BUILD b/third_party/mkl/BUILD
index 66a2bf8..5cee051 100644
--- a/third_party/mkl/BUILD
+++ b/third_party/mkl/BUILD
@@ -34,7 +34,7 @@
name = "LICENSE",
srcs = ["MKL_LICENSE"] + select({
"@org_tensorflow//tensorflow:linux_x86_64": [
- "@mkl_linux//:LICENSE",
+ "@llvm-openmp//:LICENSE.txt",
],
"@org_tensorflow//tensorflow:macos": [
"@mkl_darwin//:LICENSE",
@@ -48,12 +48,19 @@
)
cc_library(
+ name = "mkl_libs_linux",
+ srcs = [
+ "@llvm-openmp//:libiomp5.so",
+ ],
+ visibility = ["//visibility:public"],
+)
+
+cc_library(
name = "intel_binary_blob",
visibility = ["//visibility:public"],
deps = select({
"@org_tensorflow//tensorflow:linux_x86_64": [
- "@mkl_linux//:mkl_headers",
- "@mkl_linux//:mkl_libs_linux",
+ ":mkl_libs_linux",
],
"@org_tensorflow//tensorflow:macos": [
"@mkl_darwin//:mkl_headers",
diff --git a/third_party/mkl/mkl.BUILD b/third_party/mkl/mkl.BUILD
index 7237018..32d2965 100644
--- a/third_party/mkl/mkl.BUILD
+++ b/third_party/mkl/mkl.BUILD
@@ -18,15 +18,6 @@
)
cc_library(
- name = "mkl_libs_linux",
- srcs = [
- "lib/libiomp5.so",
- "lib/libmklml_intel.so",
- ],
- visibility = ["//visibility:public"],
-)
-
-cc_library(
name = "mkl_libs_darwin",
srcs = [
"lib/libiomp5.dylib",