Skip to content

Commit

Permalink
More core functors turned into new callable
Browse files Browse the repository at this point in the history
  • Loading branch information
jtlap authored May 7, 2024
1 parent 570f1d5 commit 4261f7e
Show file tree
Hide file tree
Showing 20 changed files with 142 additions and 402 deletions.
24 changes: 0 additions & 24 deletions benchmarks/module/core/sqr_abs/regular/sqr_abs.hpp

This file was deleted.

1 change: 0 additions & 1 deletion include/eve/module/core/regular/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,6 @@
#include <eve/module/core/regular/slide_right.hpp>
#include <eve/module/core/regular/sort.hpp>
#include <eve/module/core/regular/sqr.hpp>
#include <eve/module/core/regular/sqr_abs.hpp>
#include <eve/module/core/regular/sqrt.hpp>
#include <eve/module/core/regular/store.hpp>
#include <eve/module/core/regular/sub.hpp>
Expand Down
2 changes: 1 addition & 1 deletion include/eve/module/core/regular/first_true.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ namespace eve
//! **Parameters**
//!
//! * m - logical_value or top_bits where to find first true value
//! * ignore - ignored elements are considred false. Only supported for
//! * ignore - ignored elements are considered false. Only supported for
//! `logical_simd_value`
//!
//! **Return value**
Expand Down
27 changes: 23 additions & 4 deletions include/eve/module/core/regular/firstbitset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>
#include <eve/module/core/regular/inc.hpp>
#include <eve/module/core/regular/bit_andnot.hpp>

namespace eve
{
template<typename Options>
struct firstbitset_t : elementwise_callable<firstbitset_t, Options>
{
template<eve::integral_value T>
constexpr EVE_FORCEINLINE T operator()(T a) const
{ return EVE_DISPATCH_CALL(a); }

EVE_CALLABLE_OBJECT(firstbitset_t, firstbitset_);
};

//================================================================================================
//! @addtogroup core_bitops
//! @{
Expand Down Expand Up @@ -58,7 +69,15 @@ namespace eve
//!
//! @}
//================================================================================================
EVE_MAKE_CALLABLE(firstbitset_, firstbitset);
}
inline constexpr auto firstbitset = functor<firstbitset_t>;

#include <eve/module/core/regular/impl/firstbitset.hpp>
namespace detail
{
template<typename T, callable_options O>
EVE_FORCEINLINE constexpr T
firstbitset_(EVE_REQUIRES(cpu_), O const &, T a0) noexcept
{
return a0 & inc(~a0);
}
}
}
30 changes: 26 additions & 4 deletions include/eve/module/core/regular/firstbitunset.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,21 @@
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>
#include <eve/module/core/regular/inc.hpp>
#include <eve/module/core/regular/bit_notand.hpp>

namespace eve
{
template<typename Options>
struct firstbitunset_t : elementwise_callable<firstbitunset_t, Options>
{
template<eve::integral_value T>
constexpr EVE_FORCEINLINE T operator()(T a) const
{ return EVE_DISPATCH_CALL(a); }

EVE_CALLABLE_OBJECT(firstbitunset_t, firstbitunset_);
};

//================================================================================================
//! @addtogroup core_bitops
//! @{
Expand Down Expand Up @@ -58,7 +69,18 @@ namespace eve
//!
//! @}
//================================================================================================
EVE_MAKE_CALLABLE(firstbitunset_, firstbitunset);
}
inline constexpr auto firstbitunset = functor<firstbitunset_t>;

#include <eve/module/core/regular/impl/firstbitunset.hpp>
namespace detail
{
template<typename T, callable_options O>
EVE_FORCEINLINE constexpr T
firstbitunset_(EVE_REQUIRES(cpu_), O const &, T a0) noexcept
{
if constexpr( scalar_value<T> )
return ~a0 & inc(a0);
else
return bit_notand(a0, inc(a0));
}
}
}
35 changes: 0 additions & 35 deletions include/eve/module/core/regular/impl/firstbitset.hpp

This file was deleted.

40 changes: 0 additions & 40 deletions include/eve/module/core/regular/impl/firstbitunset.hpp

This file was deleted.

39 changes: 0 additions & 39 deletions include/eve/module/core/regular/impl/sqr_abs.hpp

This file was deleted.

60 changes: 0 additions & 60 deletions include/eve/module/core/regular/impl/ulpdist.hpp

This file was deleted.

1 change: 1 addition & 0 deletions include/eve/module/core/regular/is_not_equal.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
#include <eve/module/core/regular/abs.hpp>
#include <eve/module/core/regular/convert.hpp>
#include <eve/module/core/regular/dist.hpp>
#include <eve/module/core/regular/is_not_nan.hpp>
#include <eve/module/core/regular/max.hpp>
#include <eve/module/core/regular/nb_values.hpp>
#include <eve/traits/as_logical.hpp>
Expand Down
3 changes: 2 additions & 1 deletion include/eve/module/core/regular/is_unit.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@
#include <eve/arch.hpp>
#include <eve/traits/overload.hpp>
#include <eve/module/core/decorator/core.hpp>
#include <eve/module/core/regular/sqr_abs.hpp>
#include <eve/module/core/regular/sqr.hpp>
#include <eve/module/core/constant/one.hpp>
#include <eve/traits/as_logical.hpp>

namespace eve
Expand Down
47 changes: 41 additions & 6 deletions include/eve/module/core/regular/nb_values.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,27 @@
#pragma once

#include <eve/arch.hpp>
#include <eve/detail/overload.hpp>
#include <eve/traits/overload.hpp>
#include <eve/module/core/decorator/core.hpp>
#include <eve/module/core/regular/signnz.hpp>
#include <eve/module/core/regular/if_else.hpp>
#include <eve/module/core/regular/is_unordered.hpp>
#include <eve/module/core/regular/is_ltz.hpp>

#include <eve/module/core/detail/next_kernel.hpp>

namespace eve
{
template<typename Options>
struct nb_values_t : elementwise_callable<nb_values_t, Options>
{
template<value T, value U>
EVE_FORCEINLINE constexpr as_integer_t<common_value_t<T, U>, unsigned> operator()(T a, U b) const noexcept
{ return EVE_DISPATCH_CALL(a, b); }

EVE_CALLABLE_OBJECT(nb_values_t, nb_values_);
};

//================================================================================================
//! @addtogroup core_internal
//! @{
Expand All @@ -30,8 +47,8 @@ namespace eve
//! @code
//! namespace eve
//! {
//! template< eve::value T >
//! T nb_values(T x, T y) noexcept;
//! template< eve::value T, eve::value U >
//! as_integer_t<common_value_t<T, U>, unsigned> nb_values(T x, T y) noexcept;
//! }
//! @endcode
//!
Expand All @@ -47,7 +64,25 @@ namespace eve
//!
//! @godbolt{doc/core/nb_values.cpp}
//================================================================================================
EVE_MAKE_CALLABLE(nb_values_, nb_values);
}
inline constexpr auto nb_values = functor<nb_values_t>;

#include <eve/module/core/regular/impl/nb_values.hpp>
namespace detail
{
template<typename T, callable_options O>
constexpr auto nb_values_(EVE_REQUIRES(cpu_), O const&, T a, T b)
{
using ui_t = as_integer_t<T, unsigned>;
if constexpr( floating_value<T> )
{
auto aa = eve::detail::bitinteger(a);
auto bb = eve::detail::bitinteger(b);
auto z = if_else(is_unordered(a, b), eve::valmax(eve::as<ui_t>()), bit_cast(dist(bb, aa), as<ui_t>()));
return inc[is_ltz(signnz(a) * signnz(b))](z);
}
else
{
return dist[saturated](bit_cast(a, as<ui_t>()), bit_cast(b, as<ui_t>()));
}
}
}
}
Loading

0 comments on commit 4261f7e

Please sign in to comment.