-
Notifications
You must be signed in to change notification settings - Fork 61
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
* Implement builtin_vectorizable/vectorizable new concepts * Make wide accept vectorizable type * Make vectorizable works on nested product_type * Adapt unit test becasue MSVC has 8 bytes long double * Don't generate logical<bool> * Renamed concept to plain_scalar/scalar * Better plain_scalar * Remove remaining char * Some more char * More char * Split scalar produc_type concept for later reuse * MSVC is at it again * Final renaming
- Loading branch information
Showing
22 changed files
with
262 additions
and
61 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
//================================================================================================== | ||
/* | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Contributors & Maintainers | ||
SPDX-License-Identifier: MIT | ||
*/ | ||
//================================================================================================== | ||
#pragma once | ||
|
||
#include <eve/detail/kumi.hpp> | ||
#include <eve/detail/meta.hpp> | ||
#include <type_traits> | ||
#include <cstdint> | ||
#include <cstddef> | ||
|
||
namespace eve | ||
{ | ||
template<typename T, typename... Ts> | ||
concept one_of = (std::same_as<T,Ts> || ... || false); | ||
|
||
template<typename T> | ||
concept plain_scalar = one_of< T | ||
, float, double | ||
, std::int8_t , std::int16_t , std::int32_t , std::int64_t | ||
, std::uint8_t, std::uint16_t, std::uint32_t, std::uint64_t | ||
>; | ||
|
||
namespace detail | ||
{ | ||
template<typename T> constexpr bool scalar_tuple() | ||
{ | ||
if constexpr(kumi::product_type<T>) | ||
{ | ||
if constexpr(kumi::size<T>::value != 0) | ||
{ | ||
using flatten_t = kumi::result::flatten_all_t<T>; | ||
return []<std::size_t... I>( std::index_sequence<I...> ) | ||
{ | ||
return (plain_scalar<kumi::element_t<I,flatten_t>> && ... && true); | ||
}(std::make_index_sequence<kumi::size<flatten_t>::value>{}); | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
else | ||
{ | ||
return false; | ||
} | ||
} | ||
} | ||
|
||
template<typename T> | ||
concept product_scalar = detail::scalar_tuple<T>(); | ||
|
||
template<typename T> | ||
concept scalar = plain_scalar<T> || product_scalar<T>; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,143 @@ | ||
//================================================================================================== | ||
/** | ||
EVE - Expressive Vector Engine | ||
Copyright : EVE Contributors & Maintainers | ||
SPDX-License-Identifier: MIT | ||
**/ | ||
//================================================================================================== | ||
#include "test.hpp" | ||
#include <eve/concept/scalar.hpp> | ||
|
||
TTS_CASE("Check for plain_scalar on regular types" ) | ||
{ | ||
TTS_EXPECT( eve::plain_scalar<signed char>); | ||
TTS_EXPECT( eve::plain_scalar<short> ); | ||
TTS_EXPECT( eve::plain_scalar<int> ); | ||
|
||
TTS_EXPECT( eve::plain_scalar<unsigned char> ); | ||
TTS_EXPECT( eve::plain_scalar<unsigned short> ); | ||
TTS_EXPECT( eve::plain_scalar<unsigned int> ); | ||
|
||
TTS_EXPECT( eve::plain_scalar<float> ); | ||
TTS_EXPECT( eve::plain_scalar<double> ); | ||
}; | ||
|
||
TTS_CASE("Check for plain_scalar on cstdint/def types" ) | ||
{ | ||
TTS_EXPECT( eve::plain_scalar<std::int8_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::int16_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::int32_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::int64_t> ); | ||
|
||
TTS_EXPECT( eve::plain_scalar<std::uint8_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::uint16_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::uint32_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::uint64_t> ); | ||
|
||
TTS_EXPECT( eve::plain_scalar<std::size_t> ); | ||
TTS_EXPECT( eve::plain_scalar<std::ptrdiff_t> ); | ||
}; | ||
|
||
TTS_CASE("Check for plain_scalar on unsupported types" ) | ||
{ | ||
TTS_EXPECT_NOT( eve::plain_scalar<long double> ); | ||
TTS_EXPECT_NOT( eve::plain_scalar<bool> ); | ||
TTS_EXPECT_NOT( eve::plain_scalar<void*> ); | ||
TTS_EXPECT_NOT((eve::plain_scalar<kumi::tuple<int,float,std::int8_t>> )); | ||
}; | ||
|
||
TTS_CASE("Check for product_scalar on product_type" ) | ||
{ | ||
TTS_EXPECT((eve::product_scalar<kumi::tuple<int>>)); | ||
TTS_EXPECT((eve::product_scalar<kumi::tuple<int,float>>)); | ||
TTS_EXPECT((eve::product_scalar<kumi::tuple<int,std::int8_t,double>>)); | ||
TTS_EXPECT((eve::product_scalar<kumi::tuple<int,kumi::tuple<std::int8_t,double>,float>>)); | ||
}; | ||
|
||
TTS_CASE("Check for product_scalar on unsupported types" ) | ||
{ | ||
TTS_EXPECT_NOT( eve::product_scalar<long double> ); | ||
TTS_EXPECT_NOT( eve::product_scalar<std::int8_t> ); | ||
TTS_EXPECT_NOT( eve::product_scalar<void*> ); | ||
TTS_EXPECT_NOT((eve::product_scalar<float> ) ); | ||
TTS_EXPECT_NOT((eve::product_scalar<kumi::tuple<void*, int, long double>>) ); | ||
}; | ||
|
||
TTS_CASE("Check for scalar on plain_scalar" ) | ||
{ | ||
TTS_EXPECT( eve::scalar<signed char> ); | ||
TTS_EXPECT( eve::scalar<short> ); | ||
TTS_EXPECT( eve::scalar<int> ); | ||
TTS_EXPECT( eve::scalar<unsigned char> ); | ||
TTS_EXPECT( eve::scalar<unsigned short> ); | ||
TTS_EXPECT( eve::scalar<unsigned int> ); | ||
TTS_EXPECT( eve::scalar<float> ); | ||
TTS_EXPECT( eve::scalar<double> ); | ||
|
||
TTS_EXPECT( eve::scalar<std::int8_t> ); | ||
TTS_EXPECT( eve::scalar<std::int16_t> ); | ||
TTS_EXPECT( eve::scalar<std::int32_t> ); | ||
TTS_EXPECT( eve::scalar<std::int64_t> ); | ||
TTS_EXPECT( eve::scalar<std::uint8_t> ); | ||
TTS_EXPECT( eve::scalar<std::uint16_t> ); | ||
TTS_EXPECT( eve::scalar<std::uint32_t> ); | ||
TTS_EXPECT( eve::scalar<std::uint64_t> ); | ||
TTS_EXPECT( eve::scalar<std::size_t> ); | ||
TTS_EXPECT( eve::scalar<std::ptrdiff_t> ); | ||
}; | ||
|
||
TTS_CASE("Check for scalar on product_type" ) | ||
{ | ||
TTS_EXPECT((eve::scalar<kumi::tuple<int>>)); | ||
TTS_EXPECT((eve::scalar<kumi::tuple<int,float>>)); | ||
TTS_EXPECT((eve::scalar<kumi::tuple<int,std::int8_t,double>>)); | ||
TTS_EXPECT((eve::scalar<kumi::tuple<int,kumi::tuple<std::int8_t,double>,float>>)); | ||
}; | ||
|
||
TTS_CASE("Check for scalar on unsupported types" ) | ||
{ | ||
TTS_EXPECT_NOT( eve::scalar<long double> ); | ||
TTS_EXPECT_NOT( eve::scalar<bool> ); | ||
TTS_EXPECT_NOT( eve::scalar<void*> ); | ||
TTS_EXPECT_NOT( (eve::scalar<kumi::tuple<>>) ); | ||
TTS_EXPECT_NOT( (eve::scalar<kumi::tuple<int,bool>>) ); | ||
}; | ||
|
||
template<eve::plain_scalar T> auto check_overload(T) { return +1; } | ||
template<eve::scalar T> auto check_overload(T) { return +2; } | ||
template<eve::scalar T> auto check_overload2(T) { return +3; } | ||
template<eve::product_scalar T> auto check_overload3(T) { return +10; } | ||
template<typename T> auto check_overload(T) { return -1; } | ||
template<typename T> auto check_overload2(T) { return -3; } | ||
template<typename T> auto check_overload3(T) { return -10; } | ||
|
||
TTS_CASE("Check for scalar/plain_scalar overload relationship" ) | ||
{ | ||
TTS_EQUAL(check_overload(4) , +1); | ||
TTS_EQUAL(check_overload(4.f) , +1); | ||
TTS_EQUAL(check_overload(kumi::tuple{4}) , +2); | ||
TTS_EQUAL(check_overload(kumi::tuple{3,5.f}) , +2); | ||
|
||
TTS_EQUAL(check_overload(nullptr) , -1); | ||
TTS_EQUAL(check_overload(kumi::tuple<>{}) , -1); | ||
TTS_EQUAL(check_overload(kumi::tuple{nullptr}) , -1); | ||
|
||
TTS_EQUAL(check_overload2(4) , +3); | ||
TTS_EQUAL(check_overload2(4.f) , +3); | ||
TTS_EQUAL(check_overload2(kumi::tuple{4}) , +3); | ||
TTS_EQUAL(check_overload2(kumi::tuple{3,5.f}) , +3); | ||
|
||
TTS_EQUAL(check_overload2(nullptr) , -3); | ||
TTS_EQUAL(check_overload2(kumi::tuple<>{}) , -3); | ||
TTS_EQUAL(check_overload2(kumi::tuple{nullptr}) , -3); | ||
|
||
TTS_EQUAL(check_overload3(kumi::tuple{4}) , +10); | ||
TTS_EQUAL(check_overload3(kumi::tuple{3,5.f}) , +10); | ||
TTS_EQUAL(check_overload3(kumi::tuple{3,kumi::tuple{4.},5.f}) , +10); | ||
|
||
TTS_EQUAL(check_overload3(4) , -10); | ||
TTS_EQUAL(check_overload3(4.f) , -10); | ||
TTS_EQUAL(check_overload3(nullptr) , -10); | ||
TTS_EQUAL(check_overload3(kumi::tuple<>{}) , -10); | ||
TTS_EQUAL(check_overload3(kumi::tuple{nullptr}) , -10); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.