Skip to content

Commit

Permalink
Remove dangerous scalar_cardinal remaining uses
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou committed Dec 16, 2022
1 parent 4e766d7 commit ae3c5ef
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 19 deletions.
9 changes: 0 additions & 9 deletions include/eve/arch/cardinals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ namespace eve
template <typename T>
concept wide_cardinal = detail::is_wide_cardinal<T>::value;

//================================================================================================
//! @brief Cardinal type for scalar values
//================================================================================================
struct scalar_cardinal : std::integral_constant<std::ptrdiff_t, 1ULL>
{
using type = scalar_cardinal;
using combined_type = fixed<2>;
};

template<std::ptrdiff_t Cardinal>
inline constexpr fixed<Cardinal> const lane = {};

Expand Down
8 changes: 7 additions & 1 deletion include/eve/detail/skeleton.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,13 @@ namespace eve::detail
template<typename F, typename... Ts>
struct wide_result
{
static constexpr std::size_t card_v = std::max({eve::cardinal_v<std::decay_t<Ts>>...});
template<typename T>
static constexpr std::ptrdiff_t card() noexcept
{
if constexpr(simd_value<T>) return T::size(); else return 1;
}

static constexpr std::size_t card_v = std::max({card<std::decay_t<Ts>>()...});
using value_t = decltype(std::declval<F>()(at(std::declval<Ts>(), 0)...));
using fixed_t = fixed<card_v>;

Expand Down
7 changes: 2 additions & 5 deletions include/eve/traits/cardinal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
namespace eve
{
template<std::ptrdiff_t Cardinal> struct fixed;
struct scalar_cardinal;

//================================================================================================
//! @addtogroup traits
Expand Down Expand Up @@ -51,10 +50,8 @@ namespace eve
//! @}
//================================================================================================
template<typename Type>
struct cardinal : scalar_cardinal
{
using type = scalar_cardinal;
};
struct cardinal : fixed<1>
{};

template<typename Type, typename Size>
struct cardinal<wide<Type, Size>> : Size
Expand Down
5 changes: 1 addition & 4 deletions test/unit/meta/cardinal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,7 @@

TTS_CASE( "Check for scalar cardinals")
{
TTS_TYPE_IS( eve::cardinal_t<float> , eve::scalar_cardinal );
TTS_EQUAL ( eve::cardinal_v<float> , 1 );

TTS_TYPE_IS( eve::cardinal_t<eve::logical<float>> , eve::scalar_cardinal );
TTS_EQUAL ( eve::cardinal_v<float> , 1 );
TTS_EQUAL ( eve::cardinal_v<eve::logical<float>> , 1 );
};

Expand Down

0 comments on commit ae3c5ef

Please sign in to comment.