Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Idea: a "FakeFloat" type to help counting ops in non-Julia code? #26

Open
ffevotte opened this issue Mar 15, 2021 · 1 comment
Open

Comments

@ffevotte
Copy link
Member

Just wondering whether it would be worth implementing the idea prototyped in:
https://discourse.julialang.org/t/vector-matrix-vector-multiplication/57087/15?u=ffevotte

In any case, this issue is here to avoid forgetting about this topic...

@milankl
Copy link
Contributor

milankl commented Apr 14, 2021

Maybe just comparing this idea to Sherlogs.jl which also creates some "FakeFloat"s (called Sherlog16,Sherlog32, Sherlogs64) to log the arithmetic results. So for Sherlogs the information whether it was an add/sub/mul etc is thrown away, but the result is logged (which includes a conversion to Float16, as 64/32-bit bitpattern histograms are just too large). I get fairly similar results

julia> using GFlops, Sherlogs, ShallowWaters

julia> run_model(Float32,Ndays=5);
Starting ShallowWaters on Wed, 14 Apr 2021 11:27:21 without output.
60% Integration done in 0.05s.

julia> run_model(Sherlog32,Ndays=5);
Starting ShallowWaters on Wed, 14 Apr 2021 11:28:33 without output.
60% Integration done in 20.0s.

julia> lb = get_logbook();

julia> sum(lb)
219769755

So there are 219769755 flop done in Float32. Compared to

julia> @count_ops run_model(Float32,Ndays=5)
Starting ShallowWaters on Wed, 14 Apr 2021 11:32:38 without output.
60% Integration done in 18.1s.
Flop Counter: 221073693 flop
┌────────┬──────────┬─────────┐
│        │  Float32 │ Float64 │
├────────┼──────────┼─────────┤
│ muladd │        0333040 │
│    add │ 9173456572271 │
│    sub │ 22795413166263 │
│    mul │ 97629124244707 │
│    div │  258065381624 │
│    rem │        048 │
│    abs │        059320 │
│    neg │  499000048775 │
│   sqrt │        04850 │
└────────┴──────────┴─────────┘

julia> 91734565+22795413+97629124+2580653+4990000
219729755

There's somehow 40k operations missing here (not counting Float64 ops as they are part of the model set up and not counted in Sherlogs), but maybe more importantly note how the speeds are fairly comparable, while Sherlogs include a fairly costly conversion Float32->Float16. So just saying that I support the idea of having some FakeFloats to count the flop - sure it would only work with type-generic functions, but might be considerably faster (the compile time also seems to largely reduced.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants