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

Adds proper float comparison for axpy test. #539

Merged
merged 1 commit into from
Jun 20, 2018
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
14 changes: 0 additions & 14 deletions test/common/include/alpaka/test/mem/view/ViewTest.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,10 +169,6 @@ namespace alpaka

//#############################################################################
//! Compares element-wise that all bytes are set to the same value.
#if BOOST_COMP_GNUC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal" // "comparing floating point with == or != is unsafe"
#endif
struct VerifyBytesSetKernel
{
ALPAKA_NO_HOST_ACC_WARNING
Expand All @@ -189,25 +185,15 @@ namespace alpaka
(void)acc;
for(auto it = begin; it != end; ++it)
{
#if BOOST_COMP_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal" // "comparing floating point with == or != is unsafe"
#endif
auto const& elem = *it;
auto const pBytes = reinterpret_cast<std::uint8_t const *>(&elem);
for(std::size_t i = 0u; i < elemSizeInByte; ++i)
{
BOOST_VERIFY(pBytes[i] == byte);
}
#if BOOST_COMP_CLANG
#pragma clang diagnostic pop
#endif
}
}
};
#if BOOST_COMP_GNUC
#pragma GCC diagnostic pop
#endif
//-----------------------------------------------------------------------------
template<
typename TAcc,
Expand Down
18 changes: 3 additions & 15 deletions test/integ/axpy/src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
#if BOOST_COMP_CLANG
#pragma clang diagnostic pop
#endif
#include <boost/math/special_functions/relative_difference.hpp>

#include <alpaka/alpaka.hpp>
#include <alpaka/test/MeasureKernelRunTime.hpp>
Expand All @@ -46,6 +47,7 @@

#include <iostream>
#include <typeinfo>
#include <limits>

//#############################################################################
//! A vector addition kernel.
Expand Down Expand Up @@ -104,10 +106,6 @@ using TestAccs = alpaka::test::acc::EnabledAccs<
alpaka::dim::DimInt<1u>,
std::size_t>;

#if BOOST_COMP_GNUC
#pragma GCC diagnostic push
#pragma GCC diagnostic ignored "-Wfloat-equal" // "comparing floating point with == or != is unsafe"
#endif

BOOST_AUTO_TEST_CASE_TEMPLATE(
calculateAxpy,
Expand Down Expand Up @@ -237,14 +235,7 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(
{
auto const & val(pHostResultData[i]);
auto const correctResult(alpha * alpaka::mem::view::getPtrNative(memBufHostX)[i] + alpaka::mem::view::getPtrNative(memBufHostOrigY)[i]);
#if BOOST_COMP_CLANG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wfloat-equal" // "comparing floating point with == or != is unsafe"
#endif
if(val != correctResult)
#if BOOST_COMP_CLANG
#pragma clang diagnostic pop
#endif
if( boost::math::relative_difference(val, correctResult) > std::numeric_limits<Val>::epsilon() )
{
std::cout << "C[" << i << "] == " << val << " != " << correctResult << std::endl;
resultCorrect = false;
Expand All @@ -253,8 +244,5 @@ BOOST_AUTO_TEST_CASE_TEMPLATE(

BOOST_REQUIRE_EQUAL(true, resultCorrect);
}
#if BOOST_COMP_GNUC
#pragma GCC diagnostic pop
#endif

BOOST_AUTO_TEST_SUITE_END()