Skip to content

Commit d182865

Browse files
committed
Auto Reorder
1 parent 28a958a commit d182865

18 files changed

+2175
-50
lines changed

.bazelrc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ build --define tsl_protobuf_header_only=true
8282

8383
build --define=use_fast_cpp_protos=true
8484
build --define=allow_oversize_protos=true
85-
85+
build --incompatible_strict_action_env
8686
build --spawn_strategy=standalone
8787
build -c opt
8888

xla/debug_options_flags.cc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,8 @@ DebugOptions DefaultDebugOptionsIgnoringFlags() {
149149
opts.set_xla_gpu_enable_latency_hiding_scheduler(false);
150150
opts.set_xla_gpu_lhs_enable_gpu_async_tracker(true);
151151
opts.set_xla_gpu_enable_analytical_latency_estimator(false);
152+
opts.set_xla_gpu_enable_linear_program_scheduler(false);
153+
152154
opts.set_xla_gpu_pgle_profile_file_or_directory_path("");
153155
opts.set_xla_gpu_enable_highest_priority_async_stream(true);
154156

@@ -1120,6 +1122,13 @@ void MakeDebugOptionsFlags(std::vector<tsl::Flag>* flag_list,
11201122
debug_options->xla_gpu_enable_analytical_latency_estimator(),
11211123
"Enable analytical latency estimator for latency-hiding scheduler for "
11221124
"XLA:GPU"));
1125+
flag_list->push_back(tsl::Flag(
1126+
"xla_gpu_enable_linear_program_scheduler",
1127+
bool_setter_for(
1128+
&DebugOptions::set_xla_gpu_enable_linear_program_scheduler),
1129+
debug_options->xla_gpu_enable_linear_program_scheduler(),
1130+
"Enable linear program sheduler for better performance"
1131+
"XLA:GPU"));
11231132
flag_list->push_back(tsl::Flag(
11241133
"xla_gpu_pgle_profile_file_or_directory_path",
11251134
string_setter_for(
Lines changed: 100 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,100 @@
1+
load("@bazel_skylib//rules:build_test.bzl", "build_test")
2+
load("//xla:xla.bzl", "xla_cc_test","xla_cc_binary")
3+
package(
4+
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
5+
default_visibility = [":friends"],
6+
)
7+
8+
package_group(
9+
name = "friends",
10+
packages= [
11+
# "//xla/hlo/experimental/auto_reorder",
12+
"//xla/service/gpu/...",
13+
"//xla/hlo/utils/...",
14+
],
15+
16+
)
17+
18+
# Filegroup used to collect source files for dependency checking.
19+
filegroup(
20+
name = "c_srcs",
21+
data = glob([
22+
"**/*.cc",
23+
"**/*.h",
24+
]),
25+
)
26+
cc_library(
27+
name = "auto_reorder_solver",
28+
srcs = ["auto_reorder_solver.cc",
29+
],
30+
hdrs = [
31+
"auto_reorder_solver.h",
32+
],
33+
deps = [
34+
"//xla:statusor",
35+
"//xla:util",
36+
"//xla/hlo/ir:hlo",
37+
"//xla/service:hlo_parser",
38+
"//xla/hlo/utils:common_ortools_deps",
39+
"@tsl//tsl/platform:statusor",
40+
"@com_google_absl//absl/container:flat_hash_map",
41+
"@com_google_absl//absl/container:flat_hash_set",
42+
"@com_google_absl//absl/log",
43+
"@com_google_absl//absl/log:check",
44+
"@com_google_absl//absl/status",
45+
"@com_google_absl//absl/strings",
46+
"@com_google_absl//absl/time",
47+
"@tsl//tsl/platform:hash",
48+
"@tsl//tsl/platform:types",
49+
]
50+
)
51+
# All header files that are used in the build must be declared in
52+
# the hdrs or srcs of cc_* rules.
53+
# This is enforced.
54+
55+
cc_library(
56+
name = "auto_reorder",
57+
srcs = [
58+
"auto_reorder.cc",
59+
],
60+
hdrs = [
61+
"auto_reorder.h",
62+
"auto_reorder_solver.h",
63+
],
64+
visibility = ["//visibility:public"],
65+
deps = [
66+
"//xla/hlo/ir:hlo",
67+
"//xla/service:hlo_parser",
68+
"//xla/hlo/ir:hlo_module_group",
69+
"//xla/service:hlo_pass",
70+
"//xla/service:hlo_cost_analysis",
71+
"//xla/service:latency_hiding_scheduler",
72+
"//xla/service/gpu/model:gpu_hlo_cost_analysis",
73+
"//xla/service/gpu/model:analytical_latency_estimator",
74+
"//xla/service:backend",
75+
"@com_google_absl//absl/strings",
76+
"@tsl//tsl/platform:statusor",
77+
":auto_reorder_solver"
78+
],
79+
)
80+
81+
xla_cc_test(
82+
name = "auto_reorder_test",
83+
srcs = ["auto_reorder_test.cc"],
84+
deps = [
85+
":auto_reorder",
86+
"//xla/hlo/ir:hlo",
87+
"//xla/hlo/utils:hlo_matchers",
88+
"//xla/service:hlo_parser",
89+
"//xla/tests:hlo_test_base",
90+
"//xla/tests:xla_internal_test_main",
91+
"//xla/service:latency_hiding_scheduler",
92+
"//xla/service/gpu:gpu_hlo_schedule",
93+
"//xla/service:gpu_plugin",
94+
"//xla/service/gpu:gpu_device_info_for_tests",
95+
"@com_google_absl//absl/log",
96+
"@com_google_googletest//:gtest",
97+
"@tsl//tsl/lib/core:status_test_util",
98+
"@tsl//tsl/platform:statusor",
99+
],
100+
)
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# Auto Reorder
2+
3+
run tests
4+
```
5+
TF_CPP_MAX_VLOG_LEVEL=2 bazel run --compilation_mode=dbg xla/hlo/experimental/auto_reorder:auto_reorder_test --incompatible_strict_action_env --action_env=USE_CUDA --action_env=XLA_CUDA
6+
```

0 commit comments

Comments
 (0)