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

Update numerics support for __float128 #5081

Merged
merged 7 commits into from
Jun 2, 2022

Conversation

dalg24
Copy link
Member

@dalg24 dalg24 commented Jun 2, 2022

Fix #5080

Note that 4b758fb is technically a defect in 3.6.00
I am not sure whether we should bother with cherry-picking in 3.6.01, I think we can live without it.

Add round, logb, nextafter, copysign, and signbit
Added denorm_min, reciprocal_overflow_threshold, quiet_NaN, and
signaling_NaN
@dalg24 dalg24 marked this pull request as draft June 2, 2022 04:14
@dalg24
Copy link
Member Author

dalg24 commented Jun 2, 2022

I marked it as work in progress because I did not deal with abs nor the promotion traits for binary functions. I need to think bit more about these.

Also I might want to add specializations for the math constants.

Copy link
Member Author

@dalg24 dalg24 left a comment

Choose a reason for hiding this comment

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

Investigating the discrepancies with inv_pi and sqrt2.
The implementation I proposed has the digits from the <numbers> header in libstdc++
I suggest we don't get hung up with this. I will investigate and fix later as needed.

STATIC_ASSERT(Kokkos::Experimental::log2e_v <__float128> == M_LOG2Eq);
STATIC_ASSERT(Kokkos::Experimental::log10e_v<__float128> == M_LOG10Eq);
STATIC_ASSERT(Kokkos::Experimental::pi_v <__float128> == M_PIq);
// STATIC_ASSERT(Kokkos::Experimental::inv_pi_v<__float128> == M_1_PIq); // FIXME
Copy link
Member Author

Choose a reason for hiding this comment

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

Static_assert failed due to requirement 'Kokkos::Experimental::inv_pi_v<__float128> == 0.318309886183790671537767526745028689Q' ""

Copy link
Member Author

Choose a reason for hiding this comment

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

core/unit_test/TestQuadPrecisionMath.hpp Outdated Show resolved Hide resolved
@dalg24 dalg24 marked this pull request as ready for review June 2, 2022 12:52
@dalg24
Copy link
Member Author

dalg24 commented Jun 2, 2022

This is ready. Failure is unrelated (no space left on device on a build that does not have these changes in the code path)

Copy link
Contributor

@lucbv lucbv left a comment

Choose a reason for hiding this comment

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

This looks fine to me, thanks

@@ -50,6 +50,8 @@

#include <gtest/gtest.h>

namespace {
Copy link
Member

Choose a reason for hiding this comment

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

What's the point of doing this?

Copy link
Contributor

Choose a reason for hiding this comment

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

Anonymous namespace in case some of the functions are redefined in different headers?

Copy link
Member

Choose a reason for hiding this comment

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

In a unit test?

Copy link
Member Author

@dalg24 dalg24 Jun 2, 2022

Choose a reason for hiding this comment

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

You will find this idiom in the googletest samples (example here)
The definitions in that source file do not need access in any other translation unit, it avoids symbols collision (admittedly not likely to happen here). The way I see it, it falls under the general guideline of keeping scopes small.

Copy link
Member

Choose a reason for hiding this comment

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

Sure but you do it in .cc (like the example you show) not in the header.

Copy link
Member Author

Choose a reason for hiding this comment

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

Well this file is a source file in disguise. Our usual pattern of generating

// generated Backend_SomeUnitTest.cpp or such
#include <BackendSpecificHeaderWithMacroDefinitions.hpp>
#include <SomeUnitTest.hpp>

Copy link
Contributor

Choose a reason for hiding this comment

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

It's possible for multiple unit tests to get linked together. If each object file ensures that all of the symbols it contains are private, we're guaranteed not to encounter (incredibly hard to debug, from experience) ODR violation issues. There's minimal cost, and it avoids a bad problem

@dalg24 dalg24 merged commit 45263cd into kokkos:develop Jun 2, 2022
@dalg24 dalg24 deleted the fixup_numerics_quadmath branch June 2, 2022 21:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants