digitalmars.D - GDC/ARM: Help needed: Porting std.math.internal.gammafunction
- Johannes Pfau (10/10) Jul 03 2014 Hi,
- dennis luehring (6/10) Jul 03 2014 OT question:
- Iain Buclaw via Digitalmars-d (6/17) Jul 03 2014 That should be possible to check - modern ARM chips are endian
- Johannes Pfau (35/41) Jul 03 2014 I sometimes test on an armv5te as unaligned accesses corrupt data on
- John Colvin (4/19) Jul 03 2014 Warning to anyone attempting this:
- Johannes Pfau (9/11) Jul 03 2014 Actually mixing code compiled with -mlong-double-64 and code compiled
- John Colvin (3/17) Jul 03 2014 That explains the fun situation I just hit: exp(14) == 14
- Iain Buclaw via Digitalmars-d (4/15) Jul 03 2014 FYI, for those who don't have a ARM board at hand, there's always QEMU+c...
- Iain Buclaw via Digitalmars-d (3/21) Jul 03 2014 Or if you're an Ubuntu user (release names are a bit outdated)
- John Colvin (4/19) Jul 03 2014 some trial and error suggests that gammaStirling needs it's
- John Colvin (4/27) Jul 03 2014 MAXGAMMA will also need changing. I don't think there's anything
- Johannes Pfau (6/35) Jul 03 2014 Thanks for having a look at this. AFAIK this code is based on cephes,
Hi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM. I haven't got the required (maths) knowledge to fix this, so it'd be very appreciated if somebody could take a look. It's actually possible to easily test this on x86 with gdc: Just install a recent gdc build and use the -mlong-double-64 command line argument. More details and bug report here: https://issues.dlang.org/show_bug.cgi?id=13032
Jul 03 2014
Am 03.07.2014 17:33, schrieb Johannes Pfau:Hi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM.OT question: can you also check big endian behavior with your ARM system (and maybe maybe unaligned accesses) if possible - i think ARM can be configure for beeing big endian (and unaligned-unware) - or?
Jul 03 2014
On 3 July 2014 17:09, dennis luehring via Digitalmars-d <digitalmars-d puremagic.com> wrote:Am 03.07.2014 17:33, schrieb Johannes Pfau:That should be possible to check - modern ARM chips are endian invariant at last check. Regards IainHi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM.OT question: can you also check big endian behavior with your ARM system (and maybe maybe unaligned accesses) if possible - i think ARM can be configure for beeing big endian (and unaligned-unware) - or?
Jul 03 2014
Am Thu, 03 Jul 2014 18:09:41 +0200 schrieb dennis luehring <dl.soluz gmx.net>:OT question: =20 can you also check big endian behavior with your ARM system (and maybe maybe unaligned accesses) if possible -I sometimes test on an armv5te as unaligned accesses corrupt data on these systems. I found one or two alignment bugs in druntime, but those have been fixed. I'll probably run the next test run with http://www.mjmwired.net/kernel/Documentation/arm/mem_alignment enabled.=20i think ARM can be configure for beeing big endian (and=20 unaligned-unware) - or?ARM cores can in theory run in big endian mode but it's hard to find detailed information. From http://www.arium.com/pdf/Endianness.pdf ----------------- The ARM Architectural Reference Manual states that ARM processors are bi-endian, meaning they can operate in either little-endian or big-endian modes. The ARM processor does not have any instructions or features that affect endianness. The endianness of the system as a whole is determined by the circuitry that connects the processor to its peripheral devices. In those ARM cores that contain a System Control coprocessor (coprocessor 15), Control Register 1 contains a bit that can be used to reverse the endian configuration of the system. The overall design of the system may require that this bit be set for proper operation. Check the user=E2=80=99s manual for the board to determine the proper setting for this bit. Since this bit is cleared at reset, the software engineer still must ensure that any code that executes either directly from flash or immediately after reset is formatted for the correct endian configuration, and the reset handler code must set this bit if required. For those ARM cores that do not include coprocessor 15, the software engineer has no control over the endian configuration of the system. ----------------- So whether a SOC can actually run in big endian mode depends not only on the ARM core but also on the specific SOC. And it's often hard to find documentation for SOCs. I also don't know of any ARM big endian linux distribution.
Jul 03 2014
On Thursday, 3 July 2014 at 15:35:35 UTC, Johannes Pfau wrote:Hi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM. I haven't got the required (maths) knowledge to fix this, so it'd be very appreciated if somebody could take a look. It's actually possible to easily test this on x86 with gdc: Just install a recent gdc build and use the -mlong-double-64 command line argument. More details and bug report here: https://issues.dlang.org/show_bug.cgi?id=13032Warning to anyone attempting this: testing the latest gdc release, writeln and friends are broken for 64bit reals. Use core.stdc.stdio.printf with %lf instead.
Jul 03 2014
Am Thu, 03 Jul 2014 16:47:41 +0000 schrieb "John Colvin" <john.loughran.colvin gmail.com>:testing the latest gdc release, writeln and friends are broken for 64bit reals. Use core.stdc.stdio.printf with %lf instead.Actually mixing code compiled with -mlong-double-64 and code compiled without it can't really work - so I was wrong and it's not easily possible to compile only gammafunction with -mlong-double-64 (gammefunction calls into other maths modules). So it seems to really test this, either an ARM cross compiler + ARM system could be used or druntime+phobos must be built with -mlong-double-64 as well.
Jul 03 2014
On Thursday, 3 July 2014 at 17:03:51 UTC, Johannes Pfau wrote:Am Thu, 03 Jul 2014 16:47:41 +0000 schrieb "John Colvin" <john.loughran.colvin gmail.com>:That explains the fun situation I just hit: exp(14) == 14 whut??testing the latest gdc release, writeln and friends are broken for 64bit reals. Use core.stdc.stdio.printf with %lf instead.Actually mixing code compiled with -mlong-double-64 and code compiled without it can't really work - so I was wrong and it's not easily possible to compile only gammafunction with -mlong-double-64 (gammefunction calls into other maths modules). So it seems to really test this, either an ARM cross compiler + ARM system could be used or druntime+phobos must be built with -mlong-double-64 as well.
Jul 03 2014
On 3 July 2014 18:02, Johannes Pfau via Digitalmars-d <digitalmars-d puremagic.com> wrote:Am Thu, 03 Jul 2014 16:47:41 +0000 schrieb "John Colvin" <john.loughran.colvin gmail.com>:FYI, for those who don't have a ARM board at hand, there's always QEMU+chroot. http://superpiadventures.com/2012/07/development-environment/testing the latest gdc release, writeln and friends are broken for 64bit reals. Use core.stdc.stdio.printf with %lf instead.Actually mixing code compiled with -mlong-double-64 and code compiled without it can't really work - so I was wrong and it's not easily possible to compile only gammafunction with -mlong-double-64 (gammefunction calls into other maths modules). So it seems to really test this, either an ARM cross compiler + ARM system could be used or druntime+phobos must be built with -mlong-double-64 as well.
Jul 03 2014
On 3 July 2014 18:27, Iain Buclaw <ibuclaw gdcproject.org> wrote:On 3 July 2014 18:02, Johannes Pfau via Digitalmars-d <digitalmars-d puremagic.com> wrote:Or if you're an Ubuntu user (release names are a bit outdated) https://wiki.ubuntu.com/ARM/RootfsFromScratch/QemuDebootstrapAm Thu, 03 Jul 2014 16:47:41 +0000 schrieb "John Colvin" <john.loughran.colvin gmail.com>:FYI, for those who don't have a ARM board at hand, there's always QEMU+chroot. http://superpiadventures.com/2012/07/development-environment/testing the latest gdc release, writeln and friends are broken for 64bit reals. Use core.stdc.stdio.printf with %lf instead.Actually mixing code compiled with -mlong-double-64 and code compiled without it can't really work - so I was wrong and it's not easily possible to compile only gammafunction with -mlong-double-64 (gammefunction calls into other maths modules). So it seems to really test this, either an ARM cross compiler + ARM system could be used or druntime+phobos must be built with -mlong-double-64 as well.
Jul 03 2014
On Thursday, 3 July 2014 at 15:35:35 UTC, Johannes Pfau wrote:Hi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM. I haven't got the required (maths) knowledge to fix this, so it'd be very appreciated if somebody could take a look. It's actually possible to easily test this on x86 with gdc: Just install a recent gdc build and use the -mlong-double-64 command line argument. More details and bug report here: https://issues.dlang.org/show_bug.cgi?id=13032some trial and error suggests that gammaStirling needs it's threshold changing from 1024.0L to 143.0L when using 64bit reals to avoid overflow.
Jul 03 2014
On Thursday, 3 July 2014 at 17:54:17 UTC, John Colvin wrote:On Thursday, 3 July 2014 at 15:35:35 UTC, Johannes Pfau wrote:MAXGAMMA will also need changing. I don't think there's anything else wrong with gamma and gammaStirling, I haven't looked at the others yet.Hi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM. I haven't got the required (maths) knowledge to fix this, so it'd be very appreciated if somebody could take a look. It's actually possible to easily test this on x86 with gdc: Just install a recent gdc build and use the -mlong-double-64 command line argument. More details and bug report here: https://issues.dlang.org/show_bug.cgi?id=13032some trial and error suggests that gammaStirling needs it's threshold changing from 1024.0L to 143.0L when using 64bit reals to avoid overflow.
Jul 03 2014
Am Thu, 03 Jul 2014 18:13:45 +0000 schrieb "John Colvin" <john.loughran.colvin gmail.com>:On Thursday, 3 July 2014 at 17:54:17 UTC, John Colvin wrote:Thanks for having a look at this. AFAIK this code is based on cephes, http://www.netlib.org/cephes/cprob.tgz (link to double version) so the correct values can probably be found in that source code.On Thursday, 3 July 2014 at 15:35:35 UTC, Johannes Pfau wrote:MAXGAMMA will also need changing. I don't think there's anything else wrong with gamma and gammaStirling, I haven't looked at the others yet.Hi, std.math.internal.gammafunction is the last module with failing unittest on ARM, simply because it assumes that reals are always in x86 extended precision format which is obviously not true on ARM. I haven't got the required (maths) knowledge to fix this, so it'd be very appreciated if somebody could take a look. It's actually possible to easily test this on x86 with gdc: Just install a recent gdc build and use the -mlong-double-64 command line argument. More details and bug report here: https://issues.dlang.org/show_bug.cgi?id=13032some trial and error suggests that gammaStirling needs it's threshold changing from 1024.0L to 143.0L when using 64bit reals to avoid overflow.
Jul 03 2014