Reference documentation for deal.II version 9.6.0
\(\newcommand{\dealvcentcolon}{\mathrel{\mathop{:}}}\) \(\newcommand{\dealcoloneq}{\dealvcentcolon\mathrel{\mkern-1.2mu}=}\) \(\newcommand{\jump}[1]{\left[\!\left[ #1 \right]\!\right]}\) \(\newcommand{\average}[1]{\left\{\!\left\{ #1 \right\}\!\right\}}\)
Loading...
Searching...
No Matches
parallel.cc
Go to the documentation of this file.
1// ------------------------------------------------------------------------
2//
3// SPDX-License-Identifier: LGPL-2.1-or-later
4// Copyright (C) 2009 - 2024 by the deal.II authors
5//
6// This file is part of the deal.II library.
7//
8// Part of the source code is dual licensed under Apache-2.0 WITH
9// LLVM-exception OR LGPL-2.1-or-later. Detailed license information
10// governing the source code and code contributions can be found in
11// LICENSE.md and CONTRIBUTING.md at the top level directory of deal.II.
12//
13// ------------------------------------------------------------------------
14
15
17
18
20
21namespace internal
22{
23 namespace VectorImplementation
24 {
25 // set minimum grain size. this value has been determined by experiments
26 // with the actual ::Vector implementation and takes vectorization
27 // that is done inside most functions of ::Vector into account
28 // (without vectorization, we would land at around 1000). for smaller
29 // values than this, the scheduling overhead will be significant. if the
30 // value becomes too large, on the other hand, the work load cannot be
31 // split into enough chunks and the problem becomes badly balanced. the
32 // tests are documented at https://github.com/dealii/dealii/issues/2496
33 unsigned int minimum_parallel_grain_size = 4096;
34 } // namespace VectorImplementation
35
36
37 namespace SparseMatrixImplementation
38 {
39 // set this value to 1/16 of the value of the minimum grain size of
40 // vectors (a factor of 4 because we assume that sparse matrix-vector
41 // products do not vectorize and the other factor of 4 because we expect
42 // at least four entries per row). this rests on the fact that we have to
43 // do a lot more work per row of a matrix than per element of a vector. it
44 // could possibly be reduced even further but that doesn't appear worth it
45 // any more for anything but very small matrices that we don't care that
46 // much about anyway.
47 unsigned int minimum_parallel_grain_size = 256;
48 } // namespace SparseMatrixImplementation
49} // namespace internal
50
51namespace parallel
52{
53 namespace internal
54 {
55#ifdef DEAL_II_WITH_TBB
57 : my_partitioner(std::make_shared<tbb::affinity_partitioner>())
58 , in_use(false)
59 {}
60
61
62
64 {
65 AssertNothrow(in_use == false,
67 "A vector partitioner goes out of scope, but "
68 "it appears to be still in use."));
69 }
70
71
72
73 std::shared_ptr<tbb::affinity_partitioner>
75 {
76 std::lock_guard<std::mutex> lock(mutex);
77 if (in_use)
78 return std::make_shared<tbb::affinity_partitioner>();
79
80 in_use = true;
81 return my_partitioner;
82 }
83
84
85
86 void
88 const std::shared_ptr<tbb::affinity_partitioner> &p)
89 {
90 if (p.get() == my_partitioner.get())
91 {
92 std::lock_guard<std::mutex> lock(mutex);
93 in_use = false;
94 }
95 }
96#else
98#endif
99 } // namespace internal
100} // namespace parallel
101
102
103
std::shared_ptr< tbb::affinity_partitioner > acquire_one_partitioner()
Definition parallel.cc:74
void release_one_partitioner(const std::shared_ptr< tbb::affinity_partitioner > &p)
Definition parallel.cc:87
std::shared_ptr< tbb::affinity_partitioner > my_partitioner
Definition parallel.h:685
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:503
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:504
#define AssertNothrow(cond, exc)
static ::ExceptionBase & ExcInternalError()
unsigned int minimum_parallel_grain_size
Definition parallel.cc:33
STL namespace.