# Keeping track of simple vs high-performance versions

**URL:** <https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651>\
**Category:** Performance\
**Created:** [January 28, 2018, 9:17am UTC](https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651 "2018-01-28T09:17:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![improbable22](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/improbable22/32/5464_2.png) [@improbable22](https://discourse.julialang.org/u/improbable22)\
**Post date:** [January 28, 2018, 9:17am UTC](https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651/1 "2018-01-28T09:17:09Z")

</div>

Prompted by this [Dot function thread](https://discourse.julialang.org/t/dot-function/8644/3), in which I learned about [SugarBLAS](https://github.com/lopezm94/SugarBLAS.jl) and [InplaceOps](https://github.com/simonbyrne/InplaceOps.jl) and [Yeppp](https://github.com/JuliaMath/Yeppp.jl)… Often it seems that the first implementation of a function is very simple, and then the fast version is quite a bit more complicated.

Does anyone else try to keep both of them around, so that when you’ve forgotten what you were trying to do, you can look at the easy one first? And if you do, are there good ways to automate this, to make sure that the simple one is still giving the same result as the fast one?

I’m wondering if there ought to be some kind of `@slowversion` marker, which would cause tests to be run over both versions. (Ideally, all 2^n ways…) Perhaps this already exists?

---

<div class="post-metadata">

**Author:** ![Liso](https://avatars.discourse-cdn.com/v4/letter/l/898d66/32.png) [@Liso](https://discourse.julialang.org/u/Liso)\
**Post date:** [January 30, 2018, 7:00am UTC](https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651/2 "2018-01-30T07:00:32Z")

</div>

You probably want to benchmark two versions too! 🙂

Maybe `@reference_implementation` is better name…

If you are thinking about more far future then not only `@slowerversion` could be faster, but packages used to improve performance could be also abandoned. (And possibility to return to `@reference_implementation` could be useful)

Reference implementation could be helpful for documentation/learning too.

---

<div class="post-metadata">

**Author:** ![ChrisRackauckas](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/chrisrackauckas/32/77_2.png) [@ChrisRackauckas](https://discourse.julialang.org/u/ChrisRackauckas)\
**Post date:** [January 30, 2018, 7:57am UTC](https://discourse.julialang.org/t/keeping-track-of-simple-vs-high-performance-versions/8651/3 "2018-01-30T07:57:56Z")

</div>

DiffEq has two implementations of a lot of algorithms. The “slow versions” are out-of-place and actually faster for things like static arrays, which means that they actually have a purpose on smaller problems. Then the mutating versions are careful about memory access and the GPU kernels they build and so they are faster on mutable arrays and for parallelism. Dispatch keeps it all organized.

But I think you’ll see that with some practice it’s fairly obvious how to go from one to the other. It’s pretty clear how to find out what needs to be cached, what operations need to mutate, and what can be re-used after some practice. It’s really not a big deal. I keep the two since they are optimized in different domains, not for display purposes.
