close-call -> missed-optimization
This commit is contained in:
parent
c73bc6c918
commit
b598c4a1eb
|
@ -121,8 +121,8 @@
|
||||||
(lambda (p thnk) (check-not-exn thnk))]
|
(lambda (p thnk) (check-not-exn thnk))]
|
||||||
[(equal? dir "optimizer/tests/")
|
[(equal? dir "optimizer/tests/")
|
||||||
(lambda (p* thnk) (test-opt p))]
|
(lambda (p* thnk) (test-opt p))]
|
||||||
[(equal? dir "optimizer/close-calls/")
|
[(equal? dir "optimizer/missed-optimizations/")
|
||||||
(lambda (p* thnk) (test-close-call p))])))
|
(lambda (p* thnk) (test-missed-optimization p))])))
|
||||||
(test-suite
|
(test-suite
|
||||||
(path->string p)
|
(path->string p)
|
||||||
(f
|
(f
|
||||||
|
@ -141,4 +141,4 @@
|
||||||
|
|
||||||
(provide go go/text just-one
|
(provide go go/text just-one
|
||||||
int-tests unit-tests compile-benchmarks
|
int-tests unit-tests compile-benchmarks
|
||||||
optimization-tests close-call-tests)
|
optimization-tests missed-optimization-tests)
|
||||||
|
|
|
@ -2,8 +2,8 @@
|
||||||
(require racket/runtime-path
|
(require racket/runtime-path
|
||||||
rackunit rackunit/text-ui)
|
rackunit rackunit/text-ui)
|
||||||
|
|
||||||
(provide optimization-tests close-call-tests
|
(provide optimization-tests missed-optimization-tests
|
||||||
test-opt test-close-call)
|
test-opt test-missed-optimization)
|
||||||
|
|
||||||
(define (generate-log name dir flags)
|
(define (generate-log name dir flags)
|
||||||
;; some tests require other tests, so some fiddling is required
|
;; some tests require other tests, so some fiddling is required
|
||||||
|
@ -39,13 +39,13 @@
|
||||||
|
|
||||||
|
|
||||||
(define-runtime-path tests-dir "./tests")
|
(define-runtime-path tests-dir "./tests")
|
||||||
(define-runtime-path close-calls-dir "./close-calls")
|
(define-runtime-path missed-optimizations-dir "./missed-optimizations")
|
||||||
|
|
||||||
;; these two return lists of tests to be run for that category of tests
|
;; these two return lists of tests to be run for that category of tests
|
||||||
(define (test-opt name)
|
(define (test-opt name)
|
||||||
(list (compare-logs name tests-dir '#("--log-optimizations"))))
|
(list (compare-logs name tests-dir '#("--log-optimizations"))))
|
||||||
(define (test-close-call name)
|
(define (test-missed-optimization name)
|
||||||
(list (compare-logs name close-calls-dir '#("--log-close-calls"))))
|
(list (compare-logs name missed-optimizations-dir '#("--log-missed-optimizations"))))
|
||||||
|
|
||||||
;; proc returns the list of tests to be run on each file
|
;; proc returns the list of tests to be run on each file
|
||||||
(define (mk-suite suite-name dir proc)
|
(define (mk-suite suite-name dir proc)
|
||||||
|
@ -61,5 +61,5 @@
|
||||||
|
|
||||||
(define optimization-tests
|
(define optimization-tests
|
||||||
(mk-suite "Optimization Tests" tests-dir test-opt))
|
(mk-suite "Optimization Tests" tests-dir test-opt))
|
||||||
(define close-call-tests
|
(define missed-optimization-tests
|
||||||
(mk-suite "Close Call Tests" close-calls-dir test-close-call))
|
(mk-suite "Missed Optimization Tests" missed-optimizations-dir test-missed-optimization))
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(define unit? (make-parameter #f))
|
(define unit? (make-parameter #f))
|
||||||
(define int? (make-parameter #f))
|
(define int? (make-parameter #f))
|
||||||
(define opt? (make-parameter #f))
|
(define opt? (make-parameter #f))
|
||||||
(define close-calls? (make-parameter #f))
|
(define missed-opt? (make-parameter #f))
|
||||||
(define bench? (make-parameter #f))
|
(define bench? (make-parameter #f))
|
||||||
(define single (make-parameter #f))
|
(define single (make-parameter #f))
|
||||||
(current-namespace (make-base-namespace))
|
(current-namespace (make-base-namespace))
|
||||||
|
@ -17,11 +17,11 @@
|
||||||
["--unit" "run the unit tests" (unit? #t)]
|
["--unit" "run the unit tests" (unit? #t)]
|
||||||
["--int" "run the integration tests" (int? #t)]
|
["--int" "run the integration tests" (int? #t)]
|
||||||
["--opt" "run the optimization tests" (opt? #t)]
|
["--opt" "run the optimization tests" (opt? #t)]
|
||||||
["--close-calls" "run the close call tests" (close-calls? #t)]
|
["--missed-opt" "run the missed optimization tests" (missed-opt? #t)]
|
||||||
["--benchmarks" "compile the typed benchmarks" (bench? #t)]
|
["--benchmarks" "compile the typed benchmarks" (bench? #t)]
|
||||||
["--just" path "run only this test" (single (just-one path))]
|
["--just" path "run only this test" (single (just-one path))]
|
||||||
["--nightly" "for the nightly builds" (begin (nightly? #t) (unit? #t) (opt? #t))]
|
["--nightly" "for the nightly builds" (begin (nightly? #t) (unit? #t) (opt? #t))]
|
||||||
["--all" "run all tests" (begin (unit? #t) (int? #t) (opt? #t) (close-calls? #t) (bench? #t))]
|
["--all" "run all tests" (begin (unit? #t) (int? #t) (opt? #t) (missed-opt? #t) (bench? #t))]
|
||||||
["--gui" "run using the gui"
|
["--gui" "run using the gui"
|
||||||
(if (gui-available?)
|
(if (gui-available?)
|
||||||
(begin (exec go))
|
(begin (exec go))
|
||||||
|
@ -36,7 +36,7 @@
|
||||||
(append (if (unit?) (list unit-tests) '())
|
(append (if (unit?) (list unit-tests) '())
|
||||||
(if (int?) (list int-tests) '())
|
(if (int?) (list int-tests) '())
|
||||||
(if (opt?) (list optimization-tests) '())
|
(if (opt?) (list optimization-tests) '())
|
||||||
(if (close-calls?) (list close-call-tests) '())
|
(if (missed-opt?) (list missed-optimization-tests) '())
|
||||||
(if (bench?) (list (compile-benchmarks)) '())))])])
|
(if (bench?) (list (compile-benchmarks)) '())))])])
|
||||||
(unless (= 0 ((exec) to-run))
|
(unless (= 0 ((exec) to-run))
|
||||||
(eprintf "Typed Racket Tests did not pass.\n"))))
|
(eprintf "Typed Racket Tests did not pass.\n"))))
|
||||||
|
|
|
@ -378,7 +378,7 @@
|
||||||
#:when (when (and (in-complex-layer? #'e)
|
#:when (when (and (in-complex-layer? #'e)
|
||||||
(for/and ([subexpr (in-list (syntax->list #'(e.args ...)))])
|
(for/and ([subexpr (in-list (syntax->list #'(e.args ...)))])
|
||||||
(subtypeof? subexpr -Real)))
|
(subtypeof? subexpr -Real)))
|
||||||
(log-close-call "unexpected complex value"
|
(log-missed-optimization "unexpected complex value"
|
||||||
this-syntax #'e.op))
|
this-syntax #'e.op))
|
||||||
;; We don't actually want to match.
|
;; We don't actually want to match.
|
||||||
#:when #f
|
#:when #f
|
||||||
|
|
|
@ -91,10 +91,10 @@
|
||||||
;; opportunity, report it
|
;; opportunity, report it
|
||||||
;; ignore operations that stay within integers or rationals, since
|
;; ignore operations that stay within integers or rationals, since
|
||||||
;; these have nothing to do with float optimizations
|
;; these have nothing to do with float optimizations
|
||||||
[close-call? (and (not safe-to-opt?)
|
[missed-optimization? (and (not safe-to-opt?)
|
||||||
(in-real-layer? this-syntax))])
|
(in-real-layer? this-syntax))])
|
||||||
(when close-call?
|
(when missed-optimization?
|
||||||
(log-close-call "binary, args all float-arg-expr, return type not Float"
|
(log-missed-optimization "binary, args all float-arg-expr, return type not Float"
|
||||||
this-syntax
|
this-syntax
|
||||||
(for/first ([x (in-list (syntax->list #'(f1 f2 fs ...)))]
|
(for/first ([x (in-list (syntax->list #'(f1 f2 fs ...)))]
|
||||||
#:when (not (subtypeof? x -Flonum)))
|
#:when (not (subtypeof? x -Flonum)))
|
||||||
|
@ -107,7 +107,7 @@
|
||||||
;; but it's more likely to be there by accident. I can't really think of many
|
;; but it's more likely to be there by accident. I can't really think of many
|
||||||
;; use cases for computing exact intermediate results, then converting them to
|
;; use cases for computing exact intermediate results, then converting them to
|
||||||
;; floats at the end.
|
;; floats at the end.
|
||||||
(when (or safe-to-opt? close-call?)
|
(when (or safe-to-opt? missed-optimization?)
|
||||||
(for ([subexpr (in-list (syntax->list #'(f1 f2 fs ...)))]
|
(for ([subexpr (in-list (syntax->list #'(f1 f2 fs ...)))]
|
||||||
#:when (or (in-real-layer? subexpr)
|
#:when (or (in-real-layer? subexpr)
|
||||||
(in-rational-layer? subexpr)))
|
(in-rational-layer? subexpr)))
|
||||||
|
@ -118,7 +118,7 @@
|
||||||
;; (vector-ref vector-of-rationals x)
|
;; (vector-ref vector-of-rationals x)
|
||||||
;; which don't perform arithmetic despite returning numbers.
|
;; which don't perform arithmetic despite returning numbers.
|
||||||
[e:arith-expr
|
[e:arith-expr
|
||||||
(log-close-call
|
(log-missed-optimization
|
||||||
"exact arithmetic subexpression inside a float expression, extra precision discarded"
|
"exact arithmetic subexpression inside a float expression, extra precision discarded"
|
||||||
subexpr this-syntax)]
|
subexpr this-syntax)]
|
||||||
[_ #f])))
|
[_ #f])))
|
||||||
|
|
|
@ -81,7 +81,7 @@
|
||||||
#:with opt #'other))
|
#:with opt #'other))
|
||||||
|
|
||||||
(define (optimize-top stx)
|
(define (optimize-top stx)
|
||||||
(let* ([log-file? (and (or *log-optimizations?* *log-close-calls?*)
|
(let* ([log-file? (and (or *log-optimizations?* *log-missed-optimizations?*)
|
||||||
*log-to-log-file?*)]
|
*log-to-log-file?*)]
|
||||||
[port (if log-file?
|
[port (if log-file?
|
||||||
(open-output-file *log-file* #:exists 'append)
|
(open-output-file *log-file* #:exists 'append)
|
||||||
|
|
|
@ -45,7 +45,7 @@
|
||||||
;; it has to be a list, otherwise, there would have been
|
;; it has to be a list, otherwise, there would have been
|
||||||
;; a type error
|
;; a type error
|
||||||
(begin
|
(begin
|
||||||
(log-close-call "car/cdr on a potentially empty list"
|
(log-missed-optimization "car/cdr on a potentially empty list"
|
||||||
this-syntax #'p)
|
this-syntax #'p)
|
||||||
#f))
|
#f))
|
||||||
#:with opt
|
#:with opt
|
||||||
|
@ -54,7 +54,7 @@
|
||||||
(pattern (#%plain-app op:mpair-op p:expr e:expr ...)
|
(pattern (#%plain-app op:mpair-op p:expr e:expr ...)
|
||||||
#:when (or (has-mpair-type? #'p)
|
#:when (or (has-mpair-type? #'p)
|
||||||
(begin
|
(begin
|
||||||
(log-close-call "mpair op on a potentially empty mlist"
|
(log-missed-optimization "mpair op on a potentially empty mlist"
|
||||||
this-syntax #'p)
|
this-syntax #'p)
|
||||||
#f))
|
#f))
|
||||||
#:with opt
|
#:with opt
|
||||||
|
|
|
@ -8,7 +8,7 @@
|
||||||
(rep type-rep))
|
(rep type-rep))
|
||||||
|
|
||||||
(provide *log-file* *log-to-log-file?* log-optimization *log-optimizations?*
|
(provide *log-file* *log-to-log-file?* log-optimization *log-optimizations?*
|
||||||
log-close-call *log-close-calls?*
|
log-missed-optimization *log-missed-optimizations?*
|
||||||
*show-optimized-code*
|
*show-optimized-code*
|
||||||
subtypeof? isoftype?
|
subtypeof? isoftype?
|
||||||
mk-unsafe-tbl
|
mk-unsafe-tbl
|
||||||
|
@ -45,9 +45,9 @@
|
||||||
;; of reporting them to the user.
|
;; of reporting them to the user.
|
||||||
;; This is meant to help users understand what hurts the performance of
|
;; This is meant to help users understand what hurts the performance of
|
||||||
;; their programs.
|
;; their programs.
|
||||||
(define *log-close-calls?* (in-command-line? "--log-close-calls"))
|
(define *log-missed-optimizations?* (in-command-line? "--log-missed-optimizations"))
|
||||||
(define (log-close-call kind stx [irritant #f])
|
(define (log-missed-optimization kind stx [irritant #f])
|
||||||
(when *log-close-calls?*
|
(when *log-missed-optimizations?*
|
||||||
(do-logging (if irritant
|
(do-logging (if irritant
|
||||||
(format "~a -- caused by: ~a ~a"
|
(format "~a -- caused by: ~a ~a"
|
||||||
kind
|
kind
|
||||||
|
|
Loading…
Reference in New Issue
Block a user