Skip to content

Commit

Permalink
more compact lowering of broadcast and generators by avoiding `getpro…
Browse files Browse the repository at this point in the history
…perty` (#29697)
  • Loading branch information
JeffBezanson authored Oct 19, 2018
1 parent 45e2ddf commit abfbac9
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion base/compiler/compiler.jl
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ include("abstractdict.jl")
include("abstractset.jl")
include("iterators.jl")
using .Iterators: zip, enumerate
using .Iterators: Flatten, product # for generators
using .Iterators: Flatten, Filter, product # for generators
include("namedtuple.jl")

# core docsystem
Expand Down
3 changes: 2 additions & 1 deletion base/sysimg.jl
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ include("abstractdict.jl")

include("iterators.jl")
using .Iterators: zip, enumerate
using .Iterators: Flatten, product # for generators
using .Iterators: Flatten, Filter, product # for generators

include("namedtuple.jl")

Expand Down Expand Up @@ -264,6 +264,7 @@ using .PermutedDimsArrays

include("broadcast.jl")
using .Broadcast
using .Broadcast: broadcasted, broadcasted_kwsyntax, materialize, materialize!

# define the real ntuple functions
@inline function ntuple(f::F, ::Val{N}) where {F,N}
Expand Down
11 changes: 6 additions & 5 deletions src/julia-syntax.scm
Original file line number Diff line number Diff line change
Expand Up @@ -1589,7 +1589,7 @@
(car ranges)
`(call (top product) ,@ranges)))
(iter (if filt?
`(call (|.| (top Iterators) 'Filter)
`(call (top Filter)
,(func-for-generator-ranges (cadr (caddr e)) range-exprs #f '())
,iter)
iter))
Expand Down Expand Up @@ -1630,7 +1630,7 @@
(kws (car kws+args))
(kws (if (null? kws) kws (list (cons 'parameters kws))))
(args (map dot-to-fuse (cdr kws+args)))
(make `(call (|.| (top Broadcast) ,(if (null? kws) ''broadcasted ''broadcasted_kwsyntax)) ,@kws ,f ,@args)))
(make `(call (top ,(if (null? kws) 'broadcasted 'broadcasted_kwsyntax)) ,@kws ,f ,@args)))
(if top (cons 'fuse make) make)))
(if (and (pair? e) (eq? (car e) '|.|))
(let ((f (cadr e)) (x (caddr e)))
Expand All @@ -1655,12 +1655,13 @@
(if (fuse? e)
; expanded to a fuse op call
(if (null? lhs)
(expand-forms `(call (|.| (top Broadcast) 'materialize) ,(cdr e)))
(expand-forms `(call (|.| (top Broadcast) 'materialize!) ,lhs-view ,(cdr e))))
(expand-forms `(call (top materialize) ,(cdr e)))
(expand-forms `(call (top materialize!) ,lhs-view ,(cdr e))))
; expanded to something else (like a getfield)
(if (null? lhs)
(expand-forms e)
(expand-forms `(call (|.| (top Broadcast) 'materialize!) ,lhs-view (call (|.| (top Broadcast) 'broadcasted) (top identity) ,e)))))))
(expand-forms `(call (top materialize!) ,lhs-view
(call (top broadcasted) (top identity) ,e)))))))


(define (expand-where body var)
Expand Down

2 comments on commit abfbac9

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Executing the daily benchmark build, I will reply here when finished:

@nanosoldier runbenchmarks(ALL, isdaily = true)

@nanosoldier
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Your benchmark job has completed - possible performance regressions were detected. A full report can be found here. cc @ararslan

Please sign in to comment.