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

Parsing errors from FPCore input. #188

Open
zaneenders opened this issue Nov 12, 2024 · 0 comments
Open

Parsing errors from FPCore input. #188

zaneenders opened this issue Nov 12, 2024 · 0 comments

Comments

@zaneenders
Copy link
Contributor

zaneenders commented Nov 12, 2024

Herbie: 9287265 Odyssey: 8da4444.
The following FPCores encountered a similar parsing issue.
Pretty much the entire bench/graphics/lod.fpcore and /bench/mathematics/gui.fpcore file.

(FPCore (a b c)
 :name "quadp (p42, positive)"
 :herbie-expected 10
 ; From Racket Math Lib implementation
 :alt 
 (! :herbie-platform default
  (let ([sqtD
   (let ([x (* (sqrt (fabs a)) (sqrt (fabs c)))])
    (if (== (copysign a c) a)
      (* (sqrt (- (fabs (/ b 2)) x)) (sqrt (+ (fabs (/ b 2)) x)))
      (hypot (/ b 2) x)))])
    (if (< b 0) (/ (- sqtD (/ b 2)) a)
      (/ (- c) (+ (/ b 2) sqtD)))))

 (let ([d (sqrt (- (* b b) (* 4 (* a c))))])
   (/ (+ (- b) d) (* 2 a))))
   
(FPCore (a b c)
 :name "quadm (p42, negative)"
 :herbie-expected 10
 ; From Racket Math Lib implementation
 :alt 
 (! :herbie-platform default
  (let ([sqtD
   (let ([x (* (sqrt (fabs a)) (sqrt (fabs c)))])
    (if (== (copysign a c) a)
      (* (sqrt (- (fabs (/ b 2)) x)) (sqrt (+ (fabs (/ b 2)) x)))
      (hypot (/ b 2) x)))])
    (if (< b 0) (/ c (- sqtD (/ b 2)))
      (/ (+ (/ b 2) sqtD) (- a)))))

 (let ([d (sqrt (- (* b b) (* 4 (* a c))))])
   (/ (- (- b) d) (* 2 a))))
   

(FPCore (a b_2 c)
 :name "quad2m (problem 3.2.1, negative)"
 :herbie-expected 10
 ; From Racket Math Lib implementation
 :alt 
 (! :herbie-platform default
  (let ([sqtD
   (let ([x (* (sqrt (fabs a)) (sqrt (fabs c)))])
    (if (== (copysign a c) a)
      (* (sqrt (- (fabs b_2) x)) (sqrt (+ (fabs b_2) x)))
      (hypot b_2 x)))])
    (if (< b_2 0) (/ c (- sqtD b_2))
      (/ (+ b_2 sqtD) (- a)))))

 (let ([d (sqrt (- (* b_2 b_2) (* a c)))])
   (/ (- (- b_2) d) a)))


(FPCore (a b_2 c)
 :name "quad2p (problem 3.2.1, positive)"
 :herbie-expected 10
 ; From Racket Math Lib implementation
 :alt 
 (! :herbie-platform default 
  (let ([sqtD
   (let ([x (* (sqrt (fabs a)) (sqrt (fabs c)))])
    (if (== (copysign a c) a)
      (* (sqrt (- (fabs b_2) x)) (sqrt (+ (fabs b_2) x)))
      (hypot b_2 x)))])
    (if (< b_2 0) (/ (- sqtD b_2) a)
      (/ (- c) (+ b_2 sqtD)))))

 (let ([d (sqrt (- (* b_2 b_2) (* a c)))])
   (/ (+ (- b_2) d) a)))
   

(FPCore (w h dX.u dX.v dY.u dY.v maxAniso)
  :name "Anisotropic x16 LOD (LOD)"
  :precision binary32
  :pre (and (<= 1 w 16384)
            (<= 1 h 16384)
            (<= 1e-20 (fabs dX.u) 1e+20)
            (<= 1e-20 (fabs dX.v) 1e+20)
            (<= 1e-20 (fabs dY.u) 1e+20)
            (<= 1e-20 (fabs dY.v) 1e+20)
            (== maxAniso 16))
  
  (let* ([w         (floor w)]
         [h         (floor h)]
         [maxAniso  (floor maxAniso)]

         [dX.u (* w dX.u)]
         [dX.v (* h dX.v)]
         [dY.u (* w dY.u)]
         [dY.v (* h dY.v)]
    
         [dX2  (+ (* dX.u dX.u) (* dX.v dX.v))]
         [dY2  (+ (* dY.u dY.u) (* dY.v dY.v))]
         [det  (fabs (- (* dX.u dY.v) (* dX.v dY.u)))]

         [major2        (fmax dX2 dY2)]
         [major         (sqrt major2)]
         [normMajor     (/ 1 major)]
         [ratioAniso0   (/ major2 det)]

         ; first round of clamping
         [minor         (if (> ratioAniso0 maxAniso)
                            (/ major maxAniso)
                            (/ det major))]
         [ratioAniso1   (if (> ratioAniso0 maxAniso)
                            maxAniso
                            ratioAniso0)]

         ; second round of clamping
         [ratioAniso    (if (< minor 1.0)
                            (fmax 1.0 (* ratioAniso1 minor))
                            ratioAniso1)])

    (log2 minor)))
    
@zaneenders zaneenders changed the title Odyssey Error when parsing expression. Odyssey Errors from Herbie bench marks. SC prep. Nov 12, 2024
@zaneenders zaneenders changed the title Odyssey Errors from Herbie bench marks. SC prep. Parsing errors from Odyssey input. Nov 12, 2024
@zaneenders zaneenders changed the title Parsing errors from Odyssey input. Parsing errors from FPCore input. Nov 12, 2024
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

No branches or pull requests

1 participant