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

Simplify stream_executor BUILD file after recent changes. #19197

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
242 changes: 96 additions & 146 deletions xla/stream_executor/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ load("@tsl//tsl/platform:rules_cc.bzl", "cc_library")
load("//xla:xla.bzl", "xla_cc_test")
load("//xla/stream_executor:build_defs.bzl", "stream_executor_build_defs_bzl_deps", "stream_executor_friends", "stream_executor_internal")
load("//xla/tsl:tsl.bzl", "if_google", "if_oss", "internal_visibility")
load("//xla/tsl:tsl.default.bzl", "filegroup")

package(
# copybara:uncomment default_applicable_licenses = ["//tensorflow:license"],
Expand Down Expand Up @@ -41,63 +40,35 @@ bzl_library(
# StreamExecutor public API
#===--------------------------------------------------------------------------------------------===#

# If you want to use StreamExecutor you have to depend on the "core" `xla/stream_executor` target
# defined below which exports StreamExecutor public API headers and also provides implemenetation.

# StreamExecutor also have a small number of public libraries that do not depend on StreamExecutor
# itself (e.g. `device_description`), this is mostly a result of StreamExecutor being a hardware
# abstraction layer for XLA (and Tensorflow).

# StreamExecutor itself is a small abstrtaction layer on top of platform-specific API
# implementations (e.g. see `stream_executor/cuda` folder for CUDA-specific details), and should
# not contribute a lot to binary size or compilation time.

# We bundle headers into filegroups for internal use only (we re-export the same set of headers
# from multiple targets), and all external clients should depend on one of the public `cc_library`
# targets that have dependencies required for compiling headers (e.g. absl dependencies). These
# filegroup roughly correspond to "StreamExecutor components" that are available to the clients.

# These are the headers that constitute StreamExecutor public API. Clients should not depend on
# this filegroup directly, but instead depend on a `stream_executor` target that implements these
# headers.
# TODO(ezhulenev): Remove from public API headers that are exported via standalone public libraries,
# e.g. `platform` and `platform_manager` should be added with an explicit dependency.
filegroup(
name = "stream_executor_api_headers",
srcs = [
"device_description.h",
"device_memory.h",
"device_memory_allocator.h",
"kernel.h",
"launch_dim.h",
"platform.h",
"platform_manager.h",
"scratch_allocator.h",
"stream.h",
"stream_executor.h",
],
visibility = ["//visibility:private"],
)

# TODO(klucke) Remove this target once the final user of this target is changed to use "stream" instead.
cc_library(
name = "stream_executor",
hdrs = [
":stream_executor_api_headers",
"stream.h",
],
deps = [
":activate_context",
":allocator_stats",
":blas",
":command_buffer",
":data_type",
":device_description",
":device_description_proto_cc",
":device_memory",
":device_memory_allocator",
":dnn",
":event",
":event_based_timer",
":fft",
":host_memory_allocation", # build_cleaner: keep
":host_or_device_scalar",
":kernel",
":kernel_spec",
":launch_dim",
":memory_allocation",
":module_spec",
":numeric_options",
Expand Down Expand Up @@ -407,10 +378,6 @@ cc_library(
# StreamExecutor plugins
#===--------------------------------------------------------------------------------------------===#

# TODO(ezhulenev): Today all StreamExecutor plugins are linked by default into the `stream_executor`
# target and leak into "core" APIs. We should decouple all plugins into optional dependencies, and
# make sure that they are not exposed via "core" APIs (se::Stream, se::StreamExecutor, etc.).

cc_library(
name = "blas",
srcs = ["blas.cc"],
Expand Down Expand Up @@ -467,8 +434,6 @@ cc_library(
cc_library(
name = "fft",
hdrs = ["fft.h"],
deps = [
],
)

cc_library(
Expand All @@ -486,17 +451,6 @@ cc_library(
],
)

#===--------------------------------------------------------------------------------------------===#
# StreamExecutor platform-dependent interfaces
#===--------------------------------------------------------------------------------------------===#

# Only platform-dependent StreamExecutor implementations (e.g. StreamExecutor for GPUs) and targets
# defined by StreamExecutor itself (e.g. `event`, `kernel`, etc.) can depend on internal
# interfaces (interfaces that define platform-specific API).
#
# External clients of StreamExecutor should depend on `stream_executor` target (links StreamExecutor
# implementation in static build configuration).

cc_library(
name = "stream_executor_h",
hdrs = [
Expand Down Expand Up @@ -552,41 +506,6 @@ cc_library(
],
)

#===--------------------------------------------------------------------------------------------===#
# StreamExecutor internal implementation (visible to StreamExecutor platform implementations)
#===--------------------------------------------------------------------------------------------===#

cc_library(
name = "plugin_registry",
srcs = ["plugin_registry.cc"],
hdrs = ["plugin_registry.h"],
visibility = [":internal"],
deps = [
":blas",
":dnn",
":fft",
":platform",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
],
)

#===--------------------------------------------------------------------------------------------===#
# StreamExecutor private implementation (has private visibility)
#===--------------------------------------------------------------------------------------------===#

cc_library(
name = "allocator_stats",
srcs = ["allocator_stats.cc"],
hdrs = ["allocator_stats.h"],
visibility = [":internal"],
deps = ["@com_google_absl//absl/strings:str_format"],
)

cc_library(
name = "event_based_timer",
hdrs = ["event_based_timer.h"],
Expand All @@ -596,41 +515,6 @@ cc_library(
],
)

cc_library(
name = "command_buffer",
hdrs = ["command_buffer.h"],
visibility = [":internal"],
deps = [
":bit_pattern",
":device_memory",
":kernel",
":launch_dim",
":platform",
"//xla/tsl/lib/gtl:int_type",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/status",
"@com_google_absl//absl/types:span",
"@tsl//tsl/platform:errors",
],
)

cc_library(
name = "trace_command_buffer_factory",
srcs = ["trace_command_buffer_factory.cc"],
hdrs = ["trace_command_buffer_factory.h"],
visibility = [":internal"],
deps = [
":command_buffer",
":stream",
":stream_executor_h",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@tsl//tsl/platform:errors",
"@tsl//tsl/platform:statusor",
],
)

cc_library(
name = "executor_cache",
srcs = ["executor_cache.cc"],
Expand Down Expand Up @@ -707,31 +591,80 @@ cc_library(
],
)

cc_test(
name = "semantic_version_test",
srcs = ["semantic_version_test.cc"],
cc_library(
name = "scratch_allocator",
hdrs = ["scratch_allocator.h"],
deps = [
":semantic_version",
"@com_google_absl//absl/hash:hash_testing",
":device_memory",
":device_memory_allocator",
"@com_google_absl//absl/container:inlined_vector",
"@com_google_absl//absl/status:statusor",
"@tsl//tsl/platform:statusor",
],
)

#===--------------------------------------------------------------------------------------------===#
# StreamExecutor internal implementation (visible to StreamExecutor platform implementations)
#===--------------------------------------------------------------------------------------------===#

cc_library(
name = "plugin_registry",
srcs = ["plugin_registry.cc"],
hdrs = ["plugin_registry.h"],
visibility = [":internal"],
deps = [
":blas",
":dnn",
":fft",
":platform",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/log",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
"@tsl//tsl/platform:status_matchers",
"@tsl//tsl/platform:test",
"@tsl//tsl/platform:test_main",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
],
)

cc_library(
name = "scratch_allocator",
hdrs = ["scratch_allocator.h"],
name = "allocator_stats",
srcs = ["allocator_stats.cc"],
hdrs = ["allocator_stats.h"],
visibility = [":internal"],
deps = ["@com_google_absl//absl/strings:str_format"],
)

cc_library(
name = "command_buffer",
hdrs = ["command_buffer.h"],
visibility = [":internal"],
deps = [
":bit_pattern",
":device_memory",
":device_memory_allocator",
"@com_google_absl//absl/container:inlined_vector",
":kernel",
":launch_dim",
":platform",
"//xla/tsl/lib/gtl:int_type",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/status",
"@com_google_absl//absl/types:span",
"@tsl//tsl/platform:errors",
],
)

cc_library(
name = "trace_command_buffer_factory",
srcs = ["trace_command_buffer_factory.cc"],
hdrs = ["trace_command_buffer_factory.h"],
visibility = [":internal"],
deps = [
":command_buffer",
":stream",
":stream_executor_h",
"@com_google_absl//absl/functional:any_invocable",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@tsl//tsl/platform:errors",
"@tsl//tsl/platform:statusor",
],
)
Expand Down Expand Up @@ -778,7 +711,14 @@ cc_library(
"@tsl//tsl/platform:thread_annotations",
],
)
#===--------------------------------------------------------------------------------------------===#

cc_library(
name = "bit_pattern",
srcs = ["bit_pattern.cc"],
hdrs = ["bit_pattern.h"],
visibility = [":internal"],
deps = ["@com_google_absl//absl/strings"],
)

# We have a separate `stream_executor_impl` target because in open source we are building multiple
# shared libraries and then link them together (this is an implementation detail of Tensorflow
Expand Down Expand Up @@ -813,6 +753,23 @@ cc_library(
# StreamExecutor tests
#===--------------------------------------------------------------------------------------------===#

cc_test(
name = "semantic_version_test",
srcs = ["semantic_version_test.cc"],
deps = [
":semantic_version",
"@com_google_absl//absl/hash:hash_testing",
"@com_google_absl//absl/status",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:string_view",
"@com_google_googletest//:gtest_main",
"@tsl//tsl/platform:status_matchers",
"@tsl//tsl/platform:test",
"@tsl//tsl/platform:test_main",
],
)

xla_cc_test(
name = "kernel_test",
srcs = ["kernel_test.cc"],
Expand Down Expand Up @@ -941,13 +898,6 @@ xla_cc_test(
],
)

cc_library(
name = "bit_pattern",
srcs = ["bit_pattern.cc"],
hdrs = ["bit_pattern.h"],
deps = ["@com_google_absl//absl/strings"],
)

cc_test(
name = "bit_pattern_test",
srcs = ["bit_pattern_test.cc"],
Expand Down
Loading