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

« back to all changes in this revision

Viewing changes to extern/Eigen3/Eigen/src/Core/arch/SSE/PacketMath.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) 2008-2009 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_PACKET_MATH_SSE_H
26
11
#define EIGEN_PACKET_MATH_SSE_H
27
12
 
 
13
namespace Eigen {
 
14
 
28
15
namespace internal {
29
16
 
30
17
#ifndef EIGEN_CACHEFRIENDLY_PRODUCT_THRESHOLD
110
97
template<> struct unpacket_traits<Packet2d> { typedef double type; enum {size=2}; };
111
98
template<> struct unpacket_traits<Packet4i> { typedef int    type; enum {size=4}; };
112
99
 
 
100
#if defined(_MSC_VER) && (_MSC_VER==1500)
 
101
// Workaround MSVC 9 internal compiler error.
 
102
// TODO: It has been detected with win64 builds (amd64), so let's check whether it also happens in 32bits+SSE mode
 
103
// TODO: let's check whether there does not exist a better fix, like adding a pset0() function. (it crashed on pset1(0)).
 
104
template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) { return _mm_set_ps(from,from,from,from); }
 
105
template<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { return _mm_set_pd(from,from); }
 
106
template<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int&    from) { return _mm_set_epi32(from,from,from,from); }
 
107
#else
113
108
template<> EIGEN_STRONG_INLINE Packet4f pset1<Packet4f>(const float&  from) { return _mm_set1_ps(from); }
114
109
template<> EIGEN_STRONG_INLINE Packet2d pset1<Packet2d>(const double& from) { return _mm_set1_pd(from); }
115
110
template<> EIGEN_STRONG_INLINE Packet4i pset1<Packet4i>(const int&    from) { return _mm_set1_epi32(from); }
 
111
#endif
116
112
 
117
113
template<> EIGEN_STRONG_INLINE Packet4f plset<float>(const float& a) { return _mm_add_ps(pset1<Packet4f>(a), _mm_set_ps(3,2,1,0)); }
118
114
template<> EIGEN_STRONG_INLINE Packet2d plset<double>(const double& a) { return _mm_add_pd(pset1<Packet2d>(a),_mm_set_pd(1,0)); }
282
278
 
283
279
template<> EIGEN_STRONG_INLINE Packet4f ploaddup<Packet4f>(const float*   from)
284
280
{
285
 
  return vec4f_swizzle1(_mm_castpd_ps(_mm_load_sd((const double*)from)), 0, 0, 1, 1);
 
281
  return vec4f_swizzle1(_mm_castpd_ps(_mm_load_sd(reinterpret_cast<const double*>(from))), 0, 0, 1, 1);
286
282
}
287
283
template<> EIGEN_STRONG_INLINE Packet2d ploaddup<Packet2d>(const double*  from)
288
284
{ return pset1<Packet2d>(from[0]); }
302
298
  _mm_storel_pd((to), from);
303
299
  _mm_storeh_pd((to+1), from);
304
300
}
305
 
template<> EIGEN_STRONG_INLINE void pstoreu<float>(float*  to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, _mm_castps_pd(from)); }
306
 
template<> EIGEN_STRONG_INLINE void pstoreu<int>(int*      to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu((double*)to, _mm_castsi128_pd(from)); }
 
301
template<> EIGEN_STRONG_INLINE void pstoreu<float>(float*  to, const Packet4f& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(reinterpret_cast<double*>(to), _mm_castps_pd(from)); }
 
302
template<> EIGEN_STRONG_INLINE void pstoreu<int>(int*      to, const Packet4i& from) { EIGEN_DEBUG_UNALIGNED_STORE pstoreu(reinterpret_cast<double*>(to), _mm_castsi128_pd(from)); }
307
303
 
308
304
// some compilers might be tempted to perform multiple moves instead of using a vector path.
309
305
template<> EIGEN_STRONG_INLINE void pstore1<Packet4f>(float* to, const float& a)
541
537
template<int Offset>
542
538
struct palign_impl<Offset,Packet4f>
543
539
{
544
 
  EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second)
 
540
  static EIGEN_STRONG_INLINE void run(Packet4f& first, const Packet4f& second)
545
541
  {
546
542
    if (Offset!=0)
547
543
      first = _mm_castsi128_ps(_mm_alignr_epi8(_mm_castps_si128(second), _mm_castps_si128(first), Offset*4));
551
547
template<int Offset>
552
548
struct palign_impl<Offset,Packet4i>
553
549
{
554
 
  EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second)
 
550
  static EIGEN_STRONG_INLINE void run(Packet4i& first, const Packet4i& second)
555
551
  {
556
552
    if (Offset!=0)
557
553
      first = _mm_alignr_epi8(second,first, Offset*4);
561
557
template<int Offset>
562
558
struct palign_impl<Offset,Packet2d>
563
559
{
564
 
  EIGEN_STRONG_INLINE static void run(Packet2d& first, const Packet2d& second)
 
560
  static EIGEN_STRONG_INLINE void run(Packet2d& first, const Packet2d& second)
565
561
  {
566
562
    if (Offset==1)
567
563
      first = _mm_castsi128_pd(_mm_alignr_epi8(_mm_castpd_si128(second), _mm_castpd_si128(first), 8));
572
568
template<int Offset>
573
569
struct palign_impl<Offset,Packet4f>
574
570
{
575
 
  EIGEN_STRONG_INLINE static void run(Packet4f& first, const Packet4f& second)
 
571
  static EIGEN_STRONG_INLINE void run(Packet4f& first, const Packet4f& second)
576
572
  {
577
573
    if (Offset==1)
578
574
    {
595
591
template<int Offset>
596
592
struct palign_impl<Offset,Packet4i>
597
593
{
598
 
  EIGEN_STRONG_INLINE static void run(Packet4i& first, const Packet4i& second)
 
594
  static EIGEN_STRONG_INLINE void run(Packet4i& first, const Packet4i& second)
599
595
  {
600
596
    if (Offset==1)
601
597
    {
618
614
template<int Offset>
619
615
struct palign_impl<Offset,Packet2d>
620
616
{
621
 
  EIGEN_STRONG_INLINE static void run(Packet2d& first, const Packet2d& second)
 
617
  static EIGEN_STRONG_INLINE void run(Packet2d& first, const Packet2d& second)
622
618
  {
623
619
    if (Offset==1)
624
620
    {
631
627
 
632
628
} // end namespace internal
633
629
 
 
630
} // end namespace Eigen
 
631
 
634
632
#endif // EIGEN_PACKET_MATH_SSE_H