The Quest for More Processing Power, Part Two: "Multi-core and multi-threaded gaming"
by Johan De Gelas on March 14, 2005 12:05 AM EST- Posted in
- CPUs
Conclusion
Writing multithreaded code means much higher software development costs while CPU development gets easier and thus cheaper (compared to even more complex superscalar CPUs). No wonder that the CPU developers are very motivated to hype the multi-core route, but the software development community is probably less enthusiastic.Intel and other manufacturers should not simply push the costs of getting higher performance onto the software developers. Because, in the end, it will be the consumer who will pay the final price: either more money or buggier software with more crashes and hangs. One way that Intel and others can help to keep multithreaded development costs under control while offering increasing CPU performance is to keep investing in ILP and thus higher IPC cores; another option is to improve the interCPU communications.
The easiest part of multithreading is using threads that are running completely independent, that don't share any data. But this source of threading is probably already being used almost to the fullest. In order to tap into a new source of multithreading, such as the largely unused potential of multithreaded AI, Phyics and animation, it is important that developers don't have to worry about interthread messaging and synchronization lowering performance.
Very fast interprocessor communications to make sure that thread synchronization comes with little overhead will give a bigger incentive to developers to invest the extra time in multithreading.
Gabriele Svelto:[4]
"Most of the current multi-threaded software is developed with an eye at keeping inter-thread messaging and synchronization as low as possible because both have a significant cost. This cost will be lowered by an ordered of magnitude by multiple cores on a single die giving in turn more flexibility for the programmers.The Pentium-D and Pressler are examples of how not to do it: just slap two CPUs on the same die and call it a day. High clocked single cores like the upcoming Athlon 64 FX-57 will eat these massive chips for lunch in almost all benchmarks while consuming less energy. With the exception of some special far-fetched benchmarks, it will be pretty hard to justify the reason behind these dual cores.
Applications which got low speed-ups by going multi-threaded due to the overhead of fine-grained locking mechanisms will be able to exploit multiple-processors with fast interprocessor communications much better."
Luckily, Intel's Yonah and AMD's Dual Athlon 64 cores show that better multi-core CPUs are on the way. At that point in time, we are entering the multi-core engine for real. And we can only applaud that because it unleashes a massive amount of CPU power upon the developers.
References
[1] Intel multi-core briefingStephen L. Smith, Vice President Digital Enterprise group, IDF Spring 2005
[2] Unreal 3 engine
http://www.unrealtechnology.com/html/technology/ue30.shtml
[3] Galactiv Cilivisations
http://www.galciv.com/index.asp?c=1&u=0
[4] Gabriele Svelto on dualcore CPUs
http://www.aceshardware.com/forums/read_post.jsp?id=20270&forumid=2
49 Comments
View All Comments
hzmonte - Tuesday, October 4, 2005 - link
For everyone's convenience, here is Part 3: http://www.anandtech.com/cpuchipsets/showdoc.aspx?...">http://www.anandtech.com/cpuchipsets/showdoc.aspx?...bmayer - Friday, March 25, 2005 - link
About the automatic parallization:It can be fairly easy to do. I work on some Cray X1 and X1es. A little bit about the X1. The Processors (called Multi-Streaming Processors (MSP)) are made up of 4 Single Streaming Processors (SSP). They are vector units with a lenght of 64 or 32 (can't remember, the point is they are good sized vector units). The processors are clocked at 800MHz for the X1 or 1.3GHz if you have an X1e.
Ok so what do we see? These CPUs *suck* if your code is not vectorized and running in parallel.Guess what the Cray compiler does? Automatically vectorizes, streams (takes advantage of a full MSP instead of a single SSP), and parallizes.
They lay out very clearly what the conditions are where the compiler can NOT optimize, and give you directives where you can force it to do so. You can also get a listing of why it did not do a given optimization for any given line. Actually it gives you all information by default which combined with grep is nice.
OK so there are different types of parallelizm, and the one I have just talked about is different then what they are trying to do. This has been talking about speeding up the execution of some inner loop, which is very different from doing two different things at the same time (AI module and sound module running at the same time). BUT this can still be used for great effect. When the inner loops execute for half the time as on a single core/CPU machine we now have more time to do other things, and thus see a speed improvement.
I have thought that Sony/IBM should get in touch with Cray to supply compiler tech for the Cell processor. If the Cell is as easy to write parallel code for as the X1 is we will have some very awesome games, and clusters of PS3s.
If you want to see a very nice overview of processor history and some of the crazy things people are proposing to do with the multi-cores check out ftp://ftp.cs.wisc.edu/sohi/talks/2003/pact.pdf
I agree that parallel C++ is just not happening very well. There are languages like UPC which are starting to gain hold in the HPC market, which *could* find some use in the game market. But as the state of the art stands it is Fortran which is really great for automatically generating parallel code. But who could serriously say that someone outside of engineering writes a code in Fortran?
Great article, lots to think about!
blckgrffn - Friday, March 18, 2005 - link
Loved it. All of it. Especially the interview with Sweeney - it is always nice to hear where the future *will* lie with regards to at least one major application/game. Now, just get an interview with Carmack, and I will be happy for a long time... :DNat
Caleb Jasin - Friday, March 18, 2005 - link
#41Sorry for the late reply.
And yeah pthreads are not threads really. They are processes. When you call the pthread_create() function you create a new proccess ;)
ravedave - Wednesday, March 16, 2005 - link
Sorry to double post. You could easily make a benchmark that saw 1000000000% speed increase. Take one application give it high priority and have it loop for 5 days. It would lock everything else up. Throw in a second processor and you no longer have that problem, hence a huge speedup in the other processes. I dont trust any numbers from any manufacturer.ravedave - Wednesday, March 16, 2005 - link
Excellent article. Extremely excllent. I like the fact that you mentioned GUI updates, most people forget that almost all applications are multi-thread as far as GUI/core go. I really think that Microsoft is on the right track with .NET though. I belive .NET 2 or 2.5 will really take multithreading to the next level.RockHydra11 - Tuesday, March 15, 2005 - link
My fear is that instead of creating new architctures for their processors to increase performance, they will just shove more cores on it and pass it off on people.Verdant - Tuesday, March 15, 2005 - link
#40i do see a shift to something like C# but anything that brings a "performance" hit, is likely to scare away developers, especially since on non-windows platforms the hit is pretty huge atm.
you are right that a compiler probably isn't an answer, i was merely stating that if the industry was dedicated to creating a "deserializing" compiler it would be possible, extremely complex, and probably technically more than a "compiler" but still possible...
also you are thinking of UNIX, the linux kernel has supported ever since i can remember, take a look at the pthreads and linuxthreads (glibc2) libraries
Caleb Jasin - Tuesday, March 15, 2005 - link
#35Yeah agreed, from my own experience C# threadding is much easier than threadding in C. And I would say it is the same for most code. Developing in C# is generally much faster than in C or C++. And the tests I have seen shows about a 10% performance hit between optimal C# and C++ code. So I think it is just a question of time before we see games coded primarily in C#. In the end, the time saved could be used to write more optimal code I guess, so maybe the performance hit would be negligable.
However, I don't think that we will see compilers that are smart enough to multithread code any time soon. I wrote a very simple compiler for a very simple language in university and coding compilers is extremely complicated. As Tim says, they aren't threadding gamelogics and that wouldn't make much sense either because there are too many dependencies. And even though threadding takes alot of time, there are alot of relatively easily paralizeable code in games.
Btw, there is a small error in the article. It says that Linux has thread support. It really doesn't. A thread in Linux is a process. There is no diffrence at kernel level between starting a new thread and forking a new process.
melgross - Tuesday, March 15, 2005 - link
Don't forget that the idea behind these game engines is the reusability of the code. What I mean is that they will first tackle the problems that Sweeney thought most important, and easier, and then, one by one, the harder problems will be resolved. This might take years, but performance increases are always going to be appreciated. Competing products are always going to put pressure on on each other.Ten years from now the discussion will be about how they accomplished all of this.
While dual-cored GPUs have never been used, since that is just now becoming a viable technology, dual and quad GPUs have been used for many years now on the high end boards. Not the gamer boards that we see for $500 and below.