diff options
author | Anton Matosov <anton.matosov@gmail.com> | 2018-03-23 10:29:48 -0700 |
---|---|---|
committer | Gunhan Gulsoy <gunan@google.com> | 2018-03-23 10:29:48 -0700 |
commit | 116b9f34c3b3562192c69bbd045886c541cfffbc (patch) | |
tree | 49759dd299cac59e022a926a0cadf4feb1465e4b /third_party/mkl | |
parent | 319f20ad87da6c058f6d84edcc41478519d8e15e (diff) |
[WIP] MKL repos download for mac and windows + update to MKL(-DNN) 0.12 (#17396)
* Fix MKL build on MacOS
* Fix invalid return type, user_memory_->set_data_handle(buf) returns void.
* Fix type mismatch
* Implement downloading and linking of MKL repo on mac and windows
* Rework the way MKL libs are binded to avoid warnings and simplify code
* Switch to matching version of MKL-DNN
* Add mirror links
* Add renamed license file
* Add -fopenmp flag for linux mkl build as Slice op kernel is optimized using OpenMP
* Use clean_dep in the entire file for consistency
* Fix build. Constants are declrared as static in header outside the class scope now
* Reworked fix for `-openmp` flag using the suggestion from @gunan
Original version here https://github.com/gunan/tensorflow/commit/b4d39c5226e8bbafe084b1dfc35f4644f2d906c2
Diffstat (limited to 'third_party/mkl')
-rw-r--r-- | third_party/mkl/BUILD | 47 | ||||
-rw-r--r-- | third_party/mkl/MKL_LICENSE (renamed from third_party/mkl/LICENSE) | 0 | ||||
-rw-r--r-- | third_party/mkl/build_defs.bzl | 12 | ||||
-rw-r--r-- | third_party/mkl/mkl.BUILD | 27 |
4 files changed, 73 insertions, 13 deletions
diff --git a/third_party/mkl/BUILD b/third_party/mkl/BUILD index b27d341404..3262562bcc 100644 --- a/third_party/mkl/BUILD +++ b/third_party/mkl/BUILD @@ -1,7 +1,5 @@ licenses(["notice"]) # 3-Clause BSD -exports_files(["LICENSE"]) - config_setting( name = "using_mkl", values = { @@ -10,17 +8,52 @@ config_setting( visibility = ["//visibility:public"], ) +config_setting( + name = "using_mkl_lnx_x64", + values = { + "cpu": "k8", + "define": "using_mkl=true", + }, + visibility = ["//visibility:public"], +) + load( "//third_party/mkl:build_defs.bzl", "if_mkl", ) +filegroup( + name = "LICENSE", + visibility = ["//visibility:public"], + srcs = ["MKL_LICENSE"] + select({ + "@org_tensorflow//tensorflow:linux_x86_64": [ + "@mkl_linux//:LICENSE", + ], + "@org_tensorflow//tensorflow:darwin": [ + "@mkl_darwin//:LICENSE", + ], + "@org_tensorflow//tensorflow:windows": [ + "@mkl_windows//:LICENSE", + ] + }) +) + cc_library( name = "intel_binary_blob", - srcs = if_mkl([ - "@mkl//:libmklml_intel.so", - "@mkl//:libiomp5.so", - ]), + visibility = ["//visibility:public"], - deps = ["@mkl//:mkl_headers"], + deps = select({ + "@org_tensorflow//tensorflow:linux_x86_64": [ + "@mkl_linux//:mkl_headers", + "@mkl_linux//:mkl_libs_linux", + ], + "@org_tensorflow//tensorflow:darwin": [ + "@mkl_darwin//:mkl_headers", + "@mkl_darwin//:mkl_libs_darwin", + ], + "@org_tensorflow//tensorflow:windows": [ + "@mkl_windows//:mkl_headers", + "@mkl_windows//:mkl_libs_windows", + ] + }) ) diff --git a/third_party/mkl/LICENSE b/third_party/mkl/MKL_LICENSE index 9c8f3ea087..9c8f3ea087 100644 --- a/third_party/mkl/LICENSE +++ b/third_party/mkl/MKL_LICENSE diff --git a/third_party/mkl/build_defs.bzl b/third_party/mkl/build_defs.bzl index 8b73ddabdd..53e02769da 100644 --- a/third_party/mkl/build_defs.bzl +++ b/third_party/mkl/build_defs.bzl @@ -24,6 +24,18 @@ def if_mkl(if_true, if_false = []): "//conditions:default": if_false }) +def if_mkl_lnx_x64(if_true, if_false = []): + """Shorthand for select()'ing on whether we're building with MKL. + + Returns a select statement which evaluates to if_true if we're building + with MKL enabled. Otherwise, the select statement evaluates to if_false. + + """ + return select({ + str(Label("//third_party/mkl:using_mkl_lnx_x64")): if_true, + "//conditions:default": if_false + }) + def _enable_local_mkl(repository_ctx): return _TF_MKL_ROOT in repository_ctx.os.environ diff --git a/third_party/mkl/mkl.BUILD b/third_party/mkl/mkl.BUILD index 8db97232e1..892221ec00 100644 --- a/third_party/mkl/mkl.BUILD +++ b/third_party/mkl/mkl.BUILD @@ -17,14 +17,29 @@ cc_library( visibility = ["//visibility:public"], ) -filegroup( - name = "libmklml_intel.so", - srcs = ["lib/libmklml_intel.so"], +cc_library( + name = "mkl_libs_linux", + srcs = [ + "lib/libiomp5.so", + "lib/libmklml_intel.so" + ], visibility = ["//visibility:public"], ) -filegroup( - name = "libiomp5.so", - srcs = ["lib/libiomp5.so"], +cc_library( + name = "mkl_libs_darwin", + srcs = [ + "lib/libiomp5.dylib", + "lib/libmklml.dylib" + ], + visibility = ["//visibility:public"], +) + +cc_library( + name = "mkl_libs_windows", + srcs = [ + "lib/libiomp5md.lib", + "lib/mklml.lib" + ], visibility = ["//visibility:public"], ) |