Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add llvm support for s390x, fix xla and aot issue #40197

Merged
merged 14 commits into from
Jul 9, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 10 additions & 3 deletions tensorflow/compiler/aot/BUILD
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
load("//tensorflow/compiler/aot:tfcompile.bzl", "tf_library")
load("//tensorflow:tensorflow.bzl", "tf_cc_binary", "tf_cc_test")
load("//tensorflow/core/platform:build_config.bzl", "if_llvm_aarch64_available")
load("//tensorflow/core/platform:build_config.bzl", "if_llvm_s390x_available")

package(
default_visibility = ["//visibility:private"],
Expand Down Expand Up @@ -35,7 +36,9 @@ cc_library(
"flags.h",
"quantize.h",
],
defines = if_llvm_aarch64_available(["TF_LLVM_AARCH64_AVAILABLE=1"]),
defines = if_llvm_aarch64_available(["TF_LLVM_AARCH64_AVAILABLE=1"]) + if_llvm_s390x_available([
"TF_LLVM_S390X_AVAILABLE=1",
]),
visibility = ["//tensorflow/python:__pkg__"],
deps = [
":aot_only_var_handle_op",
Expand Down Expand Up @@ -73,7 +76,9 @@ cc_library(
"@llvm-project//llvm:Target",
"@llvm-project//llvm:X86CodeGen", # fixdeps: keep
"//tensorflow/core:regexp_internal",
] + if_llvm_aarch64_available([
] + if_llvm_s390x_available([
"@llvm-project//llvm:SystemZCodeGen", # fixdeps: keep
]) + if_llvm_aarch64_available([
"@llvm-project//llvm:AArch64CodeGen", # fixdeps: keep
]),
)
Expand Down Expand Up @@ -114,7 +119,9 @@ cc_library(
"@llvm-project//llvm:PowerPCCodeGen", # fixdeps: keep
"@llvm-project//llvm:Target",
"@llvm-project//llvm:X86CodeGen", # fixdeps: keep
] + if_llvm_aarch64_available([
] + if_llvm_s390x_available([
"@llvm-project//llvm:SystemZCodeGen", # fixdeps: keep
]) + if_llvm_aarch64_available([
"@llvm-project//llvm:AArch64CodeGen", # fixdeps: keep
]),
)
Expand Down
6 changes: 6 additions & 0 deletions tensorflow/compiler/aot/compile.cc
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,12 @@ static void InitializeTargets() {
LLVMInitializeAArch64TargetInfo();
LLVMInitializeAArch64TargetMC();
LLVMInitializeAArch64AsmPrinter();
#endif
#if TF_LLVM_S390X_AVAILABLE
LLVMInitializeSystemZTarget();
LLVMInitializeSystemZTargetInfo();
LLVMInitializeSystemZTargetMC();
LLVMInitializeSystemZAsmPrinter();
#endif
LLVMInitializeARMTarget();
LLVMInitializeARMTargetInfo();
Expand Down
1 change: 1 addition & 0 deletions tensorflow/compiler/aot/tfcompile.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -434,5 +434,6 @@ def target_llvm_triple():
"//tensorflow:linux_ppc64le": "ppc64le-ibm-linux-gnu",
"//tensorflow:macos": "x86_64-none-darwin",
"//tensorflow:windows": "x86_64-none-windows",
"//tensorflow:linux_s390x": "systemz-none-linux-gnu",
"//conditions:default": "x86_64-pc-linux",
})
3 changes: 3 additions & 0 deletions tensorflow/compiler/xla/service/cpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -201,6 +201,9 @@ cc_library(
"//tensorflow:linux_ppc64le": [
"@llvm-project//llvm:PowerPCCodeGen", # fixdeps: keep
],
"//tensorflow:linux_s390x": [
sanjoy marked this conversation as resolved.
Show resolved Hide resolved
"@llvm-project//llvm:SystemZCodeGen", # fixdeps: keep
],
"//conditions:default": [
],
}),
Expand Down
2 changes: 2 additions & 0 deletions tensorflow/core/platform/build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
load(
"//tensorflow/core/platform/default:build_config.bzl",
_if_llvm_aarch64_available = "if_llvm_aarch64_available",
_if_llvm_s390x_available = "if_llvm_s390x_available",
_pyx_library = "pyx_library",
_tf_additional_all_protos = "tf_additional_all_protos",
_tf_additional_binary_deps = "tf_additional_binary_deps",
Expand Down Expand Up @@ -44,6 +45,7 @@ load(
)

if_llvm_aarch64_available = _if_llvm_aarch64_available
if_llvm_s390x_available = _if_llvm_s390x_available
pyx_library = _pyx_library
tf_additional_all_protos = _tf_additional_all_protos
tf_additional_binary_deps = _tf_additional_binary_deps
Expand Down
6 changes: 6 additions & 0 deletions tensorflow/core/platform/default/build_config.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -779,3 +779,9 @@ def if_llvm_aarch64_available(then, otherwise = []):
# TODO(b/...): The TF XLA build fails when adding a dependency on
# @llvm/llvm-project/llvm:aarch64_target.
return otherwise

def if_llvm_s390x_available(then, otherwise = []):
return select({
"//tensorflow:linux_s390x": then,
"//conditions:default": otherwise,
})
1 change: 1 addition & 0 deletions third_party/llvm/llvm.autogenerated.BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ llvm_targets = [
"PowerPC",
"SystemZ",
"X86",
"SystemZ",
]

llvm_target_asm_parsers = llvm_targets
Expand Down
8 changes: 8 additions & 0 deletions third_party/llvm/llvm.bzl
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ llvm_all_cmake_vars = select({
posix_cmake_vars,
),
),
"@org_tensorflow//tensorflow:linux_s390x": cmake_var_string(
_dict_add(
cmake_vars,
llvm_target_cmake_vars("SystemZ", "systemz-unknown-linux_gnu"),
posix_cmake_vars,
linux_cmake_vars,
),
),
"//conditions:default": cmake_var_string(
_dict_add(
cmake_vars,
Expand Down