~ubuntu-branches/ubuntu/trusty/blender/trusty

« back to all changes in this revision

Viewing changes to extern/Eigen3/Eigen/src/Core/products/Parallelizer.h

  • Committer: Package Import Robot
  • Author(s): Jeremy Bicha
  • Date: 2013-03-06 12:08:47 UTC
  • mfrom: (1.5.1) (14.1.8 experimental)
  • Revision ID: package-import@ubuntu.com-20130306120847-frjfaryb2zrotwcg
Tags: 2.66a-1ubuntu1
* Resynchronize with Debian (LP: #1076930, #1089256, #1052743, #999024,
  #1122888, #1147084)
* debian/control:
  - Lower build-depends on libavcodec-dev since we're not
    doing the libav9 transition in Ubuntu yet

Show diffs side-by-side

added added

removed removed

Lines of Context:
3
3
//
4
4
// Copyright (C) 2010 Gael Guennebaud <gael.guennebaud@inria.fr>
5
5
//
6
 
// Eigen is free software; you can redistribute it and/or
7
 
// modify it under the terms of the GNU Lesser General Public
8
 
// License as published by the Free Software Foundation; either
9
 
// version 3 of the License, or (at your option) any later version.
10
 
//
11
 
// Alternatively, you can redistribute it and/or
12
 
// modify it under the terms of the GNU General Public License as
13
 
// published by the Free Software Foundation; either version 2 of
14
 
// the License, or (at your option) any later version.
15
 
//
16
 
// Eigen is distributed in the hope that it will be useful, but WITHOUT ANY
17
 
// WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 
// FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License or the
19
 
// GNU General Public License for more details.
20
 
//
21
 
// You should have received a copy of the GNU Lesser General Public
22
 
// License and a copy of the GNU General Public License along with
23
 
// Eigen. If not, see <http://www.gnu.org/licenses/>.
 
6
// This Source Code Form is subject to the terms of the Mozilla
 
7
// Public License v. 2.0. If a copy of the MPL was not distributed
 
8
// with this file, You can obtain one at http://mozilla.org/MPL/2.0/.
24
9
 
25
10
#ifndef EIGEN_PARALLELIZER_H
26
11
#define EIGEN_PARALLELIZER_H
27
12
 
 
13
namespace Eigen { 
 
14
 
28
15
namespace internal {
29
16
 
30
17
/** \internal */
55
42
  }
56
43
}
57
44
 
 
45
}
 
46
 
 
47
/** Must be call first when calling Eigen from multiple threads */
 
48
inline void initParallel()
 
49
{
 
50
  int nbt;
 
51
  internal::manage_multi_threading(GetAction, &nbt);
 
52
  std::ptrdiff_t l1, l2;
 
53
  internal::manage_caching_sizes(GetAction, &l1, &l2);
 
54
}
 
55
 
58
56
/** \returns the max number of threads reserved for Eigen
59
57
  * \sa setNbThreads */
60
58
inline int nbThreads()
61
59
{
62
60
  int ret;
63
 
  manage_multi_threading(GetAction, &ret);
 
61
  internal::manage_multi_threading(GetAction, &ret);
64
62
  return ret;
65
63
}
66
64
 
68
66
  * \sa nbThreads */
69
67
inline void setNbThreads(int v)
70
68
{
71
 
  manage_multi_threading(SetAction, &v);
 
69
  internal::manage_multi_threading(SetAction, &v);
72
70
}
73
71
 
 
72
namespace internal {
 
73
 
74
74
template<typename Index> struct GemmParallelInfo
75
75
{
76
76
  GemmParallelInfo() : sync(-1), users(0), rhs_start(0), rhs_length(0) {}
85
85
template<bool Condition, typename Functor, typename Index>
86
86
void parallelize_gemm(const Functor& func, Index rows, Index cols, bool transpose)
87
87
{
88
 
#ifndef EIGEN_HAS_OPENMP
 
88
  // TODO when EIGEN_USE_BLAS is defined,
 
89
  // we should still enable OMP for other scalar types
 
90
#if !(defined (EIGEN_HAS_OPENMP)) || defined (EIGEN_USE_BLAS)
89
91
  // FIXME the transpose variable is only needed to properly split
90
92
  // the matrix product when multithreading is enabled. This is a temporary
91
93
  // fix to support row-major destination matrices. This whole
117
119
  if(threads==1)
118
120
    return func(0,rows, 0,cols);
119
121
 
 
122
  Eigen::initParallel();
120
123
  func.initParallelSession();
121
124
 
122
125
  if(transpose)
151
154
 
152
155
} // end namespace internal
153
156
 
 
157
} // end namespace Eigen
 
158
 
154
159
#endif // EIGEN_PARALLELIZER_H