c - Why do you program in assembly? -
I have a question for all hardcore lower level hackers. I ran into this sentence in a blog; I have not really thought that the source (if you really care about it then is called hawk) because it is a general statement. For example, in many modern 3-D games, their high performing core is C ++ and the engine written in the assembly.
As far as the assembly goes - the code written in the assembly is because you do not want a compiler to use additional instructions or use excessive bytes, or do you have better algorithms You can not express in C (or can not express them without the compiler compiling)?
I fully understand that it is important to understand low-level stuff. After understanding this, I want to understand the why program in the assembly.
I think you are saying this statement wrong: For example, many modern 3- In D Games, they have high performance core engines written in C ++ and assembly.
The games (and most of these programs) "written in assembly" are not the same way that they are "written in C ++". This blog is not saying that a significant portion of the game is made in the assembly, or a team of programmers sit around and develops into the primary language of the assembly.
This actually means that developers first write games and work in C ++. Then they profile it, find out what the obstacles are, and if it is appropriate, they optimize the exit of them in the assembly. Or, if they have already experienced it, they know which obstacles are coming from them, and they have found customized pieces around other games that they have created.
The assembly in programming is similar because it has always been: to write lot of code in the speed assembler It will be ridiculous, but there are some optimizations that the compiler does not have the information, and for a small window of code, a human being is doing better
For example, for floating point, Compiler is very conservative And maybe some of your architecture Do not know about the advanced features. If you are willing to accept some error, you can generally do better than the compiler, and it is worth writing a bit of code in assembly if you think that it takes a lot of time.
Here are some more relevant examples:
Examples from games
-
Using the SSE Interrins The last code about customizing a game engine uses internal code (not inline codlar), so the amount of pure assembly is very small. But what to do to find out properly to see the codeal output by the compiler.
-
Earthquake does not have to be assembler in regular, regular, but you need to know something about architecture for such adaptation. The authors know what the operation is fast (multiplication, variation) and which are slow (split, sqrt) they come with a very complex implementation of the square root which avoids the slow operation completely.
High-performance computing
-
Outside of the game, people in scientific computing often do things Get out so that they can run fast on the latest hardware. Think about the game about this, where you can not cheat on physics.
Its a great recent example describes how the problem triggers a very small computational kernel, which was a lot more customizable for PowerPC 440. Each 440 has two FPUs, and they support some special turnarial operations which are difficult to exploit for the compiler. Without these optimizations, the Latys QCD runs very slowly, which is expensive when your problem requires millions of CPUs on expensive machines.
If you are thinking why it is important, have come out of this task that check out the use of the Latiss QCD, these people first get the proton mass Let's count, and last year it has shown that 90% of the mass comes from binding energy with mass power, and from the remaining quarks. It's in action.
For all of the above, applications are designed no or 100% written in assembly - even not close as well. But when people actually need speed, they focus on writing the main parts of their code to fly on specific hardware.
Comments
Post a Comment