Skip to content

Commit

Permalink
Adapt + - * operators to new style
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou authored May 19, 2024
1 parent f9cd9f2 commit e92ef40
Show file tree
Hide file tree
Showing 71 changed files with 727 additions and 1,744 deletions.
24 changes: 0 additions & 24 deletions benchmarks/module/core/plus/regular/plus.hpp

This file was deleted.

39 changes: 0 additions & 39 deletions include/eve/detail/function/operators.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,45 +19,6 @@ namespace eve::detail
//================================================================================================
// Infix arithmetic operators
//================================================================================================
template<scalar_value T>
EVE_FORCEINLINE auto add_(EVE_SUPPORTS(cpu_), T a, T b) noexcept
{
return static_cast<T>(a + b);
}

template<value T, value U>
EVE_FORCEINLINE auto
add_(EVE_SUPPORTS(cpu_), T const &a, U const &b) noexcept requires compatible_values<T, U>
{
return a + b;
}

template<scalar_value T>
EVE_FORCEINLINE auto sub_(EVE_SUPPORTS(cpu_), T a, T b) noexcept
{
return static_cast<T>(a - b);
}

template<value T, value U>
EVE_FORCEINLINE auto
sub_(EVE_SUPPORTS(cpu_), T const &a, U const &b) noexcept requires compatible_values<T, U>
{
return a - b;
}

template<scalar_value T>
EVE_FORCEINLINE auto mul_(EVE_SUPPORTS(cpu_), T a, T b) noexcept
{
return static_cast<T>(a * b);
}

template<value T, value U>
EVE_FORCEINLINE auto
mul_(EVE_SUPPORTS(cpu_), T const &a, U const &b) noexcept requires compatible_values<T, U>
{
return a * b;
}

template<scalar_value T>
EVE_FORCEINLINE auto div_(EVE_SUPPORTS(cpu_), T a, T b) noexcept
{
Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/algo/algo/inclusive_scan.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ namespace eve::algo
template <relaxed_range Rng, typename U>
EVE_FORCEINLINE void operator()(Rng&& rng, U init) const
{
operator()(EVE_FWD(rng), std::pair{eve::plus, eve::zero}, init);
operator()(EVE_FWD(rng), std::pair{eve::add, eve::zero}, init);
}
};

Expand All @@ -107,7 +107,7 @@ namespace eve::algo
template <zipped_range_pair R, typename U>
EVE_FORCEINLINE auto operator()(R r, U init) const
{
operator()(r, std::pair{eve::plus, eve::zero}, init);
operator()(r, std::pair{eve::add, eve::zero}, init);
}

template <typename R1, typename R2, typename Op, typename Zero, typename U>
Expand Down
2 changes: 1 addition & 1 deletion include/eve/module/algo/algo/reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ namespace eve::algo
//! * `rng`: Relaxed range input range to process
//! * `init`: Initial value. Also type of init matches the result type
//! * `op_zero`: Pair of reduction operation (commutative/associative) and an identity (zero)
//! for it. Default add_zero is `{eve::plus, eve::zero}`.
//! for it. Default add_zero is `{eve::add, eve::zero}`.
//!
//! **Return value**
//!
Expand Down
2 changes: 1 addition & 1 deletion include/eve/module/algo/algo/transform_reduce.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ template<typename TraitsSupport> struct transform_reduce_ : TraitsSupport
//! * `init`: Initial value. Also type of init matches the result type
//! * `map_op`: Transformation operation
//! * `add_zero`: Pair of reduction operation (commutative/associative) and an identity (zero)
//! for it. Default add_zero is `{eve::plus, eve::zero}`.
//! for it. Default add_zero is `{eve::add, eve::zero}`.
//!
//! **Return value**
//!
Expand Down
3 changes: 1 addition & 2 deletions include/eve/module/core/detail/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,5 @@
//==================================================================================================
#include <eve/module/core/detail/horn.hpp>
#include <eve/module/core/detail/horn1.hpp>
#include <eve/module/core/detail/multi_div.hpp>
#include <eve/module/core/detail/multi_mul.hpp>
#include <eve/module/core/detail/next_kernel.hpp>
#include <eve/module/core/detail/multi_div.hpp>
2 changes: 1 addition & 1 deletion include/eve/module/core/detail/multi_div.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ namespace eve::detail
{
using r_t = common_value_t<T0, T1, Ts...>;
r_t that(a1);
that = d(mul)(that, r_t(args)...);
that = mul[d](that, r_t(args)...);
EVE_ASSERT(eve::all(is_nez(that)), "[eve] D()(div) - 0/0 is undefined");
return (D()(div))(r_t(a0), that);
}
Expand Down
27 changes: 0 additions & 27 deletions include/eve/module/core/detail/multi_mul.hpp

This file was deleted.

39 changes: 29 additions & 10 deletions include/eve/module/core/regular/add.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,29 @@
//==================================================================================================
#pragma once

#include <eve/detail/overload.hpp>
#include <eve/arch.hpp>
#include <eve/traits/overload.hpp>
#include <eve/module/core/decorator/core.hpp>

namespace eve
{
template<typename Options>
struct add_t : tuple_callable<add_t, Options, saturated_option>
{
template<eve::value T0, value T1, value... Ts>
EVE_FORCEINLINE constexpr common_value_t<T0, T1, Ts...> operator()(T0 t0, T1 t1, Ts...ts) const noexcept
{
return EVE_DISPATCH_CALL(t0, t1, ts...);
}

template<kumi::non_empty_product_type Tup>
EVE_FORCEINLINE constexpr
kumi::apply_traits_t<eve::common_value,Tup>
operator()(Tup const& t) const noexcept requires(kumi::size_v<Tup> >= 2) { return EVE_DISPATCH_CALL(t); }

EVE_CALLABLE_OBJECT(add_t, add_);
};

//================================================================================================
//! @addtogroup core_arithmetic
//! @{
Expand All @@ -28,26 +47,25 @@ namespace eve
//! @code
//! namespace eve
//! {
//! template< eve::value... Ts >
//! template<eve::value... Ts >
//! eve::common_value_t<Ts ...> add(Ts ... xs) noexcept;
//! }
//! @endcode
//!
//! **Parameters**
//!
//! * `xs ...` : [real](@ref eve::value) arguments.
//! * `xs ...` : [Values](@ref eve::value) to sum.
//!
//! **Return value**
//!
//! The value of the sum of the arguments is returned.
//! The value of the sum of the arguments.
//!
//! @note
//!
//! * Take care that for floating entries, the addition is only 'almost' associative.
//! This call performs additions in reverse incoming order.
//!
//! * Although the infix notation with `+` is supported for
//! two parameters, the `+` operator on
//! * Although the infix notation with `+` is supported for two parameters, the `+` operator on
//! standard scalar types is the original one and so can lead to automatic promotion.
//!
//! @groupheader{Example}
Expand All @@ -63,15 +81,16 @@ namespace eve
//!
//! * eve::saturated
//!
//! The call `eve::saturated(eve::add)(...)` computes
//! a saturated version of `eve::add`.
//! The call `eve::add[eve::saturated](...)` computes a saturated version of `eve::add`.
//!
//! Take care that for signed integral entries this kind of addition is not associative at all.
//! This call perform saturated additions in reverse incoming order.
//!
//! @}
//================================================================================================
EVE_MAKE_CALLABLE(add_, add);
inline constexpr auto add = functor<add_t>;

// Required for optimisation detections
using callable_add_ = tag_t<add>;
}

#include <eve/module/core/regular/impl/add.hpp>
Expand Down
2 changes: 0 additions & 2 deletions include/eve/module/core/regular/core.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@
#include <eve/module/core/regular/has_single_bit.hpp>
#include <eve/module/core/regular/hi.hpp>
#include <eve/module/core/regular/if_else.hpp>
#include <eve/module/core/regular/ifnot_else.hpp>
#include <eve/module/core/regular/ifrexp.hpp>
#include <eve/module/core/regular/inc.hpp>
#include <eve/module/core/regular/interleave.hpp>
Expand Down Expand Up @@ -169,7 +168,6 @@
#include <eve/module/core/regular/nextafter.hpp>
#include <eve/module/core/regular/none.hpp>
#include <eve/module/core/regular/oneminus.hpp>
#include <eve/module/core/regular/plus.hpp>
#include <eve/module/core/regular/popcount.hpp>
#include <eve/module/core/regular/prev.hpp>
#include <eve/module/core/regular/rat.hpp>
Expand Down
61 changes: 0 additions & 61 deletions include/eve/module/core/regular/ifnot_else.hpp

This file was deleted.

Loading

0 comments on commit e92ef40

Please sign in to comment.