News for hackers. Stuff that matters.
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by actionfromafar on Friday August 12, 2022 @07:27AM (#32436897)
I sometimes wonder if not these CPUs are just waiting to have their power unleashed. Almost like FPGAs, they could be reprogrammed to have custom instructions by someone skilled.
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by Tuna-Fish on Friday August 12, 2022 @09:44AM (#32438528)
This wouldn't actually help in common workloads, because the instructions that already exist are typically better than what you can achieve with microcode.

The reason for the RISC revolution was the understanding that there are fairly strict limits of what you can achieve in a single instruction if you want your cpu to be fast. An instruction that does some complex task that you need done is not really going to be any faster than composing the same action out of RISC instructions because, thanks to pipelining, the limiting factor on the speed of your cpu is going to be the actual work anyway.

Microcode on modern x86 cpus is typically slower (takes longer to output uops, outputs less per clock than the uop cache) than simple instructions, and only exists for legacy and doing some complex operations (like context switches) where being uninterruptible and having a bit of extra scratch space is useful.

Re:Custom Processing Unit: Hook, patch, and trace microcode ... by nine_k on Friday August 12, 2022 @07:19PM (#32445120)
Could one add the AES-NI instruction to Intel CPUs that lacked it using purely microcode? Would it be a speedup compared to encoding one round of AES using regular instructions?
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by actionfromafar on Friday August 12, 2022 @10:51AM (#32439516)
It makes sense what you say, but I still have doubts. Are you saying that not all x86 instructions are implemented in microcode? And wouldn't shader language be a perfect target for custom microcode, etc.
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by cesarb on Friday August 12, 2022 @12:22PM (#32440753)
> Are you saying that not all x86 instructions are implemented in microcode?

If you look at discussions about the instruction decoder of Intel processors, you often see it mentioned that they have something like three "simple" decoders and one "complex" decoder. The main difference is that the "complex" decoder is the only one which can decode instructions implemented in microcode (dispatching micro-operations from the microcode ROM), while the "simple" decoders can only output micro-operations directly (using something similar to hard-wired pattern matching on the instruction). So yes, many x86 instructions are not implemented in microcode.

Re:Custom Processing Unit: Hook, patch, and trace microcode ... by mhh__ on Friday August 12, 2022 @01:39PM (#32441713)
The term microcode has become muddled in that you have microcode for implementing highly complex instructions and "microcode" as-in an internal target that X86 instructions are translated into.
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by rep_lodsb on Friday August 12, 2022 @05:20PM (#32444063)
The internal instruction format is commonly called micro-ops / uops. But easy to confuse those terms.
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by mhh__ on Friday August 12, 2022 @07:38PM (#32445258)
I know, however lots of people make it up as they go along.
Re:Custom Processing Unit: Hook, patch, and trace microcode ... by mhh__ on Friday August 12, 2022 @01:36PM (#32441666)
These already exist in niche markets, they've stayed niche for a reason