I am working on reconstructing regulatory gene networks from expression data in the malaria vector, Anopheles gambiae, using gaussian graphical models, and am simulating some data to validate the algorithm. Cheers. ]]>

gives me the same performance as your harmonic function. Love the performance of generators in Julia.

]]>function harmonic(::Type{T}, steps) where T

h = zero(T)

o = one(T)

for s in 1:steps

h += o/T(s)

end

return h

end

julia> using BenchmarkTools, BFloat16s

julia> @benchmark harmonic(BFloat16, 1000)

minimum time: 5.525 μs (0.00% GC)

julia> @benchmark harmonic(Float64, 1000)

minimum time: 1.115 μs (0.00% GC)

julia> @benchmark harmonic(Float16, 1000)

minimum time: 35.979 μs (0.00% GC)

julia> @benchmark harmonic(Float32, 1000)

minimum time: 1.135 μs (0.00% GC)

We have a BFloat16 package in Julia, which can be installed from the Julia package prompt with:

(v1.0) pkg> add git@github.com:JuliaComputing/BFloat16s.jl.git

Then, the harmonic sum is:

function harmonic(T, steps)

h = zero(T)

o = one(T)

for s in 1:steps

h += o/T(s)

end

return h

end

And then replicating the table:

julia> using BFloat16s

julia> harmonic(BFloat16, 65)

BFloat16(5.0625)

julia> harmonic(Float16, 513)

Float16(7.086)

julia> harmonic(Float32, 2097152)

15.403683f0

Nice post – the “squeezing” paper looks very interesting. Your first link to that paper on the blog post is currently linking to a different eprint, though (the correct link is in your reply to Andrea Picciau).

Best regards,

George

in [23]: import numpy as np

In [24]: s=np.float16(0)

In [25]: for k in range(1,1000): s=s+np.float16(1)/np.float16(k)

In [26]: s

Out[26]: 7.086