Live data from Hacker News

Towards fearless SIMD

raphlinus.github.io

1–10 of 82 posts

Re: Towards fearless SIMD

#3

What is SIMD?

Single Instruction Multiple Data

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

ELI5: Your processor can process more data in parallel.

If you have for example loop that has something like this in the body:

a[i] + b[i] = c[i]

Using SIMD processor can make all this operations same time:

a[i] + b[i] = c[i]

a[i+1] + b[i+1] = c[i+1]

a[i+2] + b[i+2] = c[i+2]

a[i+3] + b[i+3] = c[i+3]

Normally in one iteration you would only get one of this addition done without SIMD, thanks to SIMD you can have multiple.

Re: Towards fearless SIMD

#4
post #3

What is SIMD?

Single Instruction Multiple Data https://en.wikipedia.org/wiki/SIMD ELI5: Your processor can process more data in parallel. If you have for example loop that has something like this in the body: a[i] + b[i] = c[i] Using SIMD processor can make all this operations same time: a[i] + b[i] = c[i] a[i+1] + b[i+1] = c[i+1] a[i+2] + b[i+2] = c[i+2] a[i+3] + b[i+3] = c[i+3] Normally in one iteration you would only get one of…

Thanks! I get that if you don't already know the acronym, you're not the audience, but it is helpful to not have to search externally for a reference. Could you imagine if that was in a general programming magazine before global internet search engines were popular? You'd have to cross your fingers that your local encyclopedia has an entry!

ETA: My bad - I did not think to click that. Embarrassing. Thanks for pointing it out!

Re: Towards fearless SIMD

#5
post #3

Earlier quoted context omitted.

Single Instruction Multiple Data https://en.wikipedia.org/wiki/SIMD ELI5: Your processor can process more data in parallel. If you have for example loop that has something like this in the body: a[i] + b[i] = c[i] Using SIMD processor can make all this operations same time: a[i] + b[i] = c[i] a[i+1] + b[i+1] = c[i+1] a[i+2] + b[i+2] = c[i+2] a[i+3] + b[i+3] = c[i+3] Normally in one iteration you would only get one of…

Thanks! I get that if you don't already know the acronym, you're not the audience, but it is helpful to not have to search externally for a reference. Could you imagine if that was in a general programming magazine before global internet search engines were popular? You'd have to cross your fingers that your local encyclopedia has an entry! ETA: My bad - I did not think to click that. Embarrassing. Thanks for pointin…

In fairness the first word of the article is SIMD with a hyperlink to the Wikipedia page.

Re: Towards fearless SIMD

#8
post #6

The simplest target-independent fearless SIMD is autovectorization[1] . But taking maximum advantage of that probably means writing some code that feels a little unnatural. Also, IIRC bounds checks thwart some autovectorization. [1] https://llvm.org/docs/Vectorizers.html

In an LLVM context it also means you don't get runtime feature detection. You would need to build N dlls and then write code to load the proper one at runtime based on feature detection.

JITs could solve that problem, but few JITs currently do very much auto vectorization, because they don't have time.

Re: Towards fearless SIMD

#9
post #3

Earlier quoted context omitted.

Single Instruction Multiple Data https://en.wikipedia.org/wiki/SIMD ELI5: Your processor can process more data in parallel. If you have for example loop that has something like this in the body: a[i] + b[i] = c[i] Using SIMD processor can make all this operations same time: a[i] + b[i] = c[i] a[i+1] + b[i+1] = c[i+1] a[i+2] + b[i+2] = c[i+2] a[i+3] + b[i+3] = c[i+3] Normally in one iteration you would only get one of…

Thanks! I get that if you don't already know the acronym, you're not the audience, but it is helpful to not have to search externally for a reference. Could you imagine if that was in a general programming magazine before global internet search engines were popular? You'd have to cross your fingers that your local encyclopedia has an entry! ETA: My bad - I did not think to click that. Embarrassing. Thanks for pointin…

> Could you imagine if that was in a general programming magazine before global internet search engines were popular?

Style manuals of the time encouraged expanding acronyms on first use, but I can imagine this wasn't consistently done in a technical field!

Re: Towards fearless SIMD

#10
post #6

The simplest target-independent fearless SIMD is autovectorization[1] . But taking maximum advantage of that probably means writing some code that feels a little unnatural. Also, IIRC bounds checks thwart some autovectorization. [1] https://llvm.org/docs/Vectorizers.html

In an LLVM context it also means you don't get runtime feature detection. You would need to build N dlls and then write code to load the proper one at runtime based on feature detection. JITs could solve that problem, but few JITs currently do very much auto vectorization, because they don't have time.

> In an LLVM context it also means you don't get runtime feature detection. You would need to build N dlls and then write code to load the proper one at runtime based on feature detection.

Does LLVM not support GCC-style function multiversioning?

Post reply on HN