Comment

Comment by kragen

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.

parent kragen 5 years ago

Discussion

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton