Re: LW compiler optimizations

"Alexey Veretennikov (as alexey dot veretennikov at protonmail dot com)" <[email protected]>
Newsgroups gmane.lisp.lispworks.general
Message-ID <waDqS4-ws6dgjb-yCOWT-uV-zFFixSqQ35B8l3d40RjTXlSmlZs3v2kziiFfXuZ5n9k7U_bGN2H1RB9TylEY9twoZNRZ2H9AIiZsJd6iId0=@protonmail.com>
C++ has a "expression template" pattern for that which is used by library builders to optimize their operations while keeping the API looking clear:

https://en.wikipedia.org/wiki/Expression_templates

BR,
/Alexey

On Tuesday, January 14th, 2025 at 08:48, Yuri Davidovsky (as work at disclosure dot ie) <[email protected]> wrote:

>> On 14 Jan 2025, at 07:56, Christopher Stacy (as cstacy at dtpq dot com) <[email protected]> wrote:
>
>> I don't do any DSP programming, but it seems like a standard interface for MAC could be useful Apparently C has a standard interface called "fma()". Most computers have hardware for this. In addition, some higher level interfaces could also be standardized, where the operating system or other libraries are (FFI or otherwise) called.
>
> D lang does it in a very elegant way without even advertising it, and it took me by surprise. I was playing with some neural network code in it a while back, and was seeing some performance that literally should not have been possible on that machine, multiples of the clock speed.
>
> That got me puzzled.
>
> What I was doing is the array operations, similar to
>
> a += b * c
>
> where a, b and c are arrays. First it only seemed like a syntactic piece of sugar, but it turned out that the compiler vectorised the operations using SIMD operations behind the scenes. If those were not present, it would not matter, the compiler would simply fall back to the scalar operations.
>
> It was quite remarkable how smoothly it was designed and implemented, you literally had to know nothing of simd programming and it would work, if I were writing my own statically typed language, that would be my go-to example.
>
> Another feature of the language that got me impressed was array slicing, which was also extremely well optimised and worked seamlessly. One would simply had to use expressions like
>
> a[8..72] += b[8..72] * c [8..72]
>
> and it would work.
>
> https://dlang.org/articles/d-array-article.html
>
> [D Slices - D Programming Language](https://dlang.org/articles/d-array-article.html)
> [dlang.org](https://dlang.org/articles/d-array-article.html)	[favicon.ico](https://dlang.org/articles/d-array-article.html)
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.