From 3c4798cfcba874e4c12bac454a1b91d4b1c75f27 Mon Sep 17 00:00:00 2001 From: Matthias Maier Date: Wed, 4 Sep 2019 17:08:05 -0500 Subject: [PATCH] add a test --- tests/base/vectorization_14.cc | 95 +++++++++++++++++++++++ tests/base/vectorization_14.output | 15 ++++ tests/base/vectorization_14.output.avx | 43 ++++++++++ tests/base/vectorization_14.output.avx512 | 57 ++++++++++++++ tests/base/vectorization_14.output.sse | 29 +++++++ 5 files changed, 239 insertions(+) create mode 100644 tests/base/vectorization_14.cc create mode 100644 tests/base/vectorization_14.output create mode 100644 tests/base/vectorization_14.output.avx create mode 100644 tests/base/vectorization_14.output.avx512 create mode 100644 tests/base/vectorization_14.output.sse diff --git a/tests/base/vectorization_14.cc b/tests/base/vectorization_14.cc new file mode 100644 index 0000000000..4c1ce45c8c --- /dev/null +++ b/tests/base/vectorization_14.cc @@ -0,0 +1,95 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2015 - 2019 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE.md at +// the top level directory of deal.II. +// +// --------------------------------------------------------------------- + + +// test compare_and_apply_mask + +#include + +#include "../tests.h" + + +template +void +do_test() +{ + deallog << " test " << VectorizedArrayType::n_array_elements + << " array elements" << std::endl; + + VectorizedArrayType left; + for (unsigned int i = 0; i < VectorizedArrayType::n_array_elements; i++) + left[i] = i + 1.; + + VectorizedArrayType right(3.); + VectorizedArrayType true_values(1.); + VectorizedArrayType false_values(-1.); + + auto result = compare_and_apply_mask(left, + right, + true_values, + false_values); + deallog << result << std::endl; + + result = compare_and_apply_mask(left, + right, + true_values, + false_values); + deallog << result << std::endl; + + result = compare_and_apply_mask(left, + right, + true_values, + false_values); + deallog << result << std::endl; + + result = compare_and_apply_mask( + left, right, true_values, false_values); + deallog << result << std::endl; + + result = compare_and_apply_mask(left, + right, + true_values, + false_values); + deallog << result << std::endl; + + result = compare_and_apply_mask( + left, right, true_values, false_values); + deallog << result << std::endl; +} + + +int +main() +{ + initlog(); + +#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 3 && defined(__AVX512F__) + do_test>(); + do_test>(); +#endif + +#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 2 && defined(__AVX__) + do_test>(); + do_test>(); +#endif + +#if DEAL_II_COMPILER_VECTORIZATION_LEVEL >= 1 && defined(__SSE2__) + do_test>(); + do_test>(); +#endif + + do_test>(); + do_test>(); +} diff --git a/tests/base/vectorization_14.output b/tests/base/vectorization_14.output new file mode 100644 index 0000000000..a2418ed38a --- /dev/null +++ b/tests/base/vectorization_14.output @@ -0,0 +1,15 @@ + +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 diff --git a/tests/base/vectorization_14.output.avx b/tests/base/vectorization_14.output.avx new file mode 100644 index 0000000000..d304d82793 --- /dev/null +++ b/tests/base/vectorization_14.output.avx @@ -0,0 +1,43 @@ + +DEAL:: test 4 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 +DEAL:: test 8 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL:: test 2 array elements +DEAL::-1.00000 -1.00000 +DEAL::1.00000 1.00000 +DEAL::1.00000 1.00000 +DEAL::1.00000 1.00000 +DEAL::-1.00000 -1.00000 +DEAL::-1.00000 -1.00000 +DEAL:: test 4 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 diff --git a/tests/base/vectorization_14.output.avx512 b/tests/base/vectorization_14.output.avx512 new file mode 100644 index 0000000000..0085395eb9 --- /dev/null +++ b/tests/base/vectorization_14.output.avx512 @@ -0,0 +1,57 @@ + +DEAL:: test 8 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL:: test 16 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL:: test 4 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 +DEAL:: test 8 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 -1.00000 -1.00000 -1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 1.00000 +DEAL:: test 2 array elements +DEAL::-1.00000 -1.00000 +DEAL::1.00000 1.00000 +DEAL::1.00000 1.00000 +DEAL::1.00000 1.00000 +DEAL::-1.00000 -1.00000 +DEAL::-1.00000 -1.00000 +DEAL:: test 4 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 diff --git a/tests/base/vectorization_14.output.sse b/tests/base/vectorization_14.output.sse new file mode 100644 index 0000000000..11b3d3f833 --- /dev/null +++ b/tests/base/vectorization_14.output.sse @@ -0,0 +1,29 @@ + +DEAL:: test 2 array elements +DEAL::-1.00000 -1.00000 +DEAL::1.00000 1.00000 +DEAL::1.00000 1.00000 +DEAL::1.00000 1.00000 +DEAL::-1.00000 -1.00000 +DEAL::-1.00000 -1.00000 +DEAL:: test 4 array elements +DEAL::-1.00000 -1.00000 1.00000 -1.00000 +DEAL::1.00000 1.00000 -1.00000 1.00000 +DEAL::1.00000 1.00000 -1.00000 -1.00000 +DEAL::1.00000 1.00000 1.00000 -1.00000 +DEAL::-1.00000 -1.00000 -1.00000 1.00000 +DEAL::-1.00000 -1.00000 1.00000 1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 +DEAL:: test 1 array elements +DEAL::-1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::1.00000 +DEAL::-1.00000 +DEAL::-1.00000 -- 2.39.5