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

GH-44915: [C++] Add WithinUlp testing functions #44906

Merged
merged 10 commits into from
Dec 9, 2024
Merged

Conversation

pitrou
Copy link
Member

@pitrou pitrou commented Dec 2, 2024

Rationale for this change

When testing math-related functions, we might want to check that some results are very close to an expected value, but not necessarily exactly equal.

What changes are included in this PR?

Add functions that test whether two floating-point values are within N ulps.

("ulp" stands for "unit in the last place": https://en.wikipedia.org/wiki/Unit_in_the_last_place)

Are these changes tested?

Yes.

Are there any user-facing changes?

Potentially more useful error messages.

@pitrou
Copy link
Member Author

pitrou commented Dec 2, 2024

Initially mentioned in #12681 (comment)

@pitrou pitrou changed the title GH-XXX: [C++] Add WithinUlp testing functions GH-44915: [C++] Add WithinUlp testing functions Dec 3, 2024
@pitrou pitrou marked this pull request as ready for review December 3, 2024 10:08
@pitrou
Copy link
Member Author

pitrou commented Dec 3, 2024

@github-actions crossbow submit -g cpp

This comment was marked as outdated.

@pitrou
Copy link
Member Author

pitrou commented Dec 3, 2024

@github-actions crossbow submit -g cpp

This comment was marked as outdated.

@github-actions github-actions bot added awaiting merge Awaiting merge awaiting changes Awaiting changes and removed awaiting review Awaiting review awaiting merge Awaiting merge labels Dec 7, 2024
cpp/src/arrow/testing/math.cc Outdated Show resolved Hide resolved
cpp/src/arrow/testing/math.cc Outdated Show resolved Hide resolved
cpp/src/arrow/testing/math.cc Outdated Show resolved Hide resolved
cpp/src/arrow/testing/gtest_util_test.cc Outdated Show resolved Hide resolved
@github-actions github-actions bot added awaiting change review Awaiting change review and removed awaiting changes Awaiting changes labels Dec 9, 2024
@pitrou
Copy link
Member Author

pitrou commented Dec 9, 2024

@github-actions crossbow submit -g cpp

Copy link

github-actions bot commented Dec 9, 2024

Revision: ad2bf4f

Submitted crossbow builds: ursacomputing/crossbow @ actions-5787e09ddf

Task Status
example-cpp-minimal-build-static GitHub Actions
example-cpp-minimal-build-static-system-dependency GitHub Actions
example-cpp-tutorial GitHub Actions
test-alpine-linux-cpp GitHub Actions
test-build-cpp-fuzz GitHub Actions
test-conda-cpp GitHub Actions
test-conda-cpp-valgrind GitHub Actions
test-cuda-cpp-ubuntu-20.04-cuda-11.2.2 GitHub Actions
test-cuda-cpp-ubuntu-22.04-cuda-11.7.1 GitHub Actions
test-debian-12-cpp-amd64 GitHub Actions
test-debian-12-cpp-i386 GitHub Actions
test-fedora-39-cpp GitHub Actions
test-ubuntu-20.04-cpp GitHub Actions
test-ubuntu-20.04-cpp-bundled GitHub Actions
test-ubuntu-22.04-cpp GitHub Actions
test-ubuntu-22.04-cpp-20 GitHub Actions
test-ubuntu-22.04-cpp-emscripten GitHub Actions
test-ubuntu-22.04-cpp-no-threading GitHub Actions
test-ubuntu-24.04-cpp GitHub Actions
test-ubuntu-24.04-cpp-bundled-offline GitHub Actions
test-ubuntu-24.04-cpp-gcc-13-bundled GitHub Actions
test-ubuntu-24.04-cpp-gcc-14 GitHub Actions
test-ubuntu-24.04-cpp-minimal-with-formats GitHub Actions
test-ubuntu-24.04-cpp-thread-sanitizer GitHub Actions

Copy link
Contributor

@zanmato1984 zanmato1984 left a comment

Choose a reason for hiding this comment

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

LGTM

@pitrou pitrou merged commit 0d8c8d9 into apache:main Dec 9, 2024
37 of 38 checks passed
@pitrou pitrou removed the awaiting change review Awaiting change review label Dec 9, 2024
@pitrou pitrou deleted the within-ulp branch December 9, 2024 11:08
#include "arrow/testing/visibility.h"

namespace arrow {

Copy link
Member

Choose a reason for hiding this comment

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

why argument name in within is n_ulp, but in assertWithin is n_ulps?

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmm... no reason I'm afraid. We can open a minor PR to fix that.

@github-actions github-actions bot added the awaiting committer review Awaiting committer review label Dec 9, 2024
Copy link

After merging your PR, Conbench analyzed the 3 benchmarking runs that have been run so far on merge-commit 0d8c8d9.

There were no benchmark performance regressions. 🎉

The full Conbench report has more details. It also includes information about 52 possible false positives for unstable benchmarks that are known to sometimes produce them.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants