Skip to content

Commit

Permalink
Replace some usage of tsl::BlockingCounter with absl::BlockingCounter.
Browse files Browse the repository at this point in the history
No functional change is intended.

PiperOrigin-RevId: 705732369
  • Loading branch information
majnemer authored and Google-ML-Automation committed Dec 13, 2024
1 parent 8102719 commit 3651bb8
Show file tree
Hide file tree
Showing 11 changed files with 20 additions and 23 deletions.
2 changes: 1 addition & 1 deletion xla/backends/profiler/cpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -133,9 +133,9 @@ xla_cc_test(
"//xla/tsl/profiler/utils:timespan",
"//xla/tsl/profiler/utils:xplane_schema",
"//xla/tsl/profiler/utils:xplane_visitor",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/types:optional",
"@com_google_googletest//:gtest_main",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:test",
"@tsl//tsl/platform:types",
Expand Down
4 changes: 2 additions & 2 deletions xla/backends/profiler/cpu/host_tracer_test.cc
Original file line number Diff line number Diff line change
Expand Up @@ -20,13 +20,13 @@ limitations under the License.
#include <string>

#include <gtest/gtest.h>
#include "absl/synchronization/blocking_counter.h"
#include "absl/types/optional.h"
#include "xla/tsl/lib/core/status_test_util.h"
#include "xla/tsl/profiler/utils/tf_xplane_visitor.h"
#include "xla/tsl/profiler/utils/timespan.h"
#include "xla/tsl/profiler/utils/xplane_schema.h"
#include "xla/tsl/profiler/utils/xplane_visitor.h"
#include "tsl/platform/blocking_counter.h"
#include "tsl/platform/env.h"
#include "tsl/platform/test.h"
#include "tsl/platform/threadpool.h"
Expand Down Expand Up @@ -166,7 +166,7 @@ TEST(HostTracerTest, CollectEventsFromThreadPool) {
std::make_unique<tsl::thread::ThreadPool>(/*env=*/Env::Default(),
/*name=*/"HostTracerTest",
/*num_threads=*/1);
tsl::BlockingCounter counter(1);
absl::BlockingCounter counter(1);
auto tracer = CreateHostTracer({});
TF_EXPECT_OK(tracer->Start());
thread_pool->Schedule([&counter] {
Expand Down
15 changes: 7 additions & 8 deletions xla/service/cpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1316,11 +1316,10 @@ cc_library(
"//xla:executable_run_options",
"//xla/service:custom_call_status_internal",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:logging",
],
)
Expand Down Expand Up @@ -1727,8 +1726,8 @@ cc_library(
":onednn_config_proto_cc",
"//xla:xla_data_proto_cc",
"//xla/hlo/ir:hlo",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:platform_port",
] + mkl_deps(),
Expand Down Expand Up @@ -1781,8 +1780,8 @@ cc_library(
"//xla/hlo/ir:hlo",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:logging",
"@tsl//tsl/platform:platform_port",
Expand All @@ -1805,8 +1804,8 @@ cc_library(
"//xla:shape_util",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:logging",
"@tsl//tsl/platform:platform_port",
Expand All @@ -1830,8 +1829,8 @@ cc_library(
"//xla:executable_run_options",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:platform_port",
] + mkl_deps(),
Expand All @@ -1854,8 +1853,8 @@ cc_library(
"//xla:executable_run_options",
"@com_google_absl//absl/base:core_headers",
"@com_google_absl//absl/base:dynamic_annotations",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:platform_port",
] + mkl_deps(),
Expand Down Expand Up @@ -1900,8 +1899,8 @@ cc_library(
"//xla/service:pattern_matcher",
"@com_google_absl//absl/algorithm:container",
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/synchronization",
"@eigen_archive//:eigen3",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:logging",
"@tsl//tsl/platform:platform_port",
Expand Down
4 changes: 2 additions & 2 deletions xla/service/cpu/runtime_fork_join.cc
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ limitations under the License.
#include "absl/base/attributes.h"
#include "absl/strings/str_cat.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/blocking_counter.h"

#define EIGEN_USE_THREADS

Expand All @@ -32,7 +33,6 @@ limitations under the License.
#include "unsupported/Eigen/CXX11/Tensor"
#include "xla/executable_run_options.h"
#include "xla/service/custom_call_status_internal.h"
#include "tsl/platform/blocking_counter.h"
#include "tsl/platform/logging.h"

using ComputeFunctionType = void (*)(void*, const void*, const void**, void**,
Expand Down Expand Up @@ -91,7 +91,7 @@ ABSL_ATTRIBUTE_NO_SANITIZE_MEMORY void __xla_cpu_runtime_ParallelForkJoin(
std::vector<XlaCustomCallStatus> statuses(num_partitions);

// Dispatch 'num_partitions - 1' compute functions to run in parallel.
tsl::BlockingCounter bc(num_partitions - 1);
absl::BlockingCounter bc(num_partitions - 1);
for (int32_t i = 1; i < num_partitions; ++i) {
const int64_t offset = i * stride;
run_options->intra_op_thread_pool()->enqueueNoNotification(
Expand Down
2 changes: 1 addition & 1 deletion xla/service/gpu/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -1405,6 +1405,7 @@ cc_library(
"@com_google_absl//absl/status:statusor",
"@com_google_absl//absl/strings",
"@com_google_absl//absl/strings:str_format",
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/types:span",
"@com_google_absl//absl/types:variant",
"@llvm-project//llvm:AsmParser",
Expand Down Expand Up @@ -1606,7 +1607,6 @@ cc_library(
"//xla:util",
"//xla:xla_data_proto_cc",
"//xla:xla_proto_cc",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:casts",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:errors",
Expand Down
1 change: 0 additions & 1 deletion xla/service/gpu/autotuning/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -177,7 +177,6 @@ cc_library(
"@com_google_absl//absl/synchronization",
"@com_google_absl//absl/time",
"@com_google_absl//absl/types:span",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:errors",
"@tsl//tsl/platform:path",
Expand Down
4 changes: 2 additions & 2 deletions xla/service/gpu/autotuning/gemm_fusion_autotuner.cc
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ limitations under the License.
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/blocking_counter.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
#include "absl/types/span.h"
Expand Down Expand Up @@ -99,7 +100,6 @@ limitations under the License.
#include "xla/util.h"
#include "xla/xla.pb.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/blocking_counter.h"
#include "tsl/platform/env.h"
#include "tsl/platform/errors.h"
#include "tsl/platform/path.h"
Expand Down Expand Up @@ -989,7 +989,7 @@ GemmFusionAutotunerImpl::CompileAll(AutotunerCompileUtil& compile_util,
<< " fusions on " << thread_pool_->NumThreads() << " threads.";
}

tsl::BlockingCounter counter(config_count);
absl::BlockingCounter counter(config_count);
for (const auto& key_value : task) {
const HloFusionInstruction* fusion = key_value.first;
const std::vector<BackendConfig>& gemm_config_set = key_value.second;
Expand Down
4 changes: 2 additions & 2 deletions xla/service/gpu/gpu_compiler.cc
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ limitations under the License.
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/blocking_counter.h"
#include "absl/types/span.h"
#include "absl/types/variant.h"
#include "llvm/ADT/DenseMap.h"
Expand Down Expand Up @@ -264,7 +265,6 @@ limitations under the License.
#include "xla/util.h"
#include "xla/xla.pb.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/blocking_counter.h"
#include "tsl/platform/casts.h"
#include "tsl/platform/cpu_info.h"
#include "tsl/platform/env.h"
Expand Down Expand Up @@ -2146,7 +2146,7 @@ absl::StatusOr<GpuCompiler::BackendCompileResult> GpuCompiler::CompileAndLink(
};
std::vector<NamedCompileResult> compile_results(llvm_modules.size());
if (thread_pool.get() != nullptr) {
tsl::BlockingCounter counter(llvm_modules.size());
absl::BlockingCounter counter(llvm_modules.size());
for (int i = 0; i < llvm_modules.size(); ++i) {
thread_pool.get_mutable()->Schedule(
[&compile_results, i, &llvm_modules, &counter, this, &module_config,
Expand Down
1 change: 0 additions & 1 deletion xla/service/gpu/transforms/BUILD
Original file line number Diff line number Diff line change
Expand Up @@ -2429,7 +2429,6 @@ cc_library(
"@com_google_absl//absl/time",
"@llvm-project//llvm:Support",
"@llvm-project//mlir:IR",
"@tsl//tsl/platform:blocking_counter",
"@tsl//tsl/platform:env",
"@tsl//tsl/platform:errors",
"@tsl//tsl/platform:logging",
Expand Down
4 changes: 2 additions & 2 deletions xla/service/gpu/transforms/priority_fusion.cc
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ limitations under the License.
#include "absl/strings/str_cat.h"
#include "absl/strings/str_format.h"
#include "absl/strings/string_view.h"
#include "absl/synchronization/blocking_counter.h"
#include "absl/synchronization/mutex.h"
#include "absl/time/time.h"
#include "llvm/ADT/STLExtras.h"
Expand Down Expand Up @@ -65,7 +66,6 @@ limitations under the License.
#include "xla/shape_util.h"
#include "xla/stream_executor/device_description.h"
#include "xla/xla_data.pb.h"
#include "tsl/platform/blocking_counter.h"
#include "tsl/platform/errors.h"
#include "tsl/platform/logging.h"
#include "tsl/platform/status.h"
Expand Down Expand Up @@ -226,7 +226,7 @@ class PriorityFusionQueue {
fn();
}
};
tsl::BlockingCounter counter(instructions.size());
absl::BlockingCounter counter(instructions.size());
std::vector<Priority> priorities(instructions.size());

for (size_t i = 0; i < instructions.size(); ++i) {
Expand Down
2 changes: 1 addition & 1 deletion xla/tsl/util/onednn_threadpool.h
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ class OneDnnThreadPool : public threadpool_iface {
}
run_jobs(balance, njobs_to_schedule, n, njobs, fn);
} else {
tsl::BlockingCounter counter(njobs);
absl::BlockingCounter counter(njobs);
std::function<void(int, int)> handle_range = [=, &handle_range, &counter](
int first, int last) {
while (last - first > 1) {
Expand Down

0 comments on commit 3651bb8

Please sign in to comment.