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

The future is now #136

Merged
merged 21 commits into from
Aug 4, 2020
Merged

Conversation

stephentyrone
Copy link
Member

Merge the experimental 5.3 feature branch into master, behind a Swift version check.

This makes Swift Numerics extensions for Float16 available if the following criteria are satisfied:

  • You are using a Swift 5.3 or greater toolchain
  • You are not compiling for macOS (Float16 is not available in the macOS standard library because Intel hasn't defined the calling conventions for Float16 yet, so it cannot be made binary-stable).

This also adds a Swift version check for differentiable features; they are now only available when using Swift 5.3 or later, while previously they only checked if _Differentiation could be imported.

These cases expose a bug in the current implementation; because the split of the exponent into high and low parts may produce numbers with different signs, if both parts overflow or underflow, we can end up with 0 * infinity = NaN, when the result should actually be either zero or infinity.
Just-added tests expose this issue, where the split of n into high/low parts could produce parts with different signs. If both x**high and x**low then overflow and underflow, the resulting computation would be 0*inf (or inf*0) and produce NaN instead of either zero or infinity.
Somewhat better implementation of pow(x,n) for Float16.
build: add initial CMake based build system
This isn't actually quite the right check; what we really want is to use availability on Darwin platforms, but swift version on other platforms (that don't have the standard library in an SDK). But there's no good way to do that, so we simply make it unconditionally unavailable for earlier versions of Swift.
@stephentyrone
Copy link
Member Author

@compnerd Can you sanity-check the windows build with this?

@compnerd
Copy link
Contributor

compnerd commented Aug 5, 2020

@stephentyrone sure, I'll check it tomorrow.

@compnerd
Copy link
Contributor

compnerd commented Aug 5, 2020

This seems to have caused some issues on Windows, specifically in the tests:
https://dev.azure.com/compnerd/3133d6ab-80a8-4996-ac4f-03df25cd3224/_apis/build/builds/35505/logs/13

2020-08-05T01:38:17.1036766Z D:\a\1\s\Tests\RealTests\IntegerExponentTests.swift:89:64: error: type 'Float16' has no member 'pow'
2020-08-05T01:38:17.1038873Z     assertClose(-7.3890572722436554354625993393835304, Float16.pow(-u, 0x801))

@compnerd
Copy link
Contributor

compnerd commented Aug 5, 2020

Fixed the build issue with #137. That uncovers a few failures:
testDouble fails:

Test Case 'IntegerExponentTests.testDouble' started
ULP error was unacceptably large: expected 1.7976931348623157e+308 but saw 1.797693134862245e+308 (354.0-ulp error).
S:\SourceCache\swift-numerics\Tests\RealTests\IntegerExponentTests.swift:152: error: IntegerExponentTests.testDouble : failed -
ULP error was unacceptably large: expected -8.98846567431158e+307 but saw -8.988465674311225e+307 (177.5-ulp error).
S:\SourceCache\swift-numerics\Tests\RealTests\IntegerExponentTests.swift:153: error: IntegerExponentTests.testDouble : failed -
ULP error was unacceptably large: expected 8.98846567431158e+307 but saw 8.988465674311227e+307 (176.5-ulp error).
S:\SourceCache\swift-numerics\Tests\RealTests\IntegerExponentTests.swift:154: error: IntegerExponentTests.testDouble : failed -
Test Case 'IntegerExponentTests.testDouble' failed (0.0 seconds)
Test Suite 'IntegerExponentTests' failed

@stephentyrone
Copy link
Member Author

Ok, I'll relax the tolerances for these tests on Windows for now.

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.

4 participants