From: Wolfgang Bangerth Date: Tue, 29 Nov 2022 23:11:31 +0000 (-0700) Subject: Add a test. X-Git-Tag: v9.5.0-rc1~785^2~1 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=da9dd22b53467719fff4f655556a661a5afa5ede;p=dealii.git Add a test. --- diff --git a/tests/multithreading/task_14.cc b/tests/multithreading/task_14.cc new file mode 100644 index 0000000000..0ca699e3f5 --- /dev/null +++ b/tests/multithreading/task_14.cc @@ -0,0 +1,50 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 - 2020 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// Check TaskGroup::return_values() + + +#include + +#include "../tests.h" + + +// return a double, to make sure we correctly identify the return type +// of the expressions used in new_task(...) +int +test(int i) +{ + return 2 * i; +} + + + +int +main() +{ + initlog(); + + // Create a bunch of tasks, and put them into a TaskGroup + Threads::TaskGroup tg; + for (unsigned int i = 0; i < 10; ++i) + tg += Threads::new_task(&test, i); + + // Then wait for them all to finish and output their respective + // return values. They should be ordered the same way the tasks were + // created, and should be twice the input argument: + for (const int r : tg.return_values()) + deallog << r << std::endl; +} diff --git a/tests/multithreading/task_14.output b/tests/multithreading/task_14.output new file mode 100644 index 0000000000..0859f86735 --- /dev/null +++ b/tests/multithreading/task_14.output @@ -0,0 +1,11 @@ + +DEAL::0 +DEAL::2 +DEAL::4 +DEAL::6 +DEAL::8 +DEAL::10 +DEAL::12 +DEAL::14 +DEAL::16 +DEAL::18