Boost logo

Boost :

From: Claudio DeSouza (cdesouza_at_[hidden])
Date: 2024-12-06 23:14:50


Yes, this is the challenge with optimisations, caching, etc, is: in many
cases you have to make a trade-off between size/performance. I think it is
also important to mention that if you ultimately want to tag a block as
unsafe buffers usage and just do pointer arithmetics on top of the memory
you received through a span, you are free to do that. That's your
prerogative. That's an aspect of the abstract machine you now have a much
finer control over because you spanified your interfaces. The other way
around is not true though. You can opt-in to spanify your interfaces and
retain the ability to deep dive in a lower level type of code, and use
pointers as you see fit, However, you don't benefit from higher
abstractions once all you have is just offer pointer/length pairs. I think
Peter has made this case in a much more educated manner that I have.

Claudio.

On Fri, Dec 6, 2024 at 11:06 PM Ivan Matek via Boost <boost_at_[hidden]>
wrote:

> On Fri, Dec 6, 2024 at 7:19 PM Vinnie Falco <vinnie.falco_at_[hidden]>
> wrote:
>
> >
> >> How?
> >
> > maybe we are not talking about same situation, but this is what I meant,
> godbolt <https://godbolt.org/z/K8xEjEoMK> link
> [image: image.png]
> Compiler will generate "specialized" functions for each different size of
> span with non dynamic extent. Here you can see how he implemented summation
> for 3 and 4 integers in different ways.
>
> This is great for performance and makes checking easier since as Peter
> explained compiler knows more, but it creates larger binaries(generally
> speaking, I know compilers are smart, can inline, for 2 instantiations does
> not really matter, etc).
> Function taking dynamic span or runtime specified n will probably be slower
> because it does normal loop, but there is only one copy of it in resulting
> assembly.
>
> There is a real life example of this here in fmt. note link gives
> certificate error and I did not manage to find another link
> https://vitaut.net/posts/2020/reducing-library-size/
>
> _______________________________________________
> Unsubscribe & other changes:
> http://lists.boost.org/mailman/listinfo.cgi/boost
>


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk