Live data from Hacker News

Why those particular integer multiplies?

fgiesen.wordpress.com

31–39 of 39 posts

Re: Why those particular integer multiplies?

#31

It's a shame that SIMD is still a dark art. I've looked at writing a few simple algorithms with it but have to do it in my own time as it'll be difficult to justify it with my employer. I do know that gcc is generally terrible at auto-vectorising code, clang is much better but far from perfect. Using intrinsics directly will just lead to code that's unmaintainable by others not versed in the dark art. Even wrappers o…

Re: SIMD

Suggest you look at the Julia Language, a high-level but still capable of C-like speed.

It has built in support for SIMD (and GPU) processing.

Julia is designed to support Scientific Computing, with a growing library spanning different domains.

https://docs.julialang.org/en/v1/

Re: Why those particular integer multiplies?

#32
post #23
post #5

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…

> the lowest common denominator of operations? Note that in recent years the chosen LCD for some distros has changed - they're starting to target the v2 feature set rather than the original. See https://developers.redhat.com/blog/2021/01/05/building-red-h... > Do dynamic languages (Javascript, Python, PHP...) get a speed boost because they can compile just in time and use all the features of the user's CPU? Dynamical…

> but only if you avoid classes and use only arrays

Please do look into the kind of codegen emitted by OpenJDK and .NET before assuming this. It's a bit difficult with -XX:+PrintAssembly and much easier with DOTNET_JitDisasm='pattern'/Disasmo/NativeAOT+Ghidra. Once you do, you will clearly see how the exact set of ISA extensions influences instruction selection for all sorts of operations like stack zeroing, loads/stores, loop vectorization (automatic or manual), etc. .NET has extensive intrinsics and portable SIMD APIs that use effectively static dispatch even if the path is still picked at runtime, but just once during JIT compilation.

> still suffers from its Windows-centric history.

This is a provably wrong, especially in peformance-related scenarios.

Re: Why those particular integer multiplies?

#33

It's a shame that SIMD is still a dark art. I've looked at writing a few simple algorithms with it but have to do it in my own time as it'll be difficult to justify it with my employer. I do know that gcc is generally terrible at auto-vectorising code, clang is much better but far from perfect. Using intrinsics directly will just lead to code that's unmaintainable by others not versed in the dark art. Even wrappers o…

[deleted]

Re: Why those particular integer multiplies?

#34
post #23

Earlier quoted context omitted.

> the lowest common denominator of operations? Note that in recent years the chosen LCD for some distros has changed - they're starting to target the v2 feature set rather than the original. See https://developers.redhat.com/blog/2021/01/05/building-red-h... > Do dynamic languages (Javascript, Python, PHP...) get a speed boost because they can compile just in time and use all the features of the user's CPU? Dynamical…

> but only if you avoid classes and use only arrays Please do look into the kind of codegen emitted by OpenJDK and .NET before assuming this. It's a bit difficult with -XX:+PrintAssembly and much easier with DOTNET_JitDisasm='pattern'/Disasmo/NativeAOT+Ghidra. Once you do, you will clearly see how the exact set of ISA extensions influences instruction selection for all sorts of operations like stack zeroing, loads/st…

In non-performance contexts, C# still suffers from the fact that I can't just reach out and install it from any random distro. The only other major languages with a comparable problem are Kotlin and Swift, which suffer from a similar association with Android and Mac OS, respectively.

Re: Why those particular integer multiplies?

#35
post #34

Earlier quoted context omitted.

> but only if you avoid classes and use only arrays Please do look into the kind of codegen emitted by OpenJDK and .NET before assuming this. It's a bit difficult with -XX:+PrintAssembly and much easier with DOTNET_JitDisasm='pattern'/Disasmo/NativeAOT+Ghidra. Once you do, you will clearly see how the exact set of ISA extensions influences instruction selection for all sorts of operations like stack zeroing, loads/st…

In non-performance contexts, C# still suffers from the fact that I can't just reach out and install it from any random distro. The only other major languages with a comparable problem are Kotlin and Swift, which suffer from a similar association with Android and Mac OS, respectively.

You can, except Debian but that’s Debian for you.

  sudo apt/dnf install dotnet-sdk-8.0
For Debian use this: https://learn.microsoft.com/en-us/dotnet/core/install/linux-...

It is a better user experience than dealing with C/C++ or Java tooling too.

For shipping packages you don’t even need this since you can just publish them as self-contained or as native binaries.

Re: Why those particular integer multiplies?

#36
post #15
post #8

Earlier 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).

Another issue with lots of older processors is that they would slow down clock speed when using SIMD instructions so much that there was effectively no performance gain. You had to be very careful which instructions you could actually use.

Re: Why those particular integer multiplies?

#37
post #36
post #15

Earlier quoted context omitted.

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).

Another issue with lots of older processors is that they would slow down clock speed when using SIMD instructions so much that there was effectively no performance gain. You had to be very careful which instructions you could actually use.

AFAIK this was only ever really true for AVX-512 (when touching the actual wider registers). Most others have had a moderate downclock, but still normally worth it.

Re: Why those particular integer multiplies?

#38
post #37
post #36

Earlier quoted context omitted.

Another issue with lots of older processors is that they would slow down clock speed when using SIMD instructions so much that there was effectively no performance gain. You had to be very careful which instructions you could actually use.

AFAIK this was only ever really true for AVX-512 (when touching the actual wider registers). Most others have had a moderate downclock, but still normally worth it.

You're right, it's been a while since I dabbled in SIMD.

Re: Why those particular integer multiplies?

#39
post #5

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…

it is very easy to rebuild your own from the exact kernel version that you downloaded from the same sources. The kernel build process allows you to tailor your build compiler to exactly the processor and hardware you have. (of course, there's some assembly in there, I'm not sure how much of it is #ifdef'ed for tuning)

In the first years of linux, this is what you did, it's the way it worked more or less by default with the Slackware, the first popular "distro". RedHat and Debian came out, and they started to streamlined away from it, but it's still easy to do in those systems. I don't use debian much, but with RH/fedora you download the source rpm and use rpmbuild to unpack and build, then you can go poke around

I say it's easy, it is, but it is a bit ... not fussy, but detailed, very detailed. You answer many questions most of which you'd need to do a little research for, but you can explore the ones you want and accept defaults for the rest.

caveat: i have not done this in a half dozen years, hope it still works

Post reply on HN