<commit_before>/*  This file is part of the Vc library. {{{

    Copyright (C) 2013 <NAME> <<EMAIL>>

    Vc is free software: you can 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 3 of
    the License, or (at your option) any later version.

    Vc is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Vc.  If not, see <http://www.gnu.org/licenses/>.

}}}*/

#include "unittest.h"
#include "../common/simdarray.h"

using namespace Vc;

#define SIMD_ARRAY_LIST                                                                            \
    (SIMD_ARRAYS(32),                                                                              \
     SIMD_ARRAYS(17),                                                                              \
     SIMD_ARRAYS(16),                                                                              \
     SIMD_ARRAYS(9),                                                                               \
     SIMD_ARRAYS(8),                                                                               \
     SIMD_ARRAYS(5),                                                                               \
     SIMD_ARRAYS(4),                                                                               \
     SIMD_ARRAYS(3),                                                                               \
     SIMD_ARRAYS(2),                                                                               \
     SIMD_ARRAYS(1))

template<typename T, size_t N> constexpr size_t captureN(simdarray<T, N>) { return N; }

TEST_TYPES(V, createArray, SIMD_ARRAY_LIST)
{
    typedef typename V::VectorEntryType VT;
    V array;

    COMPARE(array.size(), captureN(V()));
    VERIFY(sizeof(array) >= array.size() * sizeof(VT));
    VERIFY(sizeof(array) <= 2 * array.size() * sizeof(VT));
}

TEST_TYPES(V, broadcast, SIMD_ARRAY_LIST)
{
    typedef typename V::EntryType T;
    V array = 0;
    array = 1;
    V v0{T(1)};
    V v1 = T(2);
    v0 = 2;
    v1 = 3;
    COMPARE(V(), V(0));
}

TEST_TYPES(V, broadcast_equal, SIMD_ARRAY_LIST)
{
    V a = 0;
    V b = 0;
    COMPARE(a, b);
    a = 1;
    b = 1;
    COMPARE(a, b);<commit_msg>simdarray test: use const-ref to get rid of ABI note<commit_after>/*  This file is part of the Vc library. {{{

    Copyright (C) 2013 <NAME> <<EMAIL>>

    Vc is free software: you can 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 3 of
    the License, or (at your option) any later version.

    Vc is distributed in the hope that it will be useful, but
    WITHOUT ANY WARRANTY; without even the implied warranty of
    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    GNU Lesser General Public License for more details.

    You should have received a copy of the GNU Lesser General Public
    License along with Vc.  If not, see <http://www.gnu.org/licenses/>.

}}}*/

#include "unittest.h"
#include "../common/simdarray.h"

using namespace Vc;

#define SIMD_ARRAY_LIST                                                                            \
    (SIMD_ARRAYS(32),                                                                              \
     SIMD_ARRAYS(17),                                                                              \
     SIMD_ARRAYS(16),                                                                              \
     SIMD_ARRAYS(9),                                                                               \
     SIMD_ARRAYS(8),                                                                               \
     SIMD_ARRAYS(5),                                                                               \
     SIMD_ARRAYS(4),                                                                               \
     SIMD_ARRAYS(3),                                                                               \
     SIMD_ARRAYS(2),                                                                               \
     SIMD_ARRAYS(1))

template <typename T, size_t N> constexpr size_t captureN(const simdarray<T, N> &)
{
    return N;
}

TEST_TYPES(V, createArray, SIMD_ARRAY_LIST)
{
    typedef typename V::VectorEntryType VT;
    V array;

    COMPARE(array.size(), captureN(V()));
    VERIFY(sizeof(array) >= array.size() * sizeof(VT));
    VERIFY(sizeof(array) <= 2 * array.size() * sizeof(VT));
}

TEST_TYPES(V, broadcast, SIMD_ARRAY_LIST)
{
    typedef typename V::EntryType T;
    V array = 0;
    array = 1;
    V v0{T(1)};
    V v1 = T(2);
    v0 = 2;
    v1 = 3;
    COMPARE(V(), V(0));
}

TEST_TYPES(V, broadcast_equal, SIMD_ARRAY_LIST)
{
    V a = 0;
    V b = 0;
    COMPARE(a, b);
    a = 1;
    b = 1;
    COMPARE(a, b);
{'fraction_non_alphanumeric': 0.08333333333333333, 'fraction_numerical': 0.013147718484145398, 'mean_word_length': 1.0960291734197731, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 60, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1509141', 'n_tokens_mistral': 1341, 'n_tokens_neox': 1291, 'n_words': 410}