Skip to content

Commit

Permalink
Port remaining test to new test interface
Browse files Browse the repository at this point in the history
Signed-off-by: Matthias Kretz <kretz@kde.org>
  • Loading branch information
mattkretz committed Sep 3, 2018
1 parent 246ca17 commit 9aacbc0
Show file tree
Hide file tree
Showing 8 changed files with 33 additions and 86 deletions.
3 changes: 3 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
[submodule "tests/testdata"]
path = tests/testdata
url = https://github.com/VcDevel/vc-testdata
[submodule "tests/virtest"]
path = tests/virtest
url = https://github.com/mattkretz/virtest
12 changes: 2 additions & 10 deletions tests/alignmentinheritance.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}}}*/

#include "unittest-old.h"
#include "unittest.h"

#if defined(Vc_ICC) || (defined(Vc_GCC) && Vc_GCC < 0x40800)
class A {} __attribute__((aligned(64)));
Expand All @@ -34,12 +34,4 @@ class alignas(64) A {};
#endif
class B : public A {};

void alignmentOfSubclass()
{
COMPARE(alignof(B), alignof(A));
}

void testmain()
{
runTest(alignmentOfSubclass);
}
TEST(alignmentOfSubclass) { COMPARE(alignof(B), alignof(A)); }
9 changes: 2 additions & 7 deletions tests/implicit_type_conversion.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}}}*/

#include "unittest-old.h"
#include "unittest.h"

using namespace Vc;

Expand Down Expand Up @@ -129,7 +129,7 @@ struct TestImplicitCast {
enum SomeEnum { EnumValue = 0 };
SomeEnum Enum() { return EnumValue; }

void testImplicitTypeConversions()
TEST(testImplicitTypeConversions)
{
VERIFY( TestImplicitCast< int>::test(double()));
VERIFY( TestImplicitCast< int>::test( float()));
Expand Down Expand Up @@ -271,9 +271,4 @@ void testImplicitTypeConversions()
TYPE_TEST( bool, uint_v, uint_v);
}

void testmain()
{
runTest(testImplicitTypeConversions);
}

// vim: foldmethod=marker
17 changes: 6 additions & 11 deletions tests/sse_blend.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}}}*/

#include "unittest-old.h"
#include "unittest.h"
#include <sse/intrinsics.h>

namespace std
Expand Down Expand Up @@ -53,7 +53,7 @@ template<> inline bool unittest_compareHelper<__m128i, __m128i>(const __m128i &a
}
} // namespace UnitTest

void blendpd()
TEST(blendpd)
{
using Vc::SSE::blend_pd;
__m128d a = _mm_set_pd(11, 10);
Expand All @@ -64,7 +64,8 @@ void blendpd()
COMPARE(_mm_movemask_pd(_mm_cmpeq_pd(blend_pd<0x2>(a, b), _mm_set_pd(21, 10))), 0x3);
COMPARE(_mm_movemask_pd(_mm_cmpeq_pd(blend_pd<0x3>(a, b), b)), 0x3);
}
void blendps()

TEST(blendps)
{
using Vc::SSE::blend_ps;
__m128 a = _mm_set_ps(13, 12, 11, 10);
Expand All @@ -87,7 +88,8 @@ void blendps()
COMPARE(_mm_movemask_ps(_mm_cmpeq_ps(blend_ps<0xe>(a, b), _mm_set_ps(23, 22, 21, 10))), 0xf);
COMPARE(_mm_movemask_ps(_mm_cmpeq_ps(blend_ps<0xf>(a, b), b)), 0xf);
}
void blendepi16()

TEST(blendepi16)
{
using Vc::SSE::blend_epi16;
__m128i a = _mm_set_epi16(17, 16, 15, 14, 13, 12, 11, 10);
Expand All @@ -112,10 +114,3 @@ void blendepi16()
COMPARE_NOEQ(blend_epi16<i>(a, b), reference);
)
}

void testmain()
{
runTest(blendpd);
runTest(blendps);
runTest(blendepi16);
}
35 changes: 14 additions & 21 deletions tests/store.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,15 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}}}*/

#include "unittest-old.h"
#include "unittest.h"
#include <iostream>
#include <cstring>

using namespace Vc;

template<typename Vec> void alignedStore()
#define ALL_TYPES (ALL_VECTORS)

TEST_TYPES(Vec, alignedStore, ALL_TYPES)
{
typedef typename Vec::EntryType T;
enum {
Expand Down Expand Up @@ -71,7 +73,7 @@ template<typename Vec> void alignedStore()
}
}

template<typename Vec> void unalignedStore()
TEST_TYPES(Vec, unalignedStore, ALL_TYPES)
{
typedef typename Vec::EntryType T;
enum {
Expand All @@ -93,7 +95,7 @@ template<typename Vec> void unalignedStore()
}
}

template<typename Vec> void streamingAndAlignedStore()
TEST_TYPES(Vec, streamingAndAlignedStore, ALL_TYPES)
{
typedef typename Vec::EntryType T;
enum {
Expand All @@ -115,7 +117,7 @@ template<typename Vec> void streamingAndAlignedStore()
}
}

template<typename Vec> void streamingAndUnalignedStore()
TEST_TYPES(Vec, streamingAndUnalignedStore, ALL_TYPES)
{
typedef typename Vec::EntryType T;
enum {
Expand All @@ -137,8 +139,14 @@ template<typename Vec> void streamingAndUnalignedStore()
}
}

template<typename Vec> void maskedStore()
TEST_TYPES(Vec, maskedStore, ALL_TYPES)
{
if ((Vec::size() & 1) == 1) {
// only works with an even number of vector entries
// a) masked store with 01010101 will use only 0 for size 1
// b) the random masks will not be random, because mean == value
return;
}
typedef typename Vec::EntryType T;
typedef typename Vec::Mask M;
M mask;
Expand Down Expand Up @@ -189,18 +197,3 @@ template<typename Vec> void maskedStore()
}
}
}

void testmain()
{
testAllTypes(alignedStore);
testAllTypes(unalignedStore);
testAllTypes(streamingAndAlignedStore);
testAllTypes(streamingAndUnalignedStore);

if (float_v::Size > 1) {
// only works with an even number of vector entries
// a) masked store with 01010101 will use only 0 for size 1
// b) the random masks will not be random, because mean == value
testAllTypes(maskedStore);
}
}
21 changes: 5 additions & 16 deletions tests/supportfunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,14 +25,11 @@ SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
}}}*/

#include "unittest-old.h"
#include "unittest.h"

void testCompiledImplementation()
{
VERIFY(Vc::currentImplementationSupported());
}
TEST(testCompiledImplementation) { VERIFY(Vc::currentImplementationSupported()); }

void testIsSupported()
TEST(testIsSupported)
{
using Vc::CpuId;
VERIFY(Vc::isImplementationSupported(Vc::ScalarImpl));
Expand All @@ -45,15 +42,15 @@ void testIsSupported()
COMPARE(Vc::isImplementationSupported(Vc::AVX2Impl ), CpuId::hasOsxsave() && CpuId::hasAvx2());
}

void testBestImplementation()
TEST(testBestImplementation)
{
// when building with a recent and fully featured compiler the following should pass
// but - old GCC versions have to fall back to Scalar, even though SSE is supported by the CPU
// - ICC/MSVC can't use XOP/FMA4
COMPARE(Vc::bestImplementationSupported(), Vc::CurrentImplementation::current());
}

void testExtraInstructions()
TEST(testExtraInstructions)
{
using Vc::CpuId;
unsigned int extra = Vc::extraInstructionsSupported();
Expand All @@ -66,12 +63,4 @@ void testExtraInstructions()
COMPARE(!(extra & Vc::Bmi2Instructions), !CpuId::hasBmi2());
}

void testmain()
{
runTest(testCompiledImplementation);
runTest(testIsSupported);
runTest(testBestImplementation);
runTest(testExtraInstructions);
}

// vim: foldmethod=marker
21 changes: 0 additions & 21 deletions tests/unittest-old.h

This file was deleted.

1 change: 1 addition & 0 deletions tests/virtest
Submodule virtest added at 3de2c8

0 comments on commit 9aacbc0

Please sign in to comment.