Raymond Toy pushed to branch issue-425-correctly-rounded-math-functions at cmucl / cmucl

Commits:

3 changed files:

Changes:

  • .gitlab-ci.yml
    ... ... @@ -147,7 +147,7 @@ linux:build:
    147 147
         - job: linux:install
    
    148 148
           artifacts: true
    
    149 149
       variables:
    
    150
    -    CONFIG: "x86_linux_clang"
    
    150
    +    CONFIG: "x86_linux"
    
    151 151
       # These rules is needed so that the static analyzer job can run on a
    
    152 152
       # schedule because this is a prerequisite of the analyzer build.  A
    
    153 153
       # regular push or merge request does the normal stuff.
    
    ... ... @@ -171,7 +171,7 @@ linux:cross-build:
    171 171
           - linux-4/lisp
    
    172 172
       variables:
    
    173 173
         # This must match the config used for the linux build!
    
    174
    -    CONFIG: "x86_linux_clang"
    
    174
    +    CONFIG: "x86_linux"
    
    175 175
     
    
    176 176
       needs:
    
    177 177
     
    
    ... ... @@ -346,7 +346,7 @@ ubuntu:build:
    346 346
         - job: ubuntu:install
    
    347 347
           artifacts: true
    
    348 348
       variables:
    
    349
    -    CONFIG: "x86_linux_clang"
    
    349
    +    CONFIG: "x86_linux"
    
    350 350
     
    
    351 351
     ubuntu:test:
    
    352 352
       <<: *unit_test_configuration
    

  • src/lisp/Config.x86_linux
    ... ... @@ -6,7 +6,8 @@ CORE_MATH = -DCORE_MATH_SUPPORT_ERRNO
    6 6
     
    
    7 7
     CFLAGS += $(COPT)
    
    8 8
     CPPFLAGS += -m32
    
    9
    -CFLAGS += -rdynamic  -march=pentium4 -mfpmath=sse -mtune=generic
    
    9
    +#CFLAGS += -rdynamic  -march=pentium4 -mfpmath=sse -mtune=generic
    
    10
    +CFLAGS += -rdynamic  -march=haswell -mfpmath=sse
    
    10 11
     # ANALYZER flag should be set to -fanalyzer when doing the CI builds
    
    11 12
     # for the C static analyzer.
    
    12 13
     CFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64 $(ANALYZER)
    

  • tests/fdlibm.lisp
    ... ... @@ -349,7 +349,9 @@
    349 349
       ;; acosh(2^50), case 2^28 < x
    
    350 350
       (assert-eql 35.35050620855721d0 (acosh (scale-float 1d0 50)))
    
    351 351
       ;; No overflow for most positive
    
    352
    -  (assert-eql 710.4758600739439d0 (acosh most-positive-double-float)))
    
    352
    +  (assert-eql #-core-math 710.4758600739439d0
    
    353
    +	      #+core-math 710.475860073944d0
    
    354
    +	      (acosh most-positive-double-float)))
    
    353 355
     
    
    354 356
     (define-test asinh-basic-tests
    
    355 357
         (:tag :fdlibm)
    
    ... ... @@ -378,8 +380,12 @@
    378 380
         (assert-eql -20.101268236238415d0 (asinh (- x))))
    
    379 381
       (let ((x most-positive-double-float))
    
    380 382
         ;; No overflow for most-positive-double-float
    
    381
    -    (assert-eql 710.4758600739439d0 (asinh x))
    
    382
    -    (assert-eql -710.4758600739439d0 (asinh (- x)))))
    
    383
    +    (assert-eql #-core-math 710.4758600739439d0
    
    384
    +		#+core-math 710.475860073944d0
    
    385
    +		(asinh x))
    
    386
    +    (assert-eql #-core-math -710.4758600739439d0
    
    387
    +		#+core-math -710.475860073944d0
    
    388
    +		(asinh (- x)))))
    
    383 389
       
    
    384 390
     (define-test atanh-basic-tests
    
    385 391
         (:tag :fdlibm)
    
    ... ... @@ -517,34 +523,52 @@
    517 523
       ;; |log(x) + log(1/x)| < 1.77635684e-15, x = 1.2^k, 0 <= k < 2000
    
    518 524
       ;; The threshold is experimentally determined
    
    519 525
       (let ((x 1d0)
    
    520
    -	(max-value -1d0))
    
    526
    +	(max-value -1d0)
    
    527
    +	(worst-x 0d0))
    
    521 528
         (declare (double-float max-value)
    
    522 529
     	     (type (double-float 1d0) x))
    
    523 530
         (dotimes (k 2000)
    
    524 531
           (let ((y (abs (+ (log x) (log (/ x))))))
    
    525
    -	(setf max-value (max max-value y))
    
    532
    +	(when (> y max-value)
    
    533
    +	  (setf worst-x x
    
    534
    +		max-value y))
    
    526 535
     	(setf x (* x 1.4d0))))
    
    527
    -    (assert-true (< max-value 1.77635684d-15)))
    
    536
    +    (assert-true (< max-value
    
    537
    +		    #-core-math 1.77635684d-15
    
    538
    +		    #+core-math 1.42108548d-14)
    
    539
    +		 max-value
    
    540
    +		 worst-x))
    
    528 541
       ;; |exp(log(x)) - x|/x < 5.6766649d-14, x = 1.4^k, 0 <= k < 2000
    
    529 542
       (let ((x 1d0)
    
    530
    -	(max-error 0d0))
    
    531
    -    (declare (double-float max-error)
    
    543
    +	(max-error 0d0)
    
    544
    +	(worst-x 0d0))
    
    545
    +    (declare (double-float max-error worst-x worst-y)
    
    532 546
     	     (type (double-float 1d0) x))
    
    533 547
         (dotimes (k 2000)
    
    534 548
           (let ((y (abs (/ (- (exp (log x)) x) x))))
    
    535
    -	(setf max-error (max max-error y))
    
    549
    +	(when (> y max-error)
    
    550
    +	  (setf worst-x x
    
    551
    +		max-error y))
    
    536 552
     	(setf x (* x 1.4d0))))
    
    537
    -    (assert-true (< max-error 5.6766649d-14)))
    
    553
    +    (assert-true (< max-error 5.6766649d-14)
    
    554
    +		 max-error
    
    555
    +		 worst-x
    
    556
    +		 worst-y))
    
    538 557
       ;; |exp(log(x)) - x|/x < 5.68410245d-14, x = 1.4^(-k), 0 <= k < 2000
    
    539 558
       (let ((x 1d0)
    
    540
    -	(max-error 0d0))
    
    541
    -    (declare (double-float max-error)
    
    559
    +	(max-error 0d0)
    
    560
    +	(worst-x 0d0))
    
    561
    +    (declare (double-float max-error worst-x worst-y)
    
    542 562
     	     (type (double-float (0d0)) x))
    
    543 563
         (dotimes (k 2000)
    
    544 564
           (let ((y (abs (/ (- (exp (log x)) x) x))))
    
    545
    -	(setf max-error (max max-error y))
    
    565
    +	(when (> y max-error)
    
    566
    +	  (setf worst-x x
    
    567
    +		max-error y))
    
    546 568
     	(setf x (/ x 1.4d0))))
    
    547
    -    (assert-true (< max-error 5.68410245d-14))))
    
    569
    +    (assert-true (< max-error 5.68410245d-14)
    
    570
    +		 max-error
    
    571
    +		 worst-x)))
    
    548 572
     
    
    549 573
     (define-test sinh-basic-tests
    
    550 574
         (:tag :fdlibm)