this post was submitted on 17 Oct 2024
1378 points (99.0% liked)

RetroGaming

19477 readers
213 users here now

Vintage gaming community.

Rules:

  1. Be kind.
  2. No spam or soliciting for money.
  3. No racism or other bigotry allowed.
  4. Obviously nothing illegal.

If you see these please report them.

founded 1 year ago
MODERATORS
 
you are viewing a single comment's thread
view the rest of the comments
[–] acockworkorange@mander.xyz 5 points 2 weeks ago (2 children)

There’s absolutely nothing you can do in C that you can’t also do in assembly. Because assembly is just the bunch of bits that the compiler generates.

That said, you’d have to be insane to write a game featuring SIMD instructions these days in assembly.

[–] Buddahriffic@lemmy.world 3 points 2 weeks ago (2 children)

I think they meant the other way around, that if you wanted to use it in C/C++, you'd have to either use assembly or some specific SSE construct otherwise the compiler wouldn't bother.

That probably was the case at one point, but I'd be surprised if it's still the case. Though maybe that's part of the reason why the Intel compiler can generate faster code. But I suspect it's more of a case of better optimization by people who have a better understanding of how it works under the hood, and maybe better utilization of newer instruction set extensions.

SSE has been around for a long time and is present in most (all?) x86 chips these days and I'd be very surprised if gcc and other popular compilers don't use it effectively today. Some of the other extensions might be different though.

[–] calcopiritus@lemmy.world 3 points 2 weeks ago

If you want to use instructions from an extension (for example SIMD), you either: provide 2 versions of the function, or just won't run in some CPUs. It would be weird for someone that doesn't know about that to compile it for x86 and then have it not run on another x86 machine. I don't think compilers use those instructions if you don't tell them too.

Anyway, the SIMD the compilers will do is nowhere near the amount that it's possible. If you manually use SIMD intrinsics/inline SIMD assembly, chances are that it will be faster than what the compiler would do. Especially because you are reducing the % of CPUs your program can run on.

[–] acockworkorange@mander.xyz 2 points 2 weeks ago

Oh I see your point. Yeah, I think they meant that. And yes, there was a time you’d have to do trickery in C to force the use of SSE or whatever extensions you wanted to use.

[–] Wilzax@lemmy.world 3 points 2 weeks ago (1 children)

Technically assembly is a human-readable, paper-thin abstraction of the machine code. It really only implements one additional feature over raw machine code and that's labels, which prevents you from having to rewrite jump and goto instructions EVERY TIME you refactor upstream code to have a different number of instructions.

So not strictly the bunch of bits. But very close to it.

[–] acockworkorange@mander.xyz 1 points 2 weeks ago

Technically correct. The best kind of correct.