Skip to content

Commit

Permalink
Update to new TTS
Browse files Browse the repository at this point in the history
  • Loading branch information
jfalcou authored Sep 5, 2023
1 parent 4d4ff18 commit c8686c4
Show file tree
Hide file tree
Showing 5 changed files with 527 additions and 512 deletions.
1 change: 0 additions & 1 deletion test/producers.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
//==================================================================================================
#pragma once
#include "test.hpp"
#include <tts/ranges.hpp>
#include <eve/memory/align.hpp>
#include <eve/concept/value.hpp>
#include <eve/traits.hpp>
Expand Down
35 changes: 31 additions & 4 deletions test/test.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@
#pragma once
#define TTS_MAIN
#define TTS_CUSTOM_DRIVER_FUNCTION eve_entry_point
#include <tts/tts.hpp>

//==================================================================================================
// EVE Specific testing overloads
Expand Down Expand Up @@ -36,12 +35,21 @@ namespace eve

namespace tts
{
template<typename T, typename U>
double ulp_distance(T const &l, U const &r);

template<typename T, typename U>
double relative_distance(T const &l, U const &r);

template<typename T, typename U>
double absolute_distance(T const &l, U const &r);

template<typename T, typename N>
inline double ulp_distance(eve::wide<T, N> const &l, eve::wide<T, N> const &r)
{
double max_ulp = 0;
for(auto i = 0; i < l.size(); ++i)
max_ulp = std::max(max_ulp, tts::ulp_distance(T(l.get(i)), T(r.get(i))));
max_ulp = std::max(max_ulp, ulp_distance(T(l.get(i)), T(r.get(i))));

return max_ulp;
}
Expand All @@ -52,12 +60,29 @@ namespace tts
return eve::compare_equal(l,r) ? 0. : std::numeric_limits<double>::infinity();
}

template<typename T, typename N>
inline bool is_ieee_equal(eve::wide<T, N> const &a, eve::wide<T, N> const &b)
{
for(auto i = 0; i < a.size(); ++i)
{
if( (a.get(i) != b.get(i)) && !(eve::is_nan(a.get(i)) && eve::is_nan(b.get(i))))
return false;
}
return true;
}

template<typename T>
inline bool is_ieee_equal(eve::logical<T> const &l, eve::logical<T>const &r)
{
return eve::compare_equal(l,r);
}

template<typename T, typename N>
inline double relative_distance(eve::wide<T, N> const &l, eve::wide<T, N> const &r)
{
double max_ulp = 0;
for(auto i = 0; i < l.size(); ++i)
max_ulp = std::max(max_ulp, tts::relative_distance(T(l.get(i)), T(r.get(i))));
max_ulp = std::max(max_ulp, relative_distance(T(l.get(i)), T(r.get(i))));

return max_ulp;
}
Expand All @@ -73,7 +98,7 @@ namespace tts
{
double max_ulp = 0;
for(auto i = 0; i < l.size(); ++i)
max_ulp = std::max(max_ulp, tts::absolute_distance(T(l.get(i)), T(r.get(i))));
max_ulp = std::max(max_ulp, absolute_distance(T(l.get(i)), T(r.get(i))));

return max_ulp;
}
Expand All @@ -85,6 +110,8 @@ namespace tts
}
}

#include <tts/tts.hpp>

//==================================================================================================
// EVE Specific types
//==================================================================================================
Expand Down
Loading

0 comments on commit c8686c4

Please sign in to comment.