[OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

[OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Ben Coman-4
 

The FloatMathPlugin provided cross-platform bit-identical floating point, needed for applications such as OpenCroquet/Qwaq/terf. The plugin depends on Sun's fdlibm which is effectively obsolete. There are better solutions; see for an overview
http://christian-seiler.de/projekte/fpmath/
and for a solution (provided this is lesser GPL, which a cursory reading suggests it is)
https://www.mpfr.org

If taking this approach, instead of needing a FloatMathPlugin we could perhaps arrange that the VM provides cross-platform bit-identical floating point by default, or that the VM is compilable with some flags that result in a VM whose floating point primitives are cross-platform bit-identical. Then one wouldn't have to use an interface to the plugin, with all the headaches that providing support for SmallFloat64 now in introduces, along with the slowness of that plugin interface.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OpenSmalltalk/opensmalltalk-vm","title":"OpenSmalltalk/opensmalltalk-vm","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm"}},"updates":{"snippets":[{"icon":"DESCRIPTION","message":"We need a solution for cross-platform bit-identical floating point. (#315)"}],"action":{"name":"View Issue","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315"}}}</script> <script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "We need a solution for cross-platform bit-identical floating point. (#315)", "sections": [ { "text": "", "activityTitle": "**Eliot Miranda**", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@eliotmiranda", "facts": [ { "name": "Repository: ", "value": "OpenSmalltalk/opensmalltalk-vm" }, { "name": "Issue #: ", "value": 315 } ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 419314528\n}" } ], "themeColor": "26292E" } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Ben Coman-4
 

mpfr is multiple precision (arbitrary precision if you prefer), and not specially optimized for IEEE 754 double precision. IMO it's too much for FloatMathPlugin.

CRLIBM (correctly rounded mathematical library) could be a good modern alternative to fdlibm.
CRLIBM is also LGPL and also from INRIA
For documentation, see:
https://hal-ens-lyon.archives-ouvertes.fr/ensl-01529804/file/crlibm.pdf


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OpenSmalltalk/opensmalltalk-vm","title":"OpenSmalltalk/opensmalltalk-vm","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@nicolas-cellier-aka-nice in #315: mpfr is multiple precision (arbitrary precision if you prefer), and not specially optimized for IEEE 754 double precision. IMO it's too much for FloatMathPlugin.\r\n\r\nCRLIBM (correctly rounded mathematical library) could be a good modern alternative to fdlibm.\r\nCRLIBM is also LGPL and also from INRIA\r\nFor documentation, see:\r\nhttps://hal-ens-lyon.archives-ouvertes.fr/ensl-01529804/file/crlibm.pdf"}],"action":{"name":"View Issue","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-444267089"}}}</script> <script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-444267089", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-444267089", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)", "sections": [ { "text": "", "activityTitle": "**Nicolas Cellier**", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@nicolas-cellier-aka-nice", "facts": [ ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-444267089" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 419314528\n}" } ], "themeColor": "26292E" } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Steffen Märcker
 
Hi,

crlibm looks indeed quite promising. If crlibm would be integrated, is it  
be possible to make setting rounding modes directly accessible without an  
FFI-call from the image? Also, I noticed that changing the rounding mode  
did not work reliable - possibly due to some plug/part of the vm that  
changes the mode on it's own behalf (freetype, maybe?).

Best, Steffen

Am .12.2018, 22:34 Uhr, schrieb Nicolas Cellier <[hidden email]>:




Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Nicolas Cellier
 
Hi Steffen,
one feature of crlibm is that it does not use current FPU rounding mode status, but has explicit functions for each rounding mode.
That might be more convenient than switching FPU rounding mode for interval arithmetic for example.

As for the rounding mode, I think that the VM itself does interfere
For example in:
there is the following definition:
#define FPU_DEFAULT (_RC_NEAR + _PC_53 + _EM_INVALID + _EM_ZERODIVIDE + _EM_OVERFLOW + _EM_UNDERFLOW + _EM_INEXACT + _EM_DENORMAL)
and a
_controlfp(FPU_DEFAULT, _MCW_EM | _MCW_RC | _MCW_PC | _MCW_IC);
in squeakExceptionHandler

This is for windows VM but I'm sure we can find similar things in linux/mac


Le mer. 5 déc. 2018 à 09:25, Steffen Märcker <[hidden email]> a écrit :
 
Hi,

crlibm looks indeed quite promising. If crlibm would be integrated, is it 
be possible to make setting rounding modes directly accessible without an 
FFI-call from the image? Also, I noticed that changing the rounding mode 
did not work reliable - possibly due to some plug/part of the vm that 
changes the mode on it's own behalf (freetype, maybe?).

Best, Steffen

Am .12.2018, 22:34 Uhr, schrieb Nicolas Cellier <[hidden email]>:




Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Ben Coman-4
In reply to this post by Ben Coman-4
 

In the interim, we can modernize fdlibm, it's easier than creating a new plugin from scratch, and it will preserve bit-identical backward compatibility with OpenCobalt/Terf/... while changing the underlying libm would require a simultaneous change of all the VM participating.

After searching for similar work in github, I saw that I would be better served by myself and gave it a go: https://github.com/nicolas-cellier-aka-nice/fdlibm/

I've run some smoke tests, but did not commit the test yet...
The reason is that I tried to add dependency to googletest via git subtree, and it was a bad idea: https://stackoverflow.com/questions/12858199/how-to-rebase-after-git-subtree-add.

I crafted the tests with ArbitraryPrecisionFloat package (from squeaksource), but generating the reference results is quite slow. If someone knows of existing test suite for libm, that might help.

If someone wants to try it, just overwrite the fdlibm files with my master branch. No special flags required (except D_IEEE_LIBM). My smoke tests pass with -O2, so should the OpenSmalltalk VM.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OpenSmalltalk/opensmalltalk-vm","title":"OpenSmalltalk/opensmalltalk-vm","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@nicolas-cellier-aka-nice in #315: In the interim, we can modernize fdlibm, it's easier than creating a new plugin from scratch, and it will preserve bit-identical backward compatibility with OpenCobalt/Terf/... while changing the underlying libm would require a simultaneous change of all the VM participating.\r\n\r\nAfter searching for similar work in github, I saw that I would be better served by myself and gave it a go: https://github.com/nicolas-cellier-aka-nice/fdlibm/\r\n\r\nI've run some smoke tests, but did not commit the test yet...\r\nThe reason is that I tried to add dependency to googletest via git subtree, and it was a bad idea: https://stackoverflow.com/questions/12858199/how-to-rebase-after-git-subtree-add.\r\n\r\nI crafted the tests with ArbitraryPrecisionFloat package (from squeaksource), but generating the reference results is quite slow. If someone knows of existing test suite for libm, that might help.\r\n\r\nIf someone wants to try it, just overwrite the fdlibm files with my master branch. No special flags required (except `D_IEEE_LIBM`). My smoke tests pass with `-O2`, so should the OpenSmalltalk VM.\r\n"}],"action":{"name":"View Issue","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-445472358"}}}</script> <script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-445472358", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-445472358", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)", "sections": [ { "text": "", "activityTitle": "**Nicolas Cellier**", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@nicolas-cellier-aka-nice", "facts": [ ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-445472358" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 419314528\n}" } ], "themeColor": "26292E" } ]</script>
Reply | Threaded
Open this post in threaded view
|

Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)

Ben Coman-4
In reply to this post by Ben Coman-4
 

I've checked that FloatMathPluginTests does not segfault anymore with head Win64 squeak.cog.spur if I replace platforms/Cross/plugins/FloatMathPlugin/fdlibm with my master branch.
All the tests are red because they depend on Random implementation, and implementation changed from a naive Park Milller to a Mersenne Twister... I will try to fix the VMMaker tests.


You are receiving this because you are subscribed to this thread.
Reply to this email directly, view it on GitHub, or mute the thread.

<script type="application/json" data-scope="inboxmarkup">{"api_version":"1.0","publisher":{"api_key":"05dde50f1d1a384dd78767c55493e4bb","name":"GitHub"},"entity":{"external_key":"github/OpenSmalltalk/opensmalltalk-vm","title":"OpenSmalltalk/opensmalltalk-vm","subtitle":"GitHub repository","main_image_url":"https://assets-cdn.github.com/images/email/message_cards/header.png","avatar_image_url":"https://assets-cdn.github.com/images/email/message_cards/avatar.png","action":{"name":"Open in GitHub","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm"}},"updates":{"snippets":[{"icon":"PERSON","message":"@nicolas-cellier-aka-nice in #315: I've checked that FloatMathPluginTests does not segfault anymore with head Win64 squeak.cog.spur if I replace `platforms/Cross/plugins/FloatMathPlugin/fdlibm` with my master branch.\r\nAll the tests are red because they depend on Random implementation, and implementation changed from a naive Park Milller to a Mersenne Twister... I will try to fix the VMMaker tests."}],"action":{"name":"View Issue","url":"https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-446365148"}}}</script> <script type="application/ld+json">[ { "@context": "http://schema.org", "@type": "EmailMessage", "potentialAction": { "@type": "ViewAction", "target": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-446365148", "url": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-446365148", "name": "View Issue" }, "description": "View this Issue on GitHub", "publisher": { "@type": "Organization", "name": "GitHub", "url": "https://github.com" } }, { "@type": "MessageCard", "@context": "http://schema.org/extensions", "hideOriginalBody": "false", "originator": "AF6C5A86-E920-430C-9C59-A73278B5EFEB", "title": "Re: [OpenSmalltalk/opensmalltalk-vm] We need a solution for cross-platform bit-identical floating point. (#315)", "sections": [ { "text": "", "activityTitle": "**Nicolas Cellier**", "activityImage": "https://assets-cdn.github.com/images/email/message_cards/avatar.png", "activitySubtitle": "@nicolas-cellier-aka-nice", "facts": [ ] } ], "potentialAction": [ { "name": "Add a comment", "@type": "ActionCard", "inputs": [ { "isMultiLine": true, "@type": "TextInput", "id": "IssueComment", "isRequired": false } ], "actions": [ { "name": "Comment", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueComment\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315,\n\"IssueComment\": \"{{IssueComment.value}}\"\n}" } ] }, { "name": "Close issue", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"IssueClose\",\n\"repositoryFullName\": \"OpenSmalltalk/opensmalltalk-vm\",\n\"issueId\": 315\n}" }, { "targets": [ { "os": "default", "uri": "https://github.com/OpenSmalltalk/opensmalltalk-vm/issues/315#issuecomment-446365148" } ], "@type": "OpenUri", "name": "View on GitHub" }, { "name": "Unsubscribe", "@type": "HttpPOST", "target": "https://api.github.com", "body": "{\n\"commandName\": \"MuteNotification\",\n\"threadId\": 419314528\n}" } ], "themeColor": "26292E" } ]</script>