unofficial mirror of guile-devel@gnu.org 
 help / color / mirror / Atom feed
From: Matt Wette <matt.wette@gmail.com>
To: guile-devel <guile-devel@gnu.org>
Cc: Andy Wingo <wingo@pobox.com>
Subject: Re: GNU Guile 2.1.6 released (beta) [numbers.c]
Date: Fri, 20 Jan 2017 11:01:45 -0800	[thread overview]
Message-ID: <6DD4E83E-6A96-4CBE-8FCE-8D74DFBD3E85@gmail.com> (raw)
In-Reply-To: <49954F94-8294-4339-9276-10793DEBAC6D@gmail.com>

[-- Attachment #1: Type: text/plain, Size: 2296 bytes --]


> On Jan 19, 2017, at 7:01 PM, Matt Wette <matt.wette@gmail.com> wrote:
> 
> 
>> On Jan 18, 2017, at 6:26 PM, Andy Wingo <wingo@pobox.com <mailto:wingo@pobox.com>> wrote:
>> 
>> We are pleased to announce GNU Guile release 2.1.6.
>> 
>> Guile 2.1.6 is the sixth pre-release in what will eventually become the
>> 2.2 release series.  We encourage you to test this release and provide
>> feedback to guile-devel@gnu.org <mailto:guile-devel@gnu.org>.
> 
> Saw this one last round.  Mac OS, now gcc-6.3.0:
> 
> ;;; ("#i1@-0" 1.0 -0.0)
> FAIL: numbers.test: string->number: valid complex number strings
> 
> I am going to see if I can generate the assembly.

Short story: scm_c_make_polar is broken for the Mac.  Guile needs to decide if it want to use __sincos() on Mac, or suppress optimization, or ...

I was able to get the above to work (guile-2.1.5) by using
 SCM
+#ifdef __APPLE__
+__attribute__((optimize("O0")))
+#endif
 scm_c_make_polar (double mag, double ang)


In scm_c_make_polar, “gcc -O2”  turns sin(), cos() into cexp(), since cexp(i*x) = cos(x) + i*sin(x):

gcc -O0 =>
LM4339:
	movq	-32(%rbp), %rax
	movd	%rax, %xmm0
	call	_sin
	movd	%xmm0, %rax
	movq	%rax, -8(%rbp)
LM4340:
	movq	-32(%rbp), %rax
	movd	%rax, %xmm0
	call	_cos
	movd	%xmm0, %rax
	movq	%rax, -16(%rbp)

gcc -O2 =>
	pxor	%xmm0, %xmm0
LVL2703:
	call	_cexp

I wrote a little C program to show that cexp() does not preserve the zero-signed-ness:

 cos,sin: +1.000000 -0.000000
__sincos: +1.000000 -0.000000
    cexp: +1.000000 +0.000000

The scm_c_make_polar will use sincos() if available, but macOS does not have sincos(), it has __sincos().

#include <stdio.h>
#include <stdint.h>
#include <math.h>
#include <complex.h>

extern double z, p, n;

int main() {
  double complex c;
  double d, sine, cosine;

  d = z*n;
  printf(" cos,sin: %+f %+f\n", cos(d), sin(d));
  __sincos(d, &sine, &cosine);
  printf("__sincos: %+f %+f\n", cosine, sine);
  c = cexp(CMPLX(0.0, d));
  printf("    cexp: %+f %+f\n", creal(c), cimag(c));
}

double z = 0.0, p = +1.0, n = -1.0;

Incidentally, the above program will not compile on my machine w/ gcc-6.3.0.  “gcc -std=c11” or “gcc -std=c99” will not recognize the standard macro CMPLX().




[-- Attachment #2: Type: text/html, Size: 13644 bytes --]

  reply	other threads:[~2017-01-20 19:01 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-01-19  2:26 GNU Guile 2.1.6 released (beta) Andy Wingo
2017-01-20  3:01 ` Matt Wette
2017-01-20 19:01   ` Matt Wette [this message]
2017-01-20 19:15     ` GNU Guile 2.1.6 released (beta) [numbers.c] Amirouche
2017-01-20 20:23     ` Matt Wette
2017-01-28 19:29       ` Matt Wette
2017-01-20 14:10 ` GNU Guile 2.1.6 released (beta) Matt Wette
2017-01-25  3:35 ` Matt Wette
2017-03-09 21:33   ` Andy Wingo
2017-03-10  2:01     ` Matt Wette
2017-03-10  2:52       ` Matt Wette
2017-03-10  8:13       ` Andy Wingo
2017-03-10 13:10         ` Matt Wette
2017-02-11 20:52 ` Matt Wette

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.gnu.org/software/guile/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=6DD4E83E-6A96-4CBE-8FCE-8D74DFBD3E85@gmail.com \
    --to=matt.wette@gmail.com \
    --cc=guile-devel@gnu.org \
    --cc=wingo@pobox.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).