Skip to content

Instantly share code, notes, and snippets.

@dionisos2
Created April 23, 2019 13:26
Show Gist options
  • Save dionisos2/536b40fbc8ef57ef20b6cce30eb95d1c to your computer and use it in GitHub Desktop.
Save dionisos2/536b40fbc8ef57ef20b6cce30eb95d1c to your computer and use it in GitHub Desktop.
julia> function dg()::Int
N = 200000
nheads::Int = @distributed (+) for i = 1:N
Int(rand(Bool))
end
return nheads
end
dg (generic function with 1 method)
julia> @code_warntype dg()
Body::Int64
1 ─ %1 = %new(Main.:(##42#43))::Core.Compiler.Const(getfield(Main, Symbol("##42#43"))(), false)
│ %2 = invoke Distributed.preduce(Main.:+::Function, %1::Function, $(QuoteNode(1:200000))::UnitRange{Int64})::Any
│ %3 = (Base.convert)(Main.Int, %2)::Any
│ (Core.typeassert)(%3, Main.Int)
│ %5 = π (%3, Int64)
└── return %5
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment