How can software run on different CPUs when they support different operations? When you download "debian-live-12.7.0-amd64-kde.iso", all the programs in the repos support all current Intel and AMD CPUs, right? Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Do dynamic languages (Javascript, Python, PHP...) get a speed boost becau…
SSE2 is a requirement for x86-64, which gives at least a reasonable(128bit wide SIMD) baseline. SSE4 is from 2008, so making it a requirement isn't unreasonable. Even AVX2 is from 2013, so some apps require it nowadays. It is extremely difficult for a compiler to convert scalar code to SIMD automatically, even static C++ compilers really suck at it. A dynamic compiler for javascript would have no real hope of any mea…
Why those particular integer multiplies?
11–20 of 39 posts
Re: Why those particular integer multiplies?
#12How can software run on different CPUs when they support different operations? When you download "debian-live-12.7.0-amd64-kde.iso", all the programs in the repos support all current Intel and AMD CPUs, right? Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Do dynamic languages (Javascript, Python, PHP...) get a speed boost becau…
SSE2 is a requirement for x86-64, which gives at least a reasonable(128bit wide SIMD) baseline. SSE4 is from 2008, so making it a requirement isn't unreasonable. Even AVX2 is from 2013, so some apps require it nowadays. It is extremely difficult for a compiler to convert scalar code to SIMD automatically, even static C++ compilers really suck at it. A dynamic compiler for javascript would have no real hope of any mea…
Re: Why those particular integer multiplies?
#13Maybe it’s me in the morning, but for some reason it was a very hard read for the text about cpu instructions. Feels like it loads you with details for ages.
Re: Why those particular integer multiplies?
#14How can software run on different CPUs when they support different operations? When you download "debian-live-12.7.0-amd64-kde.iso", all the programs in the repos support all current Intel and AMD CPUs, right? Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Do dynamic languages (Javascript, Python, PHP...) get a speed boost becau…
> Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Mostly the former. Some highly optimized bits of software do the latter—they are built with multiple code paths optimized for different hardware capabilities, and select which one to use at runtime. > Do dynamic languages (Javascript, Python, PHP...) get a speed boost because they…
They tried to do something similar in Javascript but it added way too much complexity to the runtimes and ended up getting dropped in favor of WASM SIMD.
Re: Why those particular integer multiplies?
#15How can software run on different CPUs when they support different operations? When you download "debian-live-12.7.0-amd64-kde.iso", all the programs in the repos support all current Intel and AMD CPUs, right? Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Do dynamic languages (Javascript, Python, PHP...) get a speed boost becau…
SSE2 is a requirement for x86-64, which gives at least a reasonable(128bit wide SIMD) baseline. SSE4 is from 2008, so making it a requirement isn't unreasonable. Even AVX2 is from 2013, so some apps require it nowadays. It is extremely difficult for a compiler to convert scalar code to SIMD automatically, even static C++ compilers really suck at it. A dynamic compiler for javascript would have no real hope of any mea…
Re: Why those particular integer multiplies?
#16PMULLD is probably just doing 2x PMULUDQ and discarding the high bits.
(I tried commenting on his blog but it's awaiting moderation - I don't know if that's ever checked, or just sits in the queue forever)
Re: Why those particular integer multiplies?
#17Earlier quoted context omitted.
SSE2 is a requirement for x86-64, which gives at least a reasonable(128bit wide SIMD) baseline. SSE4 is from 2008, so making it a requirement isn't unreasonable. Even AVX2 is from 2013, so some apps require it nowadays. It is extremely difficult for a compiler to convert scalar code to SIMD automatically, even static C++ compilers really suck at it. A dynamic compiler for javascript would have no real hope of any mea…
The problem is that there were CPUs made well after 2008 that don't support SSE4. In particular, Phenom II was fairly popular, sold up until 2012, and doesn't even support SSSE3 (much less SSE4.1 and SSE4.2; only an AMD-specific variant known as SSE4a).
Re: Why those particular integer multiplies?
#18How can software run on different CPUs when they support different operations? When you download "debian-live-12.7.0-amd64-kde.iso", all the programs in the repos support all current Intel and AMD CPUs, right? Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Do dynamic languages (Javascript, Python, PHP...) get a speed boost becau…
> Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Mostly the former. Some highly optimized bits of software do the latter—they are built with multiple code paths optimized for different hardware capabilities, and select which one to use at runtime. > Do dynamic languages (Javascript, Python, PHP...) get a speed boost because they…
https://docs.oracle.com/en/java/javase/23/docs/api/jdk.incub...
https://docs.oracle.com/en/java/javase/23/docs/api/jdk.incub...
Re: Why those particular integer multiplies?
#19Earlier quoted context omitted.
> Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Mostly the former. Some highly optimized bits of software do the latter—they are built with multiple code paths optimized for different hardware capabilities, and select which one to use at runtime. > Do dynamic languages (Javascript, Python, PHP...) get a speed boost because they…
It's possibly worth mentioning that Java is getting a vector API which explicitly abstracts over some of the details of SIMD, including width. You have a type Vector which represents enough of some type T to fill a vector register (eg eight 32-bit numbers in a 256-bit register), operations on Vector which produce another Vector , and some way to break arrays up into Vectors of the right size for the platform. The API…
Re: Why those particular integer multiplies?
#20How can software run on different CPUs when they support different operations? When you download "debian-live-12.7.0-amd64-kde.iso", all the programs in the repos support all current Intel and AMD CPUs, right? Do they just target the lowest common denominator of operations? Or do they somehow adapt to the operations supported by the user's CPU? Do dynamic languages (Javascript, Python, PHP...) get a speed boost becau…
This is called runtime dispatch. You can do it manually or use a library, like Google Highway. GCC supports multiversioning where you write separate versions of a function and the right one is selected at runtime.
https://github.com/google/highway
https://gcc.gnu.org/onlinedocs/gcc-9.1.0/gcc/Function-Multiv...