Skip to content
This repository has been archived by the owner on Nov 8, 2022. It is now read-only.

Commit

Permalink
Add the API reduce operators and unary map operators as having noSide…
Browse files Browse the repository at this point in the history
…Effects.
  • Loading branch information
DrTodd13 committed Sep 29, 2016
1 parent c242b29 commit 23e16f1
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/parallel-ir.jl
Original file line number Diff line number Diff line change
Expand Up @@ -2262,6 +2262,16 @@ function pir_live_cb(ast :: ANY, cbdata :: ANY)
return DomainIR.dir_live_cb(ast, cbdata)
end

function isSideEffectFreeAPI(node :: GlobalRef)
if node.mod == ParallelAccelerator.API
if in(node.name, ParallelAccelerator.API.reduce_operators) ||
in(node.name, ParallelAccelerator.API.unary_map_operators)
return true
end
end
return false
end

"""
Sometimes statements we exist in the AST of the form a=Expr where a is a Symbol that isn't live past the assignment
and we'd like to eliminate the whole assignment statement but we have to know that the right-hand side has no
Expand Down Expand Up @@ -2324,22 +2334,27 @@ function hasNoSideEffects(node :: Expr)
isBaseFunc(func, :sltint) ||
isBaseFunc(func, :(===)) ||
isBaseFunc(func, :<:) ||
isBaseFunc(func, :apply_type)
isBaseFunc(func, :apply_type) ||
isSideEffectFreeAPI(func)
@dprintln(3,"hasNoSideEffects returning true")
return true
elseif func == :ccall
func = args[1]
if func == QuoteNode(:jl_alloc_array_1d) ||
func == QuoteNode(:jl_alloc_array_2d)
@dprintln(3,"hasNoSideEffects returning true")
return true
end
elseif isa(func, TopNode)
@dprintln(3, "Found TopNode in hasNoSideEffects. type = ", typeof(func.name))
if func.name == :getfield
@dprintln(3,"hasNoSideEffects returning true")
return true
end
end
end

@dprintln(3,"hasNoSideEffects returning false")
return false
end

Expand Down

0 comments on commit 23e16f1

Please sign in to comment.