From 44861dcbfeee041223c4aac1ee075e92fa4daa01 Mon Sep 17 00:00:00 2001 From: Stanislaw Halik Date: Sun, 18 Sep 2016 12:42:15 +0200 Subject: update --- eigen/test/eigen2/eigen2_packetmath.cpp | 132 ++++++++++++++++++++++++++++++++ 1 file changed, 132 insertions(+) create mode 100644 eigen/test/eigen2/eigen2_packetmath.cpp (limited to 'eigen/test/eigen2/eigen2_packetmath.cpp') diff --git a/eigen/test/eigen2/eigen2_packetmath.cpp b/eigen/test/eigen2/eigen2_packetmath.cpp new file mode 100644 index 0000000..b1f325f --- /dev/null +++ b/eigen/test/eigen2/eigen2_packetmath.cpp @@ -0,0 +1,132 @@ +// This file is part of Eigen, a lightweight C++ template library +// for linear algebra. Eigen itself is part of the KDE project. +// +// Copyright (C) 2006-2008 Benoit Jacob +// +// This Source Code Form is subject to the terms of the Mozilla +// Public License v. 2.0. If a copy of the MPL was not distributed +// with this file, You can obtain one at http://mozilla.org/MPL/2.0/. + +#include "main.h" + +// using namespace Eigen; + +template bool areApprox(const Scalar* a, const Scalar* b, int size) +{ + for (int i=0; i const complex& min(const complex& a, const complex& b) +{ return a.real() < b.real() ? a : b; } + +template<> const complex& max(const complex& a, const complex& b) +{ return a.real() < b.real() ? b : a; } + +} + +template void packetmath() +{ + typedef typename ei_packet_traits::type Packet; + const int PacketSize = ei_packet_traits::size; + + const int size = PacketSize*4; + EIGEN_ALIGN_128 Scalar data1[ei_packet_traits::size*4]; + EIGEN_ALIGN_128 Scalar data2[ei_packet_traits::size*4]; + EIGEN_ALIGN_128 Packet packets[PacketSize*2]; + EIGEN_ALIGN_128 Scalar ref[ei_packet_traits::size*4]; + for (int i=0; i(); + data2[i] = ei_random(); + } + + ei_pstore(data2, ei_pload(data1)); + VERIFY(areApprox(data1, data2, PacketSize) && "aligned load/store"); + + for (int offset=0; offset(packets[0], packets[1]); + else if (offset==1) ei_palign<1>(packets[0], packets[1]); + else if (offset==2) ei_palign<2>(packets[0], packets[1]); + else if (offset==3) ei_palign<3>(packets[0], packets[1]); + ei_pstore(data2, packets[0]); + + for (int i=0; i Vector; + VERIFY(areApprox(ref, data2, PacketSize) && "ei_palign"); + } + + CHECK_CWISE(REF_ADD, ei_padd); + CHECK_CWISE(REF_SUB, ei_psub); + CHECK_CWISE(REF_MUL, ei_pmul); + #ifndef EIGEN_VECTORIZE_ALTIVEC + if (!ei_is_same_type::ret) + CHECK_CWISE(REF_DIV, ei_pdiv); + #endif + CHECK_CWISE(std::min, ei_pmin); + CHECK_CWISE(std::max, ei_pmax); + + for (int i=0; i() ); + CALL_SUBTEST_2( packetmath() ); + CALL_SUBTEST_3( packetmath() ); + CALL_SUBTEST_4( packetmath >() ); + } +} -- cgit v1.2.3