Reference documentation for deal.II version 9.5.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// Copyright (C) 2009 - 2020 by the deal.II authors
4//
5// This file is part of the deal.II library.
6//
7// The deal.II library is free software; you can use it, redistribute
8// it, and/or modify it under the terms of the GNU Lesser General
9// Public License as published by the Free Software Foundation; either
10// version 2.1 of the License, or (at your option) any later version.
11// The full text of the license can be found in the file LICENSE.md at
12// the top level directory of deal.II.
13//
14// ---------------------------------------------------------------------
15
16
18
19
21
22namespace internal
23{
24 namespace VectorImplementation
25 {
26 // set minimum grain size. this value has been determined by experiments
27 // with the actual ::Vector implementation and takes vectorization
28 // that is done inside most functions of ::Vector into account
29 // (without vectorization, we would land at around 1000). for smaller
30 // values than this, the scheduling overhead will be significant. if the
31 // value becomes too large, on the other hand, the work load cannot be
32 // split into enough chunks and the problem becomes badly balanced. the
33 // tests are documented at https://github.com/dealii/dealii/issues/2496
34 unsigned int minimum_parallel_grain_size = 4096;
35 } // namespace VectorImplementation
36
37
38 namespace SparseMatrixImplementation
39 {
40 // set this value to 1/16 of the value of the minimum grain size of
41 // vectors (a factor of 4 because we assume that sparse matrix-vector
42 // products do not vectorize and the other factor of 4 because we expect
43 // at least four entries per row). this rests on the fact that we have to
44 // do a lot more work per row of a matrix than per element of a vector. it
45 // could possibly be reduced even further but that doesn't appear worth it
46 // any more for anything but very small matrices that we don't care that
47 // much about anyway.
48 unsigned int minimum_parallel_grain_size = 256;
49 } // namespace SparseMatrixImplementation
50} // namespace internal
51
52namespace parallel
53{
54 namespace internal
55 {
56#ifdef DEAL_II_WITH_TBB
58 : my_partitioner(std::make_shared<tbb::affinity_partitioner>())
59 , in_use(false)
60 {}
61
62
63
65 {
66 AssertNothrow(in_use == false,
68 "A vector partitioner goes out of scope, but "
69 "it appears to be still in use."));
70 }
71
72
73
74 std::shared_ptr<tbb::affinity_partitioner>
76 {
77 std::lock_guard<std::mutex> lock(mutex);
78 if (in_use)
79 return std::make_shared<tbb::affinity_partitioner>();
80
81 in_use = true;
82 return my_partitioner;
83 }
84
85
86
87 void
89 std::shared_ptr<tbb::affinity_partitioner> &p)
90 {
91 if (p.get() == my_partitioner.get())
92 {
93 std::lock_guard<std::mutex> lock(mutex);
94 in_use = false;
95 }
96 }
97#else
99#endif
100 } // namespace internal
101} // namespace parallel
102
103
104
std::shared_ptr< tbb::affinity_partitioner > acquire_one_partitioner()
Definition parallel.cc:75
std::shared_ptr< tbb::affinity_partitioner > my_partitioner
Definition parallel.h:665
void release_one_partitioner(std::shared_ptr< tbb::affinity_partitioner > &p)
Definition parallel.cc:88
#define DEAL_II_NAMESPACE_OPEN
Definition config.h:472
#define DEAL_II_NAMESPACE_CLOSE
Definition config.h:473
#define AssertNothrow(cond, exc)
static ::ExceptionBase & ExcInternalError()
unsigned int minimum_parallel_grain_size
Definition parallel.cc:34
STL namespace.