News for hackers. Stuff that matters.
Re:The Magic Kernel by kragen on Monday March 22, 2021 @09:42PM (#26549972)
Correction: if you want to do that in two dimensions, you have to do that twice, and the second dimension is going to have worse locality of reference, especially if you don't tile your images. I still think that's efficient and practical.

GCC unrolled the loop twice, so it was 34 instructions that processed two samples per iteration. The instructions are mostly things like this:

        addq    (%rax), %rbp
        subq    %rdi, %rcx
        addq    %rbx, %rdi
        subq    %rcx, %rdx
        movq    %rcx, -2064(%rax)
        movq    -2056(%rax), %rcx
That should clarify a bit how one core of my mere 2.8GHz Core i7 is managing to run over ten billion instructions per second.

Godbolt link for those who want to play: https://godbolt.org/z/MfEqYn3Pd

Gaussian blur gets used for this a lot precisely because it's so easy to compute this way — it's the only convolution kernel that's anisotropic and separable. So people press it into service doing things like camera bokeh that it's not really very good at.

Re:The Magic Kernel by johncostella on Monday March 22, 2021 @11:09PM (#26550577)
Ah nice, I will correct that statement, which I was sure was bound to have a counterargument. :)
Re:The Magic Kernel by kragen on Wednesday March 24, 2021 @12:35PM (#26569480)
I see that now your page links to my comment, saying, "More efficient ways of performing Gaussian blur have been noted; the Magic Blur was convenient in that it made use of existing hardware libraries and calling code stack."

But in fact what I described above is the Magic Blur algorithm, just in a slightly different guise, and it can probably take advantage of existing hardware libraries in the same way. However, I don't know what your hardware libraries are doing in the blur case!

Re:The Magic Kernel by kragen on Tuesday March 23, 2021 @10:22AM (#26555357)
Happy to help!