Skip to content

Commit e053ff7

Browse files
committed
Rename AddWork to AddTask.
Signed-off-by: Michal Zientkiewicz <michalz@nvidia.com>
1 parent 2e382c4 commit e053ff7

File tree

79 files changed

+202
-195
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+202
-195
lines changed

dali/benchmark/thread_pool_bench.cc

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2020-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright (c) 2020-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -27,7 +27,7 @@ static void ThreadPoolArgs(benchmark::internal::Benchmark *b) {
2727
b->Args({batch_size, work_size_min, work_size_max, nthreads});
2828
}
2929

30-
BENCHMARK_DEFINE_F(ThreadPoolBench, AddWork)(benchmark::State& st) {
30+
BENCHMARK_DEFINE_F(ThreadPoolBench, AddTask)(benchmark::State& st) {
3131
int batch_size = st.range(0);
3232
int work_size_min = st.range(1);
3333
int work_size_max = st.range(2);
@@ -40,7 +40,7 @@ BENCHMARK_DEFINE_F(ThreadPoolBench, AddWork)(benchmark::State& st) {
4040
while (st.KeepRunning()) {
4141
for (int i = 0; i < batch_size; i++) {
4242
auto size = this->RandInt(work_size_min, work_size_max);
43-
thread_pool.AddWork(
43+
thread_pool.AddTask(
4444
[&data, size, &total_count](int thread_id){
4545
std::vector<uint8_t> other_data;
4646
for (int i = 0; i < size; i++) {
@@ -59,13 +59,13 @@ BENCHMARK_DEFINE_F(ThreadPoolBench, AddWork)(benchmark::State& st) {
5959
std::cout << total_count << std::endl;
6060
}
6161

62-
BENCHMARK_REGISTER_F(ThreadPoolBench, AddWork)->Iterations(1000)
62+
BENCHMARK_REGISTER_F(ThreadPoolBench, AddTask)->Iterations(1000)
6363
->Unit(benchmark::kMicrosecond)
6464
->UseRealTime()
6565
->Apply(ThreadPoolArgs);
6666

6767

68-
BENCHMARK_DEFINE_F(ThreadPoolBench, AddWorkDeferred)(benchmark::State& st) {
68+
BENCHMARK_DEFINE_F(ThreadPoolBench, AddTaskDeferred)(benchmark::State& st) {
6969
int batch_size = st.range(0);
7070
int work_size_min = st.range(1);
7171
int work_size_max = st.range(2);
@@ -78,7 +78,7 @@ BENCHMARK_DEFINE_F(ThreadPoolBench, AddWorkDeferred)(benchmark::State& st) {
7878
while (st.KeepRunning()) {
7979
for (int i = 0; i < batch_size; i++) {
8080
auto size = this->RandInt(work_size_min, work_size_max);
81-
thread_pool.AddWork(
81+
thread_pool.AddTask(
8282
[&data, size, &total_count](int thread_id){
8383
std::vector<uint8_t> other_data;
8484
for (int i = 0; i < size; i++) {
@@ -98,7 +98,7 @@ BENCHMARK_DEFINE_F(ThreadPoolBench, AddWorkDeferred)(benchmark::State& st) {
9898
}
9999

100100

101-
BENCHMARK_REGISTER_F(ThreadPoolBench, AddWorkDeferred)->Iterations(1000)
101+
BENCHMARK_REGISTER_F(ThreadPoolBench, AddTaskDeferred)->Iterations(1000)
102102
->Unit(benchmark::kMicrosecond)
103103
->UseRealTime()
104104
->Apply(ThreadPoolArgs);

dali/core/exec/thread_pool_base.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ void ThreadPoolBase::PopAndRunTask(std::unique_lock<std::mutex> &lock) {
125125
TaskFunc t = std::move(tasks_.front());
126126
tasks_.pop();
127127
lock.unlock();
128-
t();
128+
t(this_thread_idx());
129129
lock.lock();
130130
}
131131

dali/core/exec/thread_pool_base_test.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,10 @@ namespace dali {
2020

2121
struct SerialExecutor {
2222
template <typename Runnable>
23-
std::enable_if_t<std::is_convertible_v<Runnable, std::function<void()>>>
23+
std::enable_if_t<std::is_convertible_v<Runnable, std::function<void(int)>>>
2424
AddTask(Runnable &&runnable) {
25-
runnable();
25+
const int idx = 0;
26+
runnable(idx);
2627
}
2728
};
2829

dali/imgcodec/decoders/decoder_parallel_impl.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -104,7 +104,7 @@ class DLL_PUBLIC BatchParallelDecoderImpl : public ImageDecoderImpl {
104104
ROI no_roi;
105105
for (int i = 0; i < in.size(); i++) {
106106
auto roi = rois.empty() ? no_roi : rois[i];
107-
ctx.tp->AddWork([=, out = out[i], in = in[i]](int tid) mutable {
107+
ctx.tp->AddTask([=, out = out[i], in = in[i]](int tid) mutable {
108108
try {
109109
promise.set(i, DecodeImplTask(tid, out, in, opts, roi));
110110
} catch (...) {
@@ -128,7 +128,7 @@ class DLL_PUBLIC BatchParallelDecoderImpl : public ImageDecoderImpl {
128128
ROI no_roi;
129129
for (int i = 0; i < in.size(); i++) {
130130
auto roi = rois.empty() ? no_roi : rois[i];
131-
ctx.tp->AddWork([=, out = out[i], in = in[i]](int tid) mutable {
131+
ctx.tp->AddTask([=, out = out[i], in = in[i]](int tid) mutable {
132132
try {
133133
promise.set(i, DecodeImplTask(tid, ctx.stream, out, in, opts, roi));
134134
} catch (...) {

dali/imgcodec/decoders/nvjpeg_lossless/nvjpeg_lossless.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ void NvJpegLosslessDecoderInstance::Parse(DecodeResultsPromise &promise,
114114
DecodeResultsPromise parse_promise(nsamples);
115115
for (int i = 0; i < nsamples; i++) {
116116
int tid = 0;
117-
ctx.tp->AddWork(
117+
ctx.tp->AddTask(
118118
[&, i](int tid) {
119119
auto &jpeg_stream = per_thread_resources_[tid].jpeg_stream;
120120
auto *sample = in[i];

dali/imgcodec/future_decode_result_test.cc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -29,7 +29,7 @@ TEST(FutureDecodeResultsTest, WaitNew) {
2929

3030
DecodeResultsPromise pro(3);
3131
auto fut = pro.get_future();
32-
tp.AddWork([pro](int tidx) mutable {
32+
tp.AddTask([pro](int tidx) mutable {
3333
std::this_thread::sleep_for(std::chrono::milliseconds(10));
3434
pro.set(1, DecodeResult::Success());
3535
pro.set(0, DecodeResult::Success());
@@ -59,7 +59,7 @@ TEST(FutureDecodeResultsTest, Benchmark) {
5959
auto start = std::chrono::high_resolution_clock::now();
6060
for (int iter = 0; iter < num_iter; iter++) {
6161
DecodeResultsPromise res(100);
62-
tp.AddWork([&](int tidx) {
62+
tp.AddTask([&](int tidx) {
6363
for (int i = 0; i < res.num_samples(); i++)
6464
res.set(i, DecodeResult::Success());
6565
}, 0, true);

dali/imgcodec/tools/imagemagick_test.cc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright (c) 2022-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -205,7 +205,7 @@ void run(Env &env) {
205205

206206
while (directory_it != fs::end(directory_it)) {
207207
auto batch = get_batch(env, directory_it);
208-
pool.AddWork([=, &env](int tid){
208+
pool.AddTask([=, &env](int tid){
209209
process(env, batch);
210210
});
211211
}

dali/kernels/common/scatter_gather.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2019-2022, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
1+
// Copyright (c) 2019-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -170,7 +170,7 @@ class DLL_PUBLIC ScatterGatherCPU : public ScatterGatherBase {
170170
} else {
171171
MakeBlocks(exec_engine.NumThreads() * kTasksMultiplier);
172172
for (auto &r : blocks_) {
173-
exec_engine.AddWork([=](int thread_id) { std::memcpy(r.dst, r.src, r.size); }, r.size);
173+
exec_engine.AddTask([=](int thread_id) { std::memcpy(r.dst, r.src, r.size); }, r.size);
174174
}
175175
exec_engine.RunAll();
176176
}

dali/kernels/imgproc/structure/connected_components.h

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
1+
// Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -208,7 +208,7 @@ void LabelSlice(OutLabel *label_base,
208208
for (int64_t i = 0; i < n; i++) {
209209
auto out_slice = out.slice(i);
210210
auto in_slice = in.slice(i);
211-
engine.AddWork([=, &seq_engn](int){
211+
engine.AddTask([=, &seq_engn](int){
212212
LabelSlice(label_base, out_slice, in_slice, background, seq_engn);
213213
});
214214
}
@@ -220,7 +220,7 @@ void LabelSlice(OutLabel *label_base,
220220
auto in_slice = in.slice(i);
221221
auto prev_out = out.slice(i-1);
222222
auto prev_in = in.slice(i-1);
223-
engine.AddWork([=](int){
223+
engine.AddTask([=](int){
224224
MergeSlices(label_base, prev_out, out_slice, prev_in, in_slice);
225225
});
226226
}
@@ -313,7 +313,7 @@ int64_t CompactLabels(OutLabel *labels,
313313
int64_t chunk_start = volume * chunk / num_chunks;
314314
int64_t chunk_end = volume * (chunk + 1) / num_chunks;
315315

316-
engine.AddWork([=, &tmp_sets, &lock](int thread) {
316+
engine.AddTask([=, &tmp_sets, &lock](int thread) {
317317
OutLabel prev = old_bg_label;
318318
OutLabel remapped = old_bg_label;
319319
for (int64_t i = chunk_start; i < chunk_end; i++) {
@@ -354,7 +354,7 @@ int64_t CompactLabels(OutLabel *labels,
354354
for (int chunk = 0; chunk < num_chunks; chunk++) {
355355
int64_t chunk_start = volume * chunk / num_chunks;
356356
int64_t chunk_end = volume * (chunk + 1) / num_chunks;
357-
engine.AddWork([=, &label_map](int) {
357+
engine.AddTask([=, &label_map](int) {
358358
RemapChunk(make_span(labels + chunk_start, chunk_end - chunk_start), label_map);
359359
});
360360
}

dali/kernels/imgproc/structure/label_bbox.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2021, NVIDIA CORPORATION. All rights reserved.
1+
// Copyright (c) 2021-2023, NVIDIA CORPORATION & AFFILIATES. All rights reserved.
22
//
33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -245,7 +245,7 @@ void GetLabelBoundingBoxes(span<Box<ndim, Coord>> boxes,
245245
part_boxes = make_span(&tmp_boxes[(i - 1)*boxes.size()], boxes.size());
246246
part.size[max_d] = end - start;
247247
part.data = in.data + start * stride;
248-
engine.AddWork([=](int) {
248+
engine.AddTask([=](int) {
249249
i64vec<ndim> origin = {};
250250
origin[dim_mapping[max_d]] = start;
251251
GetLabelBoundingBoxes(part_boxes, part, dim_mapping, background, origin);

0 commit comments

Comments
 (0)