diff options
author | Tom de Vries <tdevries@suse.de> | 2022-08-05 16:12:56 +0200 |
---|---|---|
committer | Tom de Vries <tdevries@suse.de> | 2022-08-05 16:12:56 +0200 |
commit | b859a3ef488cd1a3bf072f71002dced36353875b (patch) | |
tree | 9ec7af8baef949fdc2db0540b3b4b6503f08216f /gdb/unittests | |
parent | 377c3a9c91785d5df5c0d96121160e6210204cc0 (diff) | |
download | gdb-b859a3ef488cd1a3bf072f71002dced36353875b.zip gdb-b859a3ef488cd1a3bf072f71002dced36353875b.tar.gz gdb-b859a3ef488cd1a3bf072f71002dced36353875b.tar.bz2 |
[gdbsupport] Add task size parameter in parallel_for_each
Add a task_size parameter to parallel_for_each, defaulting to nullptr, and use
the task size to distribute similarly-sized chunks to the threads.
Tested on x86_64-linux.
Diffstat (limited to 'gdb/unittests')
-rw-r--r-- | gdb/unittests/parallel-for-selftests.c | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/gdb/unittests/parallel-for-selftests.c b/gdb/unittests/parallel-for-selftests.c index 8a86b43..6e341f6 100644 --- a/gdb/unittests/parallel-for-selftests.c +++ b/gdb/unittests/parallel-for-selftests.c @@ -68,6 +68,34 @@ test (int n_threads) }); SELF_CHECK (counter == 0); + auto task_size_max_ = [] (int iter) + { + return (size_t)SIZE_MAX; + }; + auto task_size_max = gdb::make_function_view (task_size_max_); + + counter = 0; + gdb::parallel_for_each (1, 0, NUMBER, + [&] (int start, int end) + { + counter += end - start; + }, task_size_max); + SELF_CHECK (counter == NUMBER); + + auto task_size_one_ = [] (int iter) + { + return (size_t)1; + }; + auto task_size_one = gdb::make_function_view (task_size_one_); + + counter = 0; + gdb::parallel_for_each (1, 0, NUMBER, + [&] (int start, int end) + { + counter += end - start; + }, task_size_one); + SELF_CHECK (counter == NUMBER); + #undef NUMBER } |