diff --git a/mace/utils/thread_pool.cc b/mace/utils/thread_pool.cc index 8d7d98c8535065b9ac1a9a55325f441898bec4a1..8cbdbf140e65c4aee6c22378b6996d8616c7ee24 100644 --- a/mace/utils/thread_pool.cc +++ b/mace/utils/thread_pool.cc @@ -175,7 +175,7 @@ void ThreadPool::Run(const std::function &func, for (size_t i = 0; i < thread_count; ++i) { int64_t count = iters_per_thread + (static_cast(i) < remainder); thread_infos_[i].range_start = iters_offset; - int64_t range_end = std::min(iterations, iters_offset + count); + int64_t range_end = iters_offset + count; thread_infos_[i].range_end = range_end; thread_infos_[i].range_len = range_end - iters_offset; thread_infos_[i].func = reinterpret_cast(&func); @@ -306,7 +306,7 @@ void ThreadPool::Compute1D(const std::function= 0 && items * cost_per_item < kMaxCostUsingSingleThread)) { func(start, end, step); @@ -317,11 +317,11 @@ void ThreadPool::Compute1D(const std::function(1), items / default_tile_count_); } - int64_t step_tile_size = step * tile_size; - int64_t tile_count = RoundUpDiv(items, tile_size); - Run([&](int64_t tile_idx) { - int64_t tile_start = start + tile_idx * step_tile_size; - int64_t tile_end = std::min(end, tile_start + step_tile_size); + const int64_t step_tile_size = step * tile_size; + const int64_t tile_count = RoundUpDiv(items, tile_size); + Run([=](int64_t tile_idx) { + const int64_t tile_start = start + tile_idx * step_tile_size; + const int64_t tile_end = std::min(end, tile_start + step_tile_size); func(tile_start, tile_end, step); }, tile_count); } @@ -345,8 +345,8 @@ void ThreadPool::Compute2D(const std::function= 0 && items0 * items1 * cost_per_item < kMaxCostUsingSingleThread)) { func(start0, end0, step0, start1, end1, step1); @@ -364,18 +364,18 @@ void ThreadPool::Compute2D(const std::function= 0 && items0 * items1 * items2 * cost_per_item < kMaxCostUsingSingleThread)) { @@ -423,7 +423,7 @@ void ThreadPool::Compute3D(const std::function= default_tile_count_) { tile_size1 = items01 / default_tile_count_; tile_size2 = items2; @@ -435,25 +435,25 @@ void ThreadPool::Compute3D(const std::function