diff --git a/tensorflow/core/lib/core/threadpool.cc b/tensorflow/core/lib/core/threadpool.cc index 59d77a37344..a2245bb28ec 100644 --- a/tensorflow/core/lib/core/threadpool.cc +++ b/tensorflow/core/lib/core/threadpool.cc @@ -123,15 +123,6 @@ void ThreadPool::ParallelFor(int64 total, int64 cost_per_unit, impl_->ParallelFor(total, cost_per_unit, std::move(fn)); } -void ThreadPool::ParallelForWithWorkerId( - int64 total, int64 cost_per_unit, - const std::function& fn) { - impl_->ParallelFor(total, cost_per_unit, - [this, &fn](int64 start, int64 limit) { - fn(start, limit, CurrentThreadId()); - }); -} - int ThreadPool::NumThreads() const { return impl_->NumThreads(); } int ThreadPool::CurrentThreadId() const { return impl_->CurrentThreadId(); } diff --git a/tensorflow/core/lib/core/threadpool.h b/tensorflow/core/lib/core/threadpool.h index 4d791721b43..371339598d3 100644 --- a/tensorflow/core/lib/core/threadpool.h +++ b/tensorflow/core/lib/core/threadpool.h @@ -47,7 +47,7 @@ class ThreadPool { // Schedule fn() for execution in the pool of threads. void Schedule(std::function fn); - // ParallelFor shards the "total" units of work assuming each unit of work + // ParallelFor shards the "total" unit of work assuming each unit of work // having roughly "cost_per_unit" cost, in cycles. Each unit of work is // indexed 0, 1, ..., total - 1. Each shard contains 1 or more units of work // and the total cost of each shard is roughly the same. @@ -60,15 +60,6 @@ class ThreadPool { void ParallelFor(int64 total, int64 cost_per_unit, std::function fn); - // Shard the "total" units of work. For more details, see "ParallelFor". - // - // The function is passed a thread_id in the range [0, NumThreads()]. The - // functions can safely write to a partial result for their id, in a tensor of - // size (NumThreads(), ...). - void ParallelForWithWorkerId( - int64 total, int64 cost_per_unit, - const std::function& fn); - // Returns the number of threads in the pool. int NumThreads() const; diff --git a/tensorflow/core/lib/core/threadpool_test.cc b/tensorflow/core/lib/core/threadpool_test.cc index cecdc343799..c7d8db51364 100644 --- a/tensorflow/core/lib/core/threadpool_test.cc +++ b/tensorflow/core/lib/core/threadpool_test.cc @@ -80,42 +80,6 @@ TEST(ThreadPool, ParallelFor) { } } -TEST(ThreadPool, ParallelForWithWorkerId) { - // Make ParallelForWithWorkerId use as many threads as possible. - int64 kHugeCost = 1 << 30; - for (int num_threads = 1; num_threads < kNumThreads; num_threads++) { - fprintf(stderr, "Testing with %d threads\n", num_threads); - const int kWorkItems = 15; - bool work[kWorkItems]; - ThreadPool pool(Env::Default(), "test", num_threads); - for (int i = 0; i < kWorkItems; i++) { - work[i] = false; - } - std::atomic threads_running[kNumThreads]; - for (int i = 0; i < num_threads; i++) { - threads_running[i] = false; - } - pool.ParallelForWithWorkerId( - kWorkItems, kHugeCost, - [&threads_running, &work](int64 begin, int64 end, int64 id) { - // Store true for the current thread, and assert that another thread - // is not running with the same id. - ASSERT_FALSE(threads_running[id].exchange(true)); - for (int64 i = begin; i < end; ++i) { - ASSERT_FALSE(work[i]); - work[i] = true; - } - ASSERT_TRUE(threads_running[id].exchange(false)); - }); - for (int i = 0; i < kWorkItems; i++) { - ASSERT_TRUE(work[i]); - } - for (int i = 0; i < num_threads; i++) { - ASSERT_FALSE(threads_running[i]); - } - } -} - static void BM_Sequential(int iters) { ThreadPool pool(Env::Default(), "test", kNumThreads); // Decrement count sequentially until 0.