intend_to_pass_type_in_template_arg

Created Diff never expires
4 removals
45 lines
4 additions
45 lines
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//
//
//
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
// See https://llvm.org/LICENSE.txt for license information.
// See https://llvm.org/LICENSE.txt for license information.
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
// SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
//
//
//===----------------------------------------------------------------------===//
//===----------------------------------------------------------------------===//


#ifndef TEST_UTIL_H
#ifndef TEST_UTIL_H
#define TEST_UTIL_H
#define TEST_UTIL_H


#include <utility>
#include <utility>
#include <experimental/simd>
#include <experimental/simd>
#include "type_algorithms.h"
#include "type_algorithms.h"


namespace ex = std::experimental::parallelism_v2;
namespace ex = std::experimental::parallelism_v2;


constexpr std::size_t max_simd_size = 32;
constexpr std::size_t max_simd_size = 32;


template <template <std::size_t N> class F>
template <template <class T, std::size_t N> class F>
struct TestAllSimdAbiFunctor {
struct TestAllSimdAbiFunctor {
template <class T, std::size_t N>
template <class T, std::size_t N>
using sized_abis = types::type_list<ex::simd_abi::fixed_size<N>, ex::simd_abi::deduce_t<T, N>>;
using sized_abis = types::type_list<ex::simd_abi::fixed_size<N>, ex::simd_abi::deduce_t<T, N>>;


template <class T, std::size_t... Ns>
template <class T, std::size_t... Ns>
void instantiate_with_n(std::index_sequence<Ns...>) {
void instantiate_with_n(std::index_sequence<Ns...>) {
(types::for_each(sized_abis<T, Ns + 1>{}, F<Ns + 1>{}), ...);
(types::for_each(sized_abis<T, Ns + 1>{}, F<T, Ns + 1>{}), ...);
}
}


template <class T>
template <class T>
void operator()() {
void operator()() {
using abis = types::type_list<ex::simd_abi::scalar, ex::simd_abi::native<T>, ex::simd_abi::compatible<T>>;
using abis = types::type_list<ex::simd_abi::scalar, ex::simd_abi::native<T>, ex::simd_abi::compatible<T>>;
types::for_each(abis{}, F<1>());
types::for_each(abis{}, F<T, 1>());


instantiate_with_n<T>(std::make_index_sequence<max_simd_size - 1>{});
instantiate_with_n<T>(std::make_index_sequence<max_simd_size - 1>{});
}
}
};
};


template <template <std::size_t N> class Func>
template <template <class T, std::size_t N> class Func>
void test_all_simd_abi() {
void test_all_simd_abi() {
using arithmetic_no_bool_types = types::concatenate_t<types::integer_types, types::floating_point_types>;
using arithmetic_no_bool_types = types::concatenate_t<types::integer_types, types::floating_point_types>;
types::for_each(arithmetic_no_bool_types(), TestAllSimdAbiFunctor<Func>());
types::for_each(arithmetic_no_bool_types(), TestAllSimdAbiFunctor<Func>());
}
}


#endif // TEST_UTIL_H
#endif // TEST_UTIL_H