Live data from Hacker News

Ask HN: What is hand-coded assembly language used for these days?

news.ycombinator.com

11–20 of 60 posts

Re: Ask HN: What is hand-coded assembly language used for these days?

#11
IMVU hand-rolled its SSE skinning loops and parts of the software 3D lighting code, because only 2/3 of our customers have GPUs. We need to run well on five-year-old Dells with Intel graphics. (Direct3D on Intel isn't as good as a dedicated software renderer. We chose RAD's Pixomatic.)

In addition, look at how popular netbooks are becoming. The Intel Atom is an in-order CPU. Imagine a hyperthreaded, 1.6 GHz 486...

On the iPhone it's even worse. It's got a decent vector unit, but the CPU is very slow. You'll see great wins by doing your 3D math yourself.

As we continue to become multicore, I could imagine somebody shaving a couple cycles out of the core message passing routines, though you're almost certainly bus bound in those situations...

Computers are getting smaller and people want more out of them; assembly language is back in style!

Re: Ask HN: What is hand-coded assembly language used for these days?

#12
Signal processing algorithms on the phones made by a certain company I worked at are mostly written in assembly. The cellular protocols, at least those that use time-division (e.g. GSM), have strict real-time constraints, but mostly they use assembly because every microsecond you can shave off those algorithms is a microsecond you can sleep and conserve power.

Re: Ask HN: What is hand-coded assembly language used for these days?

#13

IMVU hand-rolled its SSE skinning loops and parts of the software 3D lighting code, because only 2/3 of our customers have GPUs. We need to run well on five-year-old Dells with Intel graphics. (Direct3D on Intel isn't as good as a dedicated software renderer. We chose RAD's Pixomatic.) In addition, look at how popular netbooks are becoming. The Intel Atom is an in-order CPU. Imagine a hyperthreaded, 1.6 GHz 486... On…

Oh, I forgot about another huge case for writing assembly language... These days, we have tons of different languages talking to each other, all in the same program. In Mozilla, for example, JavaScript talks to C++ objects via XPCOM/XPIDL. Since the C++ objects expect data laid out on the C stack in a certain order and JavaScript has no notion of the C stack, there is a bit of platform-specific assembly code in the middle that takes the JavaScript values, places them on the stack, and jumps into the C++.

I'm guessing that most languages with built-in foreign function interfaces (like Python's ctypes) have similar thunking layers.

Re: Ask HN: What is hand-coded assembly language used for these days?

#14

Anything that's worth spending time to do fast is worth spending time writing SIMD assembly for. You can get 5x, 10x, 20x, or more performance increases just by using the vector instructions given to you by the CPU. Until a magic compiler appears that can make proper use of them (read: never), hand-coded assembly will be critical for almost any application for which performance is critical, especially multimedia proc…

A compiler can't be made to make proper use of vector instructions? Why is that?

Re: Ask HN: What is hand-coded assembly language used for these days?

#15
In addition to the optimization reasons, you also end up coding assembly by hand to tickle features in the verification and bringup of new processors and/or processor architectures.

Since a lot of the bugs therein may be dependent on a certain sequence of instructions, doing it in a high level language doesn't make any sense.

Re: Ask HN: What is hand-coded assembly language used for these days?

#16
post #2

Some weirdos just plain like it more than high-level languages. One of those weirdos is developing the Linoleum language: http://anywherebb.com/bb/index.php?l=D4JeGEdhacS6Srr6QLQgZpW...

I, for one, think that Assembly is just beautiful in its simplicity.

Re: Ask HN: What is hand-coded assembly language used for these days?

#17
post #14

Anything that's worth spending time to do fast is worth spending time writing SIMD assembly for. You can get 5x, 10x, 20x, or more performance increases just by using the vector instructions given to you by the CPU. Until a magic compiler appears that can make proper use of them (read: never), hand-coded assembly will be critical for almost any application for which performance is critical, especially multimedia proc…

A compiler can't be made to make proper use of vector instructions? Why is that?

In many cases it can, but then you have to be sure that it keeps doing so. You can write test cases for that, but in many cases it's easier to verify by just using the instructions directly.

If you don't write the compiler, you have to make assumptions about when and how it can/will use those instructions, and often you assume wrong, particularly across compiler upgrades.

Re: Ask HN: What is hand-coded assembly language used for these days?

#18
post #14

Anything that's worth spending time to do fast is worth spending time writing SIMD assembly for. You can get 5x, 10x, 20x, or more performance increases just by using the vector instructions given to you by the CPU. Until a magic compiler appears that can make proper use of them (read: never), hand-coded assembly will be critical for almost any application for which performance is critical, especially multimedia proc…

A compiler can't be made to make proper use of vector instructions? Why is that?

It is an extraordinarily difficult problem to transform scalar code into vector instructions. The only way to get even passable output from a vectorizing compiler is to write the code as vectors to begin with, such as with cross-platform assembly tools like Orc.

And even then you'll often end up significantly worse off than if you wrote the assembly by hand.

A run of Intel's compiler on the C versions of our DSP functions resulted in a grand total of one vectorization, which was done terribly, too.

Re: Ask HN: What is hand-coded assembly language used for these days?

#19
GPGPU stuff -- that is, using your graphics processor for random programming tasks. While something like CUDAhttp://www.nvidia.com/object/cuda_home.html>CUDA; reduces the need to write assembly-like code, it also reduces the available speed substantially.

For that matter, CUDA (and ATI's Bare-Metal Interface, which is similar) is more assembly-like than C-like in many ways. So even using the higher-level available language is still pretty much like assembly.

You tend to only write these things when you're going to be running a lot of elements through, so almost everything you do in these platforms is inner-loop, or you'd be using a different tool. So even small speed-ups tend to matter.

Re: Ask HN: What is hand-coded assembly language used for these days?

#20
post #16
post #2

Some weirdos just plain like it more than high-level languages. One of those weirdos is developing the Linoleum language: http://anywherebb.com/bb/index.php?l=D4JeGEdhacS6Srr6QLQgZpW...

I, for one, think that Assembly is just beautiful in its simplicity.

Having read and written assembly on a daily basis for years, I have to disagree entirely. The only simple thing about assembly is that it happens to map to machine code directly, but macros and quasi-instructions even make that iffy. There are so many idiosyncrasies in every ISA, so many ways in which the code you write has side effects. Assembly isn't just complex in practice, it's complex in concept.

If you want simplicity, you look at lisps; homoiconicity is perhaps the most elegant, simple concept known in computing. It may be more complex in practice (many more layers above the bare metal), but in concept it's simply beautiful.

Post reply on HN