Skip to content

Commit 049affc

Browse files
pifon2atensorflower-gardener
authored andcommitted
[XLA:GPU] Move legacy emitters to the codegen/llvm directory.
PiperOrigin-RevId: 837532458
1 parent d52a6e8 commit 049affc

14 files changed

Lines changed: 161 additions & 168 deletions

File tree

Lines changed: 130 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,130 @@
1+
# LLVM codegen for GPU.
2+
load("@rules_cc//cc:cc_library.bzl", "cc_library")
3+
load("//xla/tsl:tsl.bzl", "internal_visibility")
4+
load("//xla/tsl:tsl.default.bzl", "get_compatible_with_portable")
5+
6+
package_group(
7+
name = "friends",
8+
includes = [
9+
"//xla:friends",
10+
],
11+
)
12+
13+
package(
14+
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
15+
default_visibility = internal_visibility([":friends"]),
16+
licenses = ["notice"],
17+
)
18+
19+
cc_library(
20+
name = "ir_emitter",
21+
srcs = [
22+
"ir_emitter.cc",
23+
"ir_emitter_nested.cc",
24+
],
25+
hdrs = [
26+
"ir_emitter.h",
27+
"ir_emitter_nested.h",
28+
],
29+
deps = [
30+
":parallel_loop_emitter",
31+
":sort_util",
32+
"//xla:literal",
33+
"//xla:shape_util",
34+
"//xla:status_macros",
35+
"//xla:util",
36+
"//xla/backends/gpu/codegen:fusion_emitter",
37+
"//xla/backends/gpu/runtime:kernel_thunk",
38+
"//xla/backends/gpu/runtime:thunk",
39+
"//xla/backends/gpu/runtime:thunk_id",
40+
"//xla/codegen/emitters:computation_fingerprint",
41+
"//xla/codegen/emitters:kernel_arguments",
42+
"//xla/hlo/ir:hlo",
43+
"//xla/service:buffer_assignment",
44+
"//xla/service:elemental_ir_emitter",
45+
"//xla/service/gpu:gpu_constants",
46+
"//xla/service/gpu:gpu_executable",
47+
"//xla/service/gpu:hlo_to_ir_bindings",
48+
"//xla/service/gpu:ir_emission_utils",
49+
"//xla/service/gpu:ir_emitter_context",
50+
"//xla/service/gpu:launch_dimensions",
51+
"//xla/service/llvm_ir:buffer_assignment_util",
52+
"//xla/service/llvm_ir:fused_ir_emitter",
53+
"//xla/service/llvm_ir:ir_array",
54+
"//xla/service/llvm_ir:ir_builder_mixin",
55+
"//xla/service/llvm_ir:kernel_support_library",
56+
"//xla/service/llvm_ir:llvm_util",
57+
"//xla/service/llvm_ir:loop_emitter",
58+
"//xla/service/llvm_ir:tuple_ops",
59+
"//xla/stream_executor:device_description",
60+
"//xla/stream_executor/gpu:tma_metadata",
61+
"//xla/tsl/platform:errors",
62+
"//xla/tsl/platform:statusor",
63+
"@com_google_absl//absl/algorithm:container",
64+
"@com_google_absl//absl/log",
65+
"@com_google_absl//absl/log:check",
66+
"@com_google_absl//absl/status",
67+
"@com_google_absl//absl/status:statusor",
68+
"@com_google_absl//absl/strings",
69+
"@com_google_absl//absl/strings:str_format",
70+
"@com_google_absl//absl/types:span",
71+
"@llvm-project//llvm:Core",
72+
"@llvm-project//llvm:Support",
73+
"@llvm-project//llvm:TargetParser",
74+
"@local_tsl//tsl/platform:errors",
75+
"@local_tsl//tsl/platform:fingerprint",
76+
"@local_tsl//tsl/platform:statusor",
77+
],
78+
)
79+
80+
cc_library(
81+
name = "sort_util",
82+
srcs = ["sort_util.cc"],
83+
hdrs = ["sort_util.h"],
84+
deps = [
85+
":parallel_loop_emitter",
86+
"//xla:shape_util",
87+
"//xla:util",
88+
"//xla:xla_data_proto_cc",
89+
"//xla/service/gpu:ir_emission_utils",
90+
"//xla/service/gpu:launch_dimensions",
91+
"//xla/service/gpu:target_util",
92+
"//xla/service/llvm_ir:ir_array",
93+
"//xla/service/llvm_ir:kernel_support_library",
94+
"//xla/service/llvm_ir:llvm_util",
95+
"//xla/service/llvm_ir:loop_emitter",
96+
"//xla/tsl/platform:errors",
97+
"//xla/tsl/platform:status",
98+
"@com_google_absl//absl/status",
99+
"@com_google_absl//absl/strings",
100+
"@com_google_absl//absl/types:span",
101+
"@llvm-project//llvm:Core",
102+
"@llvm-project//llvm:Support",
103+
],
104+
)
105+
106+
cc_library(
107+
name = "parallel_loop_emitter",
108+
srcs = ["parallel_loop_emitter.cc"],
109+
hdrs = ["parallel_loop_emitter.h"],
110+
compatible_with = get_compatible_with_portable(),
111+
deps = [
112+
"//xla:shape_util",
113+
"//xla/service/gpu:launch_dimensions",
114+
"//xla/service/gpu:target_util",
115+
"//xla/service/llvm_ir:ir_array",
116+
"//xla/service/llvm_ir:kernel_support_library",
117+
"//xla/service/llvm_ir:llvm_loop",
118+
"//xla/service/llvm_ir:llvm_util",
119+
"//xla/service/llvm_ir:loop_emitter",
120+
"@com_google_absl//absl/log",
121+
"@com_google_absl//absl/log:check",
122+
"@com_google_absl//absl/status",
123+
"@com_google_absl//absl/strings",
124+
"@com_google_absl//absl/strings:string_view",
125+
"@com_google_absl//absl/types:span",
126+
"@llvm-project//llvm:Core",
127+
"@local_tsl//tsl/platform:errors",
128+
"@local_tsl//tsl/platform:logging",
129+
],
130+
)

third_party/xla/xla/service/gpu/ir_emitter.cc renamed to third_party/xla/xla/backends/gpu/codegen/llvm/ir_emitter.cc

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#include "xla/service/gpu/ir_emitter.h"
16+
#include "xla/backends/gpu/codegen/llvm/ir_emitter.h"
1717

1818
#include <algorithm>
1919
#include <cstdint>
@@ -37,6 +37,9 @@ limitations under the License.
3737
#include "llvm/IR/Instructions.h"
3838
#include "llvm/IR/Module.h"
3939
#include "xla/backends/gpu/codegen/fusion_emitter.h"
40+
#include "xla/backends/gpu/codegen/llvm/ir_emitter_nested.h"
41+
#include "xla/backends/gpu/codegen/llvm/parallel_loop_emitter.h"
42+
#include "xla/backends/gpu/codegen/llvm/sort_util.h"
4043
#include "xla/backends/gpu/runtime/kernel_thunk.h"
4144
#include "xla/backends/gpu/runtime/thunk.h"
4245
#include "xla/backends/gpu/runtime/thunk_id.h"
@@ -48,15 +51,12 @@ limitations under the License.
4851
#include "xla/service/gpu/gpu_constants.h"
4952
#include "xla/service/gpu/ir_emission_utils.h"
5053
#include "xla/service/gpu/ir_emitter_context.h"
51-
#include "xla/service/gpu/ir_emitter_nested.h"
5254
#include "xla/service/gpu/launch_dimensions.h"
53-
#include "xla/service/gpu/parallel_loop_emitter.h"
5455
#include "xla/service/llvm_ir/fused_ir_emitter.h"
5556
#include "xla/service/llvm_ir/ir_array.h"
5657
#include "xla/service/llvm_ir/kernel_support_library.h"
5758
#include "xla/service/llvm_ir/llvm_util.h"
5859
#include "xla/service/llvm_ir/loop_emitter.h"
59-
#include "xla/service/llvm_ir/sort_util.h"
6060
#include "xla/service/llvm_ir/tuple_ops.h"
6161
#include "xla/shape.h"
6262
#include "xla/shape_util.h"

third_party/xla/xla/service/gpu/ir_emitter.h renamed to third_party/xla/xla/backends/gpu/codegen/llvm/ir_emitter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#ifndef XLA_SERVICE_GPU_IR_EMITTER_H_
17-
#define XLA_SERVICE_GPU_IR_EMITTER_H_
16+
#ifndef XLA_BACKENDS_GPU_CODEGEN_LLVM_IR_EMITTER_H_
17+
#define XLA_BACKENDS_GPU_CODEGEN_LLVM_IR_EMITTER_H_
1818

1919
#include <vector>
2020

@@ -159,4 +159,4 @@ absl::StatusOr<ThunkSequence> EmitRngGetAndUpdateStateLLVMIR(
159159
} // namespace gpu
160160
} // namespace xla
161161

162-
#endif // XLA_SERVICE_GPU_IR_EMITTER_H_
162+
#endif // XLA_BACKENDS_GPU_CODEGEN_LLVM_IR_EMITTER_H_

third_party/xla/xla/service/gpu/ir_emitter_nested.cc renamed to third_party/xla/xla/backends/gpu/codegen/llvm/ir_emitter_nested.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
15-
#include "xla/service/gpu/ir_emitter_nested.h"
15+
#include "xla/backends/gpu/codegen/llvm/ir_emitter_nested.h"
1616

1717
#include <algorithm>
1818
#include <cstddef>
@@ -42,6 +42,7 @@ limitations under the License.
4242
#include "llvm/IR/LLVMContext.h"
4343
#include "llvm/Support/Casting.h"
4444
#include "llvm/TargetParser/Triple.h"
45+
#include "xla/backends/gpu/codegen/llvm/ir_emitter.h"
4546
#include "xla/codegen/emitters/computation_fingerprint.h"
4647
#include "xla/hlo/ir/hlo_computation.h"
4748
#include "xla/hlo/ir/hlo_instruction.h"
@@ -50,7 +51,6 @@ limitations under the License.
5051
#include "xla/service/gpu/gpu_constants.h"
5152
#include "xla/service/gpu/gpu_executable.h"
5253
#include "xla/service/gpu/ir_emission_utils.h"
53-
#include "xla/service/gpu/ir_emitter.h"
5454
#include "xla/service/gpu/ir_emitter_context.h"
5555
#include "xla/service/llvm_ir/buffer_assignment_util.h"
5656
#include "xla/service/llvm_ir/ir_array.h"

third_party/xla/xla/service/gpu/ir_emitter_nested.h renamed to third_party/xla/xla/backends/gpu/codegen/llvm/ir_emitter_nested.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#ifndef XLA_SERVICE_GPU_IR_EMITTER_NESTED_H_
17-
#define XLA_SERVICE_GPU_IR_EMITTER_NESTED_H_
16+
#ifndef XLA_BACKENDS_GPU_CODEGEN_LLVM_IR_EMITTER_NESTED_H_
17+
#define XLA_BACKENDS_GPU_CODEGEN_LLVM_IR_EMITTER_NESTED_H_
1818

1919
#include <cstdint>
2020
#include <vector>
@@ -66,4 +66,4 @@ GpuExecutable::ConstantInfo AppendGlobalConstant(llvm::Module* module,
6666
} // namespace gpu
6767
} // namespace xla
6868

69-
#endif // XLA_SERVICE_GPU_IR_EMITTER_NESTED_H_
69+
#endif // XLA_BACKENDS_GPU_CODEGEN_LLVM_IR_EMITTER_NESTED_H_

third_party/xla/xla/service/gpu/parallel_loop_emitter.cc renamed to third_party/xla/xla/backends/gpu/codegen/llvm/parallel_loop_emitter.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#include "xla/service/gpu/parallel_loop_emitter.h"
16+
#include "xla/backends/gpu/codegen/llvm/parallel_loop_emitter.h"
1717

1818
#include <cstdint>
1919
#include <vector>

third_party/xla/xla/service/gpu/parallel_loop_emitter.h renamed to third_party/xla/xla/backends/gpu/codegen/llvm/parallel_loop_emitter.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#ifndef XLA_SERVICE_GPU_PARALLEL_LOOP_EMITTER_H_
17-
#define XLA_SERVICE_GPU_PARALLEL_LOOP_EMITTER_H_
16+
#ifndef XLA_BACKENDS_GPU_CODEGEN_LLVM_PARALLEL_LOOP_EMITTER_H_
17+
#define XLA_BACKENDS_GPU_CODEGEN_LLVM_PARALLEL_LOOP_EMITTER_H_
1818

1919
#include <vector>
2020

@@ -99,4 +99,4 @@ class ParallelLoopEmitter {
9999
} // namespace gpu
100100
} // namespace xla
101101

102-
#endif // XLA_SERVICE_GPU_PARALLEL_LOOP_EMITTER_H_
102+
#endif // XLA_BACKENDS_GPU_CODEGEN_LLVM_PARALLEL_LOOP_EMITTER_H_

third_party/xla/xla/service/llvm_ir/sort_util.cc renamed to third_party/xla/xla/backends/gpu/codegen/llvm/sort_util.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#include "xla/service/llvm_ir/sort_util.h"
16+
#include "xla/backends/gpu/codegen/llvm/sort_util.h"
1717

1818
#include <algorithm>
1919
#include <cstdint>
@@ -33,10 +33,10 @@ limitations under the License.
3333
#include "llvm/IR/Instructions.h"
3434
#include "llvm/IR/Value.h"
3535
#include "llvm/Support/Casting.h"
36+
#include "xla/backends/gpu/codegen/llvm/parallel_loop_emitter.h"
3637
#include "xla/layout_util.h"
3738
#include "xla/service/gpu/ir_emission_utils.h"
3839
#include "xla/service/gpu/launch_dimensions.h"
39-
#include "xla/service/gpu/parallel_loop_emitter.h"
4040
#include "xla/service/gpu/target_util.h"
4141
#include "xla/service/llvm_ir/ir_array.h"
4242
#include "xla/service/llvm_ir/kernel_support_library.h"

third_party/xla/xla/service/llvm_ir/sort_util.h renamed to third_party/xla/xla/backends/gpu/codegen/llvm/sort_util.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@ See the License for the specific language governing permissions and
1313
limitations under the License.
1414
==============================================================================*/
1515

16-
#ifndef XLA_SERVICE_LLVM_IR_SORT_UTIL_H_
17-
#define XLA_SERVICE_LLVM_IR_SORT_UTIL_H_
16+
#ifndef XLA_BACKENDS_GPU_CODEGEN_LLVM_SORT_UTIL_H_
17+
#define XLA_BACKENDS_GPU_CODEGEN_LLVM_SORT_UTIL_H_
1818

1919
#include <cstdint>
2020
#include <functional>
@@ -45,4 +45,4 @@ absl::Status EmitSortInPlace(
4545
} // namespace llvm_ir
4646
} // namespace xla
4747

48-
#endif // XLA_SERVICE_LLVM_IR_SORT_UTIL_H_
48+
#endif // XLA_BACKENDS_GPU_CODEGEN_LLVM_SORT_UTIL_H_

0 commit comments

Comments
 (0)