Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix apple clang build #1479

Merged
merged 1 commit into from
Dec 10, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 0 additions & 9 deletions include/eve/algo/concepts/detail.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,15 +26,6 @@ namespace eve::algo::detail
{ std::declval<T>() <=> std::declval<U>() };
};

template <typename>
struct is_fixed : std::false_type {};

template <std::ptrdiff_t N>
struct is_fixed<eve::fixed<N>> : std::true_type {};

template <typename T>
concept is_fixed_v = is_fixed<T>::value;

template <typename I>
concept iterator_operations =
std::copyable<std::remove_cvref_t<I>> &&
Expand Down
2 changes: 1 addition & 1 deletion include/eve/algo/concepts/eve_iterator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ namespace eve::algo
template <typename I>
concept iterator =
requires(I) {
{ std::remove_cvref_t<I>::iterator_cardinal() } -> detail::is_fixed_v;
{ std::remove_cvref_t<I>::iterator_cardinal() } -> wide_cardinal;
typename std::remove_cvref_t<I>::value_type;
} &&
std::totally_ordered_with<I, partially_aligned_t<I>> &&
Expand Down
2 changes: 1 addition & 1 deletion include/eve/algo/container/soa_vector.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ namespace eve::algo
auto ptr = l.begin();
for(size_type i = 0; i < size(); ++i)
{
eve::write(*ptr++, begin()+i);
eve::write(*ptr++, begin() + (std::ptrdiff_t)i);
}
}

Expand Down
2 changes: 1 addition & 1 deletion include/eve/algo/views/iota.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ namespace eve::algo::views

EVE_FORCEINLINE friend T tagged_dispatch(eve::tag::read_, iota_with_step_iterator self)
{
return self.base + eve::convert(self.i * self.step, eve::as<T>{});
return self.base + (T)self.i * self.step;
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This cast is because you can't eve::convert ptrdifft

}

template <typename U>
Expand Down
21 changes: 21 additions & 0 deletions include/eve/arch/cardinals.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,27 @@ namespace eve
using combined_type = fixed<2>;
};

namespace detail {

template <typename>
struct is_wide_cardinal : std::false_type {};

template <std::ptrdiff_t N>
struct is_wide_cardinal<eve::fixed<N>> : std::true_type {};

} // namespace detail

//================================================================================================
//! @brief concept to determine if this is cardinal type of a wide
//!
//! @tparam T
//!
//! only true if T is instance of `eve::fixed`.
//!
//! This concept is needed to define some other concepts, unlikely to be useful on it's own.
//================================================================================================
template <typename T>
concept wide_cardinal = detail::is_wide_cardinal<T>::value;

//================================================================================================
//! @brief Cardinal type for scalar values
Expand Down
4 changes: 4 additions & 0 deletions include/eve/memory/aligned_allocator.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@
#include <malloc.h>
#endif

#include <iostream>

namespace eve
{
//================================================================================================
Expand Down Expand Up @@ -72,11 +74,13 @@ namespace eve

void * allocate_aligned(std::size_t n, std::size_t a)
{
if (a < 8U) a = 8U;
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

a = std::min(a,8U); ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

max. I thought about it but I figured I can not bring algorithm.

Also size_t and U are different types on apple clang - I'd have to cast

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Tried - because of the cast I don't want to.

auto sz = align(n, over{a});

#if defined(SPY_COMPILER_IS_MSVC)
return _aligned_malloc(sz,a);
#else

return std::aligned_alloc(a, sz);
#endif
}
Expand Down
4 changes: 2 additions & 2 deletions include/eve/module/bessel/detail/evaluate_rational.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ evaluate_rational(const T num, const U den, V z) noexcept
z = rec(z);
auto r = horner(z, num) / horner(z, den);
if( size(den) == size(num) ) return r;
else return r * pow(z, size(num) - size(den));
else return r * pow(z, (std::uint64_t) size(num) - size(den));
};
auto test = z <= V(1);
if( eve::all(test) ) return eval_small(z);
Expand All @@ -42,7 +42,7 @@ reverse_evaluate_rational(const T num, const U den, V z) noexcept
z = rec(z);
auto r = reverse_horner(z, num) / reverse_horner(z, den);
if( size(den) == size(num) ) return r;
else return r * pow(z, size(num) - size(den));
else return r * pow(z, (std::uint64_t) size(num) - size(den));
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this pops up because size_t is not passing the concept. And going to pow is not working.

};
auto test = z <= V(1);
if( eve::all(test) ) return eval_small(z);
Expand Down
18 changes: 12 additions & 6 deletions include/eve/traits/as_wide.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -53,12 +53,18 @@ namespace eve
using as_wide_t = typename as_wide<Type, Size>::type;

template<typename T, typename U>
struct as_wide_as
: std::conditional< !simd_value<T> && simd_value<U>
, as_wide_t<T,cardinal_t<U>>
, T
>
{};
struct as_wide_as;


template<scalar_value T, simd_value U>
struct as_wide_as<T, U> {
using type = as_wide_t<T,cardinal_t<U>>;
};

template<value T, typename U>
struct as_wide_as<T, U> {
using type = T;
};

template<typename T, typename U>
using as_wide_as_t = typename as_wide_as<T,U>::type;
Expand Down
2 changes: 1 addition & 1 deletion include/eve/traits/value_type.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,6 @@ namespace eve
//================================================================================================

template <typename T>
requires (!value<T>)
requires (!value<T> && !wide_cardinal<T>)
using value_type_t = typename decltype(detail::value_type_impl<T>())::type;
}
4 changes: 0 additions & 4 deletions test/unit/meta/concepts/logical.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,6 @@ TTS_CASE("Check for logical_scalar/simd_value on cstdint/def types" )
TTS_EXPECT( eve::logical_scalar_value<eve::logical<std::uint16_t>> );
TTS_EXPECT( eve::logical_scalar_value<eve::logical<std::uint32_t>> );
TTS_EXPECT( eve::logical_scalar_value<eve::logical<std::uint64_t>> );
TTS_EXPECT( eve::logical_scalar_value<eve::logical<std::size_t>> );
TTS_EXPECT( eve::logical_scalar_value<eve::logical<std::ptrdiff_t> >);

TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::int8_t>>> );
TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::int16_t>>> );
Expand All @@ -50,8 +48,6 @@ TTS_CASE("Check for logical_scalar/simd_value on cstdint/def types" )
TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::uint16_t>>> );
TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::uint32_t>>> );
TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::uint64_t>>> );
TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::size_t>>> );
TTS_EXPECT( eve::logical_simd_value<eve::logical<eve::wide<std::ptrdiff_t>>>);
};

TTS_CASE("Check for logical_scalar/simd_value on unsupported types" )
Expand Down
5 changes: 0 additions & 5 deletions test/unit/meta/concepts/scalar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ TTS_CASE("Check for plain_scalar_value on cstdint/def types" )
TTS_EXPECT( eve::plain_scalar_value<std::uint16_t> );
TTS_EXPECT( eve::plain_scalar_value<std::uint32_t> );
TTS_EXPECT( eve::plain_scalar_value<std::uint64_t> );

TTS_EXPECT( eve::plain_scalar_value<std::size_t> );
TTS_EXPECT( eve::plain_scalar_value<std::ptrdiff_t> );
};

TTS_CASE("Check for plain_scalar_value on unsupported types" )
Expand Down Expand Up @@ -82,8 +79,6 @@ TTS_CASE("Check for arithmetic_scalar_value on plain_scalar_value" )
TTS_EXPECT( eve::arithmetic_scalar_value<std::uint16_t> );
TTS_EXPECT( eve::arithmetic_scalar_value<std::uint32_t> );
TTS_EXPECT( eve::arithmetic_scalar_value<std::uint64_t> );
TTS_EXPECT( eve::arithmetic_scalar_value<std::size_t> );
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I need to get more info on what Apple Clang doesn't liek about those.
size_t and ptrdiff_t are common type people will want to use.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So is char. But it doesn't work.

If we want to support all of the weird types that are not actually the same, we have to solve it as a separate problem.

TTS_EXPECT( eve::arithmetic_scalar_value<std::ptrdiff_t> );
};

TTS_CASE("Check for arithmetic_scalar_value on product_type" )
Expand Down
6 changes: 0 additions & 6 deletions test/unit/meta/concepts/simd.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,6 @@ TTS_CASE("Check for plain_simd_value on cstdint/def types" )
TTS_EXPECT( eve::plain_simd_value<eve::wide<std::uint16_t>> );
TTS_EXPECT( eve::plain_simd_value<eve::wide<std::uint32_t>> );
TTS_EXPECT( eve::plain_simd_value<eve::wide<std::uint64_t>> );

TTS_EXPECT( eve::plain_simd_value<eve::wide<std::size_t>> );
TTS_EXPECT( eve::plain_simd_value<eve::wide<std::ptrdiff_t>> );
};

TTS_CASE("Check for plain_simd_value on unsupported types" )
Expand Down Expand Up @@ -88,9 +85,6 @@ TTS_CASE("Check for arithmetic_simd_value on plain_simd_value" )
TTS_EXPECT( eve::arithmetic_simd_value<eve::wide<std::uint16_t>> );
TTS_EXPECT( eve::arithmetic_simd_value<eve::wide<std::uint32_t>> );
TTS_EXPECT( eve::arithmetic_simd_value<eve::wide<std::uint64_t>> );

TTS_EXPECT( eve::arithmetic_simd_value<eve::wide<std::size_t>> );
TTS_EXPECT( eve::arithmetic_simd_value<eve::wide<std::ptrdiff_t>> );
};

TTS_CASE("Check for arithmetic_simd_value on product_type" )
Expand Down
8 changes: 4 additions & 4 deletions test/unit/module/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,13 @@
## Modules
add_subdirectory(core)
add_subdirectory(complex)
add_subdirectory(polynomial)
add_subdirectory(proba)

#if(EVE_USE_BOOST)
if(EVE_USE_BOOST)
add_subdirectory(bessel)
add_subdirectory(elliptic)
add_subdirectory(combinatorial)
add_subdirectory(elliptic)
add_subdirectory(math)
add_subdirectory(polynomial)
add_subdirectory(special)
#endif()
endif()
11 changes: 7 additions & 4 deletions test/unit/module/complex/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,12 @@
add_custom_target(unit.complex.exe )
add_dependencies(unit.exe unit.complex.exe )

if(EVE_USE_BOOST)
make_unit("unit.complex" asin.cpp )
make_unit("unit.complex" atanh.cpp )
make_unit("unit.complex" asinh.cpp )
endif()

make_unit("unit.complex" abs.cpp )
make_unit("unit.complex" acos.cpp )
make_unit("unit.complex" acosh.cpp )
Expand All @@ -22,11 +28,8 @@ make_unit("unit.complex" agd.cpp )
make_unit("unit.complex" asec.cpp )
make_unit("unit.complex" asech.cpp )
make_unit("unit.complex" asecpi.cpp )
make_unit("unit.complex" asin.cpp )
make_unit("unit.complex" asinh.cpp )
make_unit("unit.complex" asinpi.cpp )
make_unit("unit.complex" atan.cpp )
make_unit("unit.complex" atanh.cpp )
make_unit("unit.complex" atanpi.cpp )
make_unit("unit.complex" average.cpp )
make_unit("unit.complex" beta.cpp )
Expand Down Expand Up @@ -127,4 +130,4 @@ make_unit("unit.complex" tan.cpp )
make_unit("unit.complex" tanh.cpp )
make_unit("unit.complex" tanpi.cpp )
make_unit("unit.complex" tgamma.cpp )
make_unit("unit.complex" trunc.cpp )
make_unit("unit.complex" trunc.cpp )
10 changes: 5 additions & 5 deletions test/unit/module/complex/sqr.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ TTS_CASE_WITH( "Check behavior of sqr on scalar"
for(auto f : a1)
{
auto z1= c_t(e, f);
TTS_ULP_EQUAL( eve::sqr(z1), z1*z1, 2.0);
TTS_ULP_EQUAL( eve::sqr(z1), z1*z1, 18.0);
}
}
};
Expand All @@ -41,8 +41,8 @@ TTS_CASE_WITH( "Check behavior of sqr on wide"
using z_t = eve::wide<eve::complex<e_t>, typename T::cardinal_type>;

z_t z{a0,a1};
TTS_ULP_EQUAL( eve::sqr(a0), a0*a0, 2.0);
TTS_ULP_EQUAL( eve::sqr(z_t{a0,a1}), z*z, 2.0);
TTS_ULP_EQUAL( eve::pedantic(eve::sqr)(a0), a0*a0, 2.0);
TTS_ULP_EQUAL( eve::pedantic(eve::sqr)(z), z*z, 6.0);
TTS_ULP_EQUAL( eve::sqr(a0), a0*a0, 18.0);
TTS_ULP_EQUAL( eve::sqr(z_t{a0,a1}), z*z, 18.0);
TTS_ULP_EQUAL( eve::pedantic(eve::sqr)(a0), a0*a0, 18.0);
TTS_ULP_EQUAL( eve::pedantic(eve::sqr)(z), z*z, 18.0);
};