You feel that if someone wanted to know how to implement things at the level of CPU technology, it would be worthwhile to waste their time with silly garbage?~ wrote:I just feel that if a team out of all of those out there wanted to know how to implement things at the level of CPU technology, it would be worthwhile.
No; this is very wrong. You can optimise each little function as much as you like and it will still be worthless garbage because nothing will be able to optimise the interactions between functions (inlining, constant folding, common sub-expression elimination, tail call optimisation, etc).~ wrote:It just seems to me that if a team was to create a massive amount of hand-made assembly routines with a style that resembled the usage of other instructions, maybe even using opcode-like byte structure for the parameters, those routines could be very durable, as much as the rest of native instructions, taking their logic to concise, minimal, optimized bits per routine.
They would just need to be routinely optimized as much as the instructions themselves. But if there is a part of the team that only works at the low level optimizations also with the intention to gain CPU-implementing technology (for hardware projects of theirs), then the high-level team would simply make the rest of the program, and if they know that something is too slow, they could easily direct hand-optimized assembly only to the most critical parts of the program, not necessarily to everything, and it could become more understandable just because of being in the context of something that urges optimization.
It can make sense to spend a massive amount of time creating a "highly optimised by hand" piece of assembly for a very specific purpose (e.g. MPEG decoder); but these things can already be done and already are done (and often put in libraries and used from high level languages).~ wrote:It seems to me that if it was possible to design an optimizing CPU, then it's possible for a good team to create optimized code where it's really needed. Not many things truly require brutal optimization, only the most specialized algorithms. The rest can be gradually improved over time. It could be an interesting platform to re-explore.
Sure, if you don't care about performance at all, you can make 80x86 assembly language portable between 16-bit, 32-bit and 64-bit, just by not using anything that isn't supported in all CPU modes; and all assemblers support this (without macros or other ugly hacks).~ wrote:At least x86 assembly has been proven to be able to have portable code for 16, 32 and 64-bit as much as if it was C, so the possibility is there.
If you do care about performance then you need to optimise for specific cases; because some instructions are faster/slower on different CPUs, some CPUs do "micro-op fusion" and some don't, some have "loop stream detection" and some don't, etc; and also because some CPUs support features/instructions that others don't (SSE, AVX, etc).
For one example; for something like (e.g.) "find the 2 points in an array of points which are the closest to each other" you'd need about 100 variations where each variation is optimal for a specific CPU in a specific mode.
I don't see how the current bulk of software could benefit from becoming extremely inefficient and slow.~ wrote:And with the current bulk of software it would probably be beneficial to do this at least for making the machine execute a considerably shorter stream of code.
Cheers,
Brendan