Skip to content

Commit cd4f0ec

Browse files
infiWanggns
authored andcommitted
xla: add some riscv64 conditions
1 parent e637e42 commit cd4f0ec

File tree

6 files changed

+36
-0
lines changed

6 files changed

+36
-0
lines changed

third_party/xla/third_party/hwloc/hwloc.BUILD

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ cc_library(
272272
"hwloc/topology-linux.c",
273273
"include/hwloc/linux.h",
274274
],
275+
"@local_xla//xla/tsl:linux_riscv64": [
276+
"hwloc/topology-linux.c",
277+
"include/hwloc/linux.h",
278+
],
275279
"@local_xla//xla/tsl:linux_s390x": [
276280
"hwloc/topology-linux.c",
277281
"include/hwloc/linux.h",

third_party/xla/third_party/mkl_dnn/mkldnn_v1.BUILD

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,7 @@ cc_library(
220220
"@local_xla//xla/tsl:linux_aarch64": ["-lrt"],
221221
"@local_xla//xla/tsl:linux_x86_64": ["-lrt"],
222222
"@local_xla//xla/tsl:linux_ppc64le": ["-lrt"],
223+
"@local_xla//xla/tsl:linux_riscv64": ["-lrt"],
223224
"//conditions:default": [],
224225
}),
225226
textual_hdrs = _TEXTUAL_HDRS_LIST,

third_party/xla/xla/service/cpu/test_target_triple_helper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@ static const char kTargetTripleForHost[] = "aarch64-unknown-linux-gnu";
2323
defined(__ppc__) && (__BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__))
2424
static const char kTargetCpuForHost[] = "ppc";
2525
static const char kTargetTripleForHost[] = "ppc64le-ibm-linux-gnu";
26+
#elif defined(__riscv) && (__riscv_xlen == 64)
27+
static const char kTargetCpuForHost[] = "generic-rv64";
28+
static const char kTargetTripleForHost[] = "riscv64-unknown-linux-gnu";
2629
#elif defined(__s390x__)
2730
static const char kTargetCpuForHost[] = "s390x";
2831
static const char kTargetTripleForHost[] = "systemz-none-linux-gnu";

third_party/xla/xla/tsl/BUILD

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,16 @@ config_setting(
303303
visibility = ["//visibility:public"],
304304
)
305305

306+
config_setting(
307+
name = "linux_riscv64",
308+
constraint_values =
309+
[
310+
"@platforms//cpu:riscv64",
311+
"@platforms//os:linux",
312+
],
313+
visibility = ["//visibility:public"],
314+
)
315+
306316
config_setting(
307317
name = "linux_s390x",
308318
constraint_values =
@@ -369,6 +379,15 @@ selects.config_setting_group(
369379
visibility = ["//visibility:public"],
370380
)
371381

382+
selects.config_setting_group(
383+
name = "riscv64_or_cross",
384+
match_any = [
385+
":linux_riscv64",
386+
":with_cross_compiler_support",
387+
],
388+
visibility = ["//visibility:public"],
389+
)
390+
372391
selects.config_setting_group(
373392
name = "s390x_or_cross",
374393
match_any = [
@@ -440,6 +459,7 @@ selects.config_setting_group(
440459
":linux_aarch64",
441460
":linux_armhf",
442461
":linux_ppc64le",
462+
":linux_riscv64",
443463
":linux_s390x",
444464
":linux_x86_64",
445465
],

third_party/xla/xla/tsl/framework/contraction/BUILD

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,7 @@ cc_library(
9696
"//xla/tsl:fuchsia_x86_64": [],
9797
"//xla/tsl:ios": [],
9898
"//xla/tsl:linux_ppc64le": [],
99+
"//xla/tsl:linux_riscv64": [],
99100
"//xla/tsl:linux_s390x": [],
100101
"//xla/tsl:macos_arm64": [],
101102
"//conditions:default": [
@@ -115,6 +116,7 @@ cc_library(
115116
"//xla/tsl:fuchsia_x86_64": [],
116117
"//xla/tsl:ios": [],
117118
"//xla/tsl:linux_ppc64le": [],
119+
"//xla/tsl:linux_riscv64": [],
118120
"//xla/tsl:linux_s390x": [],
119121
"//xla/tsl:macos_arm64": [],
120122
"//conditions:default": ["@onednn//:mkl_dnn"],

third_party/xla/xla/tsl/platform/default/build_config_root.bzl

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -122,6 +122,12 @@ def if_llvm_powerpc_available(then, otherwise = []):
122122
"//conditions:default": otherwise,
123123
})
124124

125+
def if_llvm_riscv64_available(then, otherwise = []):
126+
return select({
127+
str(Label("//xla/tsl:riscv64_or_cross")): then,
128+
"//conditions:default": otherwise,
129+
})
130+
125131
def if_llvm_system_z_available(then, otherwise = []):
126132
return select({
127133
str(Label("//xla/tsl:s390x_or_cross")): then,

0 commit comments

Comments
 (0)