Skip to content

Commit af2cb4c

Browse files
WillFroomGoogle-ML-Automation
authored andcommitted
[XLA:CPU] Remove unused stream_executor host code.
PiperOrigin-RevId: 715298307
1 parent 521d1a8 commit af2cb4c

12 files changed

+4
-1622
lines changed

xla/stream_executor/host/BUILD

Lines changed: 2 additions & 138 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,6 @@
44
load("//xla:xla.bzl", "xla_cc_test")
55
load("//xla/stream_executor:build_defs.bzl", "stream_executor_friends")
66
load("//xla/tsl:tsl.bzl", "internal_visibility")
7-
load(
8-
"//xla/tsl/platform:build_config_root.bzl",
9-
"if_llvm_aarch32_available",
10-
"if_llvm_aarch64_available",
11-
"if_llvm_powerpc_available",
12-
"if_llvm_system_z_available",
13-
"if_llvm_x86_available",
14-
)
157
load("//xla/tsl/platform:rules_cc.bzl", "cc_library")
168

179
package(
@@ -83,14 +75,14 @@ cc_library(
8375
],
8476
deps = [
8577
":host_event",
86-
":host_kernel",
8778
"//xla/stream_executor:device_memory",
8879
"//xla/stream_executor:event",
8980
"//xla/stream_executor:kernel",
9081
"//xla/stream_executor:launch_dim",
9182
"//xla/stream_executor:stream",
9283
"//xla/stream_executor:stream_common",
9384
"//xla/stream_executor:stream_executor_h",
85+
"//xla/tsl/platform:env",
9486
"@com_google_absl//absl/base:core_headers",
9587
"@com_google_absl//absl/functional:any_invocable",
9688
"@com_google_absl//absl/log:check",
@@ -103,66 +95,6 @@ cc_library(
10395
],
10496
)
10597

106-
cc_library(
107-
name = "host_kernel_c_api",
108-
hdrs = ["host_kernel_c_api.h"],
109-
)
110-
111-
cc_library(
112-
name = "host_kernel",
113-
srcs = ["host_kernel.cc"],
114-
hdrs = ["host_kernel.h"],
115-
deps = [
116-
":host_kernel_c_api",
117-
"//xla/stream_executor:device_memory",
118-
"//xla/stream_executor:kernel",
119-
"//xla/stream_executor:kernel_spec",
120-
"//xla/stream_executor:launch_dim",
121-
"//xla/stream_executor:stream",
122-
"//xla/tsl/concurrency:async_value",
123-
"//xla/tsl/platform:env",
124-
"//xla/tsl/platform:logging",
125-
"@com_google_absl//absl/base:core_headers",
126-
"@com_google_absl//absl/container:inlined_vector",
127-
"@com_google_absl//absl/functional:any_invocable",
128-
"@com_google_absl//absl/status",
129-
"@com_google_absl//absl/status:statusor",
130-
"@com_google_absl//absl/strings:str_format",
131-
"@com_google_absl//absl/types:span",
132-
"@tsl//tsl/platform:env",
133-
],
134-
)
135-
136-
xla_cc_test(
137-
name = "host_kernel_test",
138-
srcs = ["host_kernel_test.cc"],
139-
deps = [
140-
":host_kernel",
141-
":host_kernel_c_api",
142-
":host_platform",
143-
":jit_host_kernel_function",
144-
":ptr_host_kernel_function",
145-
"//xla/stream_executor:device_memory",
146-
"//xla/stream_executor:kernel",
147-
"//xla/stream_executor:kernel_spec",
148-
"//xla/stream_executor:launch_dim",
149-
"//xla/stream_executor:platform",
150-
"//xla/stream_executor:platform_manager",
151-
"//xla/stream_executor:stream_executor_h",
152-
"//xla/tsl/concurrency:async_value",
153-
"//xla/tsl/lib/core:status_test_util",
154-
"@com_google_absl//absl/status:statusor",
155-
"@com_google_absl//absl/strings",
156-
"@com_google_absl//absl/types:span",
157-
"@com_google_googletest//:gtest_main",
158-
"@tsl//tsl/platform:env",
159-
"@tsl//tsl/platform:platform_port",
160-
"@tsl//tsl/platform:statusor",
161-
"@tsl//tsl/platform:test",
162-
"@tsl//tsl/platform:test_benchmark",
163-
],
164-
)
165-
16698
cc_library(
16799
name = "host_executor",
168100
srcs = [
@@ -173,7 +105,6 @@ cc_library(
173105
],
174106
deps = [
175107
":host_event",
176-
":host_kernel",
177108
":host_stream",
178109
"//xla/stream_executor:device_description",
179110
"//xla/stream_executor:device_memory",
@@ -185,15 +116,14 @@ cc_library(
185116
"//xla/stream_executor:platform",
186117
"//xla/stream_executor:stream",
187118
"//xla/stream_executor:stream_executor_common",
119+
"//xla/tsl/platform:env",
188120
"//xla/tsl/platform/profile_utils:profile_utils_cpu_utils",
189121
"@com_google_absl//absl/log",
190122
"@com_google_absl//absl/log:check",
191123
"@com_google_absl//absl/status",
192124
"@com_google_absl//absl/status:statusor",
193125
"@com_google_absl//absl/strings",
194-
"@tsl//tsl/platform:env",
195126
"@tsl//tsl/platform:platform_port",
196-
"@tsl//tsl/platform:statusor",
197127
],
198128
alwayslink = True,
199129
)
@@ -216,69 +146,3 @@ xla_cc_test(
216146
"@tsl//tsl/platform:test",
217147
],
218148
)
219-
220-
cc_library(
221-
name = "ptr_host_kernel_function",
222-
srcs = ["ptr_host_kernel_function.cc"],
223-
hdrs = ["ptr_host_kernel_function.h"],
224-
deps = [
225-
":host_executor",
226-
":host_kernel",
227-
":host_kernel_c_api",
228-
"//xla/stream_executor:kernel_spec",
229-
"//xla/stream_executor/platform:initialize",
230-
"@com_google_absl//absl/status:statusor",
231-
"@com_google_absl//absl/strings",
232-
],
233-
alwayslink = True, # static kernel function loader registration
234-
)
235-
236-
cc_library(
237-
name = "jit_host_kernel_function",
238-
srcs = ["jit_host_kernel_function.cc"],
239-
hdrs = ["jit_host_kernel_function.h"],
240-
deps = [
241-
":host_executor",
242-
":host_kernel",
243-
":host_kernel_c_api",
244-
"//xla/stream_executor:kernel_spec",
245-
"//xla/stream_executor/platform:initialize",
246-
"@com_google_absl//absl/log:check",
247-
"@com_google_absl//absl/status",
248-
"@com_google_absl//absl/status:statusor",
249-
"@com_google_absl//absl/strings",
250-
"@com_google_absl//absl/strings:str_format",
251-
"@com_google_absl//absl/synchronization",
252-
"@com_google_absl//absl/types:span",
253-
"@llvm-project//llvm:Analysis",
254-
"@llvm-project//llvm:AsmParser",
255-
"@llvm-project//llvm:Core",
256-
"@llvm-project//llvm:ExecutionEngine",
257-
"@llvm-project//llvm:JITLink",
258-
"@llvm-project//llvm:OrcJIT",
259-
"@llvm-project//llvm:OrcShared",
260-
"@llvm-project//llvm:Passes",
261-
"@llvm-project//llvm:Support",
262-
"@llvm-project//llvm:Target",
263-
"@llvm-project//llvm:TargetParser",
264-
"@llvm-project//llvm:TransformUtils",
265-
"@llvm-project//llvm:ir_headers",
266-
"@tsl//tsl/platform:statusor",
267-
] + if_llvm_aarch32_available([
268-
"@llvm-project//llvm:ARMAsmParser",
269-
"@llvm-project//llvm:ARMCodeGen",
270-
]) + if_llvm_aarch64_available([
271-
"@llvm-project//llvm:AArch64AsmParser",
272-
"@llvm-project//llvm:AArch64CodeGen",
273-
]) + if_llvm_powerpc_available([
274-
"@llvm-project//llvm:PowerPCAsmParser",
275-
"@llvm-project//llvm:PowerPCCodeGen",
276-
]) + if_llvm_system_z_available([
277-
"@llvm-project//llvm:SystemZAsmParser",
278-
"@llvm-project//llvm:SystemZCodeGen",
279-
]) + if_llvm_x86_available([
280-
"@llvm-project//llvm:X86AsmParser",
281-
"@llvm-project//llvm:X86CodeGen",
282-
]),
283-
alwayslink = 1, # static kernel function loader registration
284-
)

xla/stream_executor/host/host_executor.cc

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,10 @@ limitations under the License.
2222

2323
#include <cstdint>
2424
#include <memory>
25-
#include <new>
2625
#include <optional>
2726
#include <string>
2827
#include <utility>
2928
#include <variant>
30-
#include <vector>
3129

3230
#include "absl/log/check.h"
3331
#include "absl/log/log.h"
@@ -38,18 +36,15 @@ limitations under the License.
3836
#include "xla/stream_executor/device_memory.h"
3937
#include "xla/stream_executor/event.h"
4038
#include "xla/stream_executor/host/host_event.h"
41-
#include "xla/stream_executor/host/host_kernel.h"
4239
#include "xla/stream_executor/host/host_stream.h"
4340
#include "xla/stream_executor/kernel.h"
4441
#include "xla/stream_executor/kernel_spec.h"
4542
#include "xla/stream_executor/platform.h"
4643
#include "xla/stream_executor/stream.h"
4744
#include "xla/tsl/platform/profile_utils/cpu_utils.h"
45+
#include "xla/tsl/platform/threadpool.h"
4846
#include "tsl/platform/cpu_info.h"
49-
#include "tsl/platform/env.h"
5047
#include "tsl/platform/mem.h"
51-
#include "tsl/platform/statusor.h"
52-
#include "tsl/platform/threadpool.h"
5348

5449
namespace stream_executor {
5550
namespace host {
@@ -59,16 +54,6 @@ HostStream* AsHostStream(Stream* stream) {
5954
return dynamic_cast<HostStream*>(stream);
6055
}
6156

62-
static std::vector<HostExecutor::KernelFunctionLoader>&
63-
KernelFunctionLoaderRegistry() {
64-
static auto* registry = new std::vector<HostExecutor::KernelFunctionLoader>();
65-
return *registry;
66-
}
67-
68-
void HostExecutor::RegisterKernelFunctionLoader(KernelFunctionLoader loader) {
69-
KernelFunctionLoaderRegistry().push_back(std::move(loader));
70-
}
71-
7257
absl::Status HostExecutor::Init() {
7358
thread_pool_ = std::make_shared<tsl::thread::ThreadPool>(
7459
tsl::Env::Default(), "host-executor", tsl::port::MaxParallelism());
@@ -77,18 +62,6 @@ absl::Status HostExecutor::Init() {
7762

7863
absl::StatusOr<std::unique_ptr<Kernel>> HostExecutor::LoadKernel(
7964
const MultiKernelLoaderSpec& spec) {
80-
auto host_kernel = std::make_unique<HostKernel>(thread_pool_);
81-
host_kernel->SetArity(spec.arity());
82-
83-
for (auto& loader : KernelFunctionLoaderRegistry()) {
84-
auto loaded = loader(spec);
85-
if (!loaded.has_value()) continue;
86-
87-
TF_ASSIGN_OR_RETURN(auto kernel_function, *std::move(loaded));
88-
host_kernel->SetKernelFunction(std::move(kernel_function));
89-
return std::move(host_kernel);
90-
}
91-
9265
return absl::InternalError("No method of loading host kernel provided");
9366
}
9467

xla/stream_executor/host/host_executor.h

Lines changed: 1 addition & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,6 @@ limitations under the License.
1717
#define XLA_STREAM_EXECUTOR_HOST_HOST_EXECUTOR_H_
1818

1919
#include <cstdint>
20-
#include <functional>
2120
#include <memory>
2221
#include <optional>
2322
#include <variant>
@@ -27,15 +26,14 @@ limitations under the License.
2726
#include "xla/stream_executor/device_description.h"
2827
#include "xla/stream_executor/device_memory.h"
2928
#include "xla/stream_executor/event.h"
30-
#include "xla/stream_executor/host/host_kernel.h"
3129
#include "xla/stream_executor/host_memory_allocation.h"
3230
#include "xla/stream_executor/kernel.h"
3331
#include "xla/stream_executor/kernel_spec.h"
3432
#include "xla/stream_executor/memory_allocation.h"
3533
#include "xla/stream_executor/platform.h"
3634
#include "xla/stream_executor/stream.h"
3735
#include "xla/stream_executor/stream_executor_common.h"
38-
#include "tsl/platform/threadpool.h"
36+
#include "xla/tsl/platform/threadpool.h"
3937

4038
namespace stream_executor {
4139
namespace host {
@@ -48,15 +46,6 @@ namespace host {
4846
// routines executed under the context of a GPU executor.
4947
class HostExecutor : public StreamExecutorCommon {
5048
public:
51-
// A function that loads a kernel function from a given spec. If spec is not
52-
// supported it returns an empty optional.
53-
using KernelFunctionLoader = std::function<std::optional<
54-
absl::StatusOr<std::unique_ptr<HostKernel::KernelFunction>>>(
55-
const MultiKernelLoaderSpec& spec)>;
56-
57-
// Registers a kernel function loader in a static registry.
58-
static void RegisterKernelFunctionLoader(KernelFunctionLoader loader);
59-
6049
HostExecutor(Platform* platform, int device_ordinal)
6150
: StreamExecutorCommon(platform), device_ordinal_(device_ordinal) {}
6251

0 commit comments

Comments
 (0)