.com.unity Forums
  The Official e-Store of Shrapnel Games

This Month's Specials

Raging Tiger- Save $9.00
The Star and the Crescent- Save $9.00

   







Go Back   .com.unity Forums > Shrapnel Community > Space Empires: IV & V

Reply
 
Thread Tools Display Modes
  #1  
Old September 23rd, 2007, 10:02 PM
Will's Avatar

Will Will is offline
Lieutenant Colonel
 
Join Date: Mar 2001
Location: Emeryville, CA
Posts: 1,412
Thanks: 0
Thanked 0 Times in 0 Posts
Will is on a distinguished road
Default Re: OT: Building a new computer...

It would not actually be too much of a problem structure-wise to get most games multi-threaded. For example, SEV; instead of each AI processing its turn in order, just spawn a thread for each AI, and have each work on its processing at the same time. For combat, spawn a new thread to resolve the combat, and continue processing other parts of the game.

The issue isn't with games not having multiple threads in mind at the design stage; the issue is with actually writing the games to exploit multiple threads WITHOUT concurrency bugs. A FPS-type game is fairly natural with two threads, one to update the game state (player input, monster movements, etc), and the other to read the game state and do the appropriate rendering on the screen. This avoids the issue of concurrency bugs because it doesn't really matter much if the renderer reads part of the game state before or after an update, since it will just render all over again in a few milliseconds. The combination of read-only and rapid looping means that programmers can use two threads with no trouble. However, when there are multiple threads that are reading AND writing state, there become issues. They are issues that in principle are solvable (TSL, semaphores, monitors), but do not always amount to performance gains. Making code multi-threaded will ALWAYS add overhead to the process, and often that overhead will exceed the gains from having multiple execution units. And since some things will always need to be processed serially instead of in parallel, there is a limit to what multiple cores can accomplish. That's why the most performance gains you will usually see from doubling processing cores is 50%, and sometimes you will see performance hits. That's why it is not worth shelling out cash for a quad core in the current environment.
__________________
GEEK CODE V.3.12: GCS/E d-- s: a-- C++ US+ P+ L++ E--- W+++ N+ !o? K- w-- !O M++ V? PS+ PE Y+ PGP t- 5++ X R !tv-- b+++ DI++ D+ G+ e+++ h !r*-- y?
SE4 CODE: A-- Se+++* GdY $?/++ Fr! C++* Css Sf Ai Au- M+ MpN S Ss- RV Pw- Fq-- Nd Rp+ G- Mm++ Bb@ Tcp- L+
Reply With Quote
  #2  
Old September 23rd, 2007, 10:47 PM

Raapys Raapys is offline
First Lieutenant
 
Join Date: Jan 2005
Posts: 689
Thanks: 0
Thanked 0 Times in 0 Posts
Raapys is on a distinguished road
Default Re: OT: Building a new computer...

I don't think your approach to SEV multi-threaded would work. You could have one core per AI, but that doesn't help you any because the AIs do their turns one after the other, with their decisions being made depending on the previous AI's actions that turn. The same is true with combat; you can't resolve other parts of the game while processing combat because the other parts are dependant on how each combat is resolved. You end up with cores just having to wait for other cores to finish before they can do their work.

At any rate, they're getting better and better at finding ways to thread the applications, and since they've pretty much reached the clock limit with the current base-technology, more cores is the best way to go until someone 're-invents' the computer for a more optmized and streamlined design. There's too many bottlenecks 'improvisations' in our current systems.
Reply With Quote
  #3  
Old September 23rd, 2007, 11:51 PM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Building a new computer...

First off, note that cores never wait for other cores; cores are always running, always processing instructions. The kernel task scheduler puts various processes and threads on each core dynamically, as needed for optimal load-balancing.

Abandoning the garbage sequential movement mode solves the concurrency issue nicely. If all game modes featured simultaneous movement, each AI can think at the same time, since all they are doing is giving orders. They can even do all their thinking while the human player is playing his turn... Turn resolution can still benefit somewhat from multithreading, since you could process the movement of all of an empire's ships in one thread. Have each one process one day worth of movement and wait for combat resolutions.

With 20 threads and 4 cores (a full game), the kernel task scheduler would typically have 5 of the threads process on each core (though it could really be any distribution, depending on how long each AI thread takes to finish). Each AI thread would process one day of movement, then go to sleep. After all such AI threads are sleeping, all pending combats would then be assigned their own threads, and executed in parallel. Once they are all done, the main game thread just has to wake up each of the AI threads.
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #4  
Old September 24th, 2007, 10:29 AM

Raapys Raapys is offline
First Lieutenant
 
Join Date: Jan 2005
Posts: 689
Thanks: 0
Thanked 0 Times in 0 Posts
Raapys is on a distinguished road
Default Re: OT: Building a new computer...

It'd definitely work better with simultaneous movement, that's true. However, the best approach might be something similar to how Master of Orion 3, which also uses simultaneous movement, processes turns. It basically finishes all movements for all empires, then stores all potential combats.

This way the game could just go ahead and process all empires' movements at once, using all the cores. When that was finished, it could then go ahead and split the combats between the different cores. This way, the only thing that would have to wait would be those combats dependant on the results of previous combats the same turn.
Reply With Quote
  #5  
Old September 24th, 2007, 11:38 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Building a new computer...

You can't do that without eliminating the ability to move in sectors of a system; MOO3 had a really primitive movement system, without any ability to move more than through part of a warp lane in a turn. Systems are just a generalized location, without any internal locations. This can't work for SE-style location systems, because ships can move, fight, move, fight, etc., all in one turn. You can't postpone things pending a later combat resolution, since literally hundreds or thousands of objects' movements can be affected by a single combat.
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #6  
Old December 13th, 2007, 04:00 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Building a new computer...

Yet another nail in the latest AMD architecture's coffin today...
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #7  
Old December 13th, 2007, 02:32 PM
Xrati's Avatar

Xrati Xrati is offline
First Lieutenant
 
Join Date: May 2005
Location: Outter Glazbox
Posts: 760
Thanks: 12
Thanked 4 Times in 4 Posts
Xrati is on a distinguished road
Default Re: OT: Building a new computer...

So, they're still around. They must be doing something right to continue to survive...
Reply With Quote
  #8  
Old September 25th, 2007, 04:03 AM

AstralWanderer AstralWanderer is offline
Corporal
 
Join Date: Oct 2006
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
AstralWanderer is on a distinguished road
Default Re: OT: Building a new computer...

Raapys said:
I don't think your approach to SEV multi-threaded would work. You could have one core per AI, but that doesn't help you any because the AIs do their turns one after the other, with their decisions being made depending on the previous AI's actions that turn.


You could at least in theory make AI processing multicore by splitting out the "opponent invariant" parts (aspects that don't depend on the current tactical actions of other players like research, diplomacy, production and movement in systems held by that AI exclusively) and each individual combat could be handled by a separate thread (with the main AI thread moving on to other systems pending battle completion).

Whether SEV could do this though, depends solely on the underlying code and so is a question only Aaron could likely answer.

As for more general purposes, there are plenty of situations where a second core comes into play even for single-core applications (e.g. Nvidia's graphics drivers with some of the image quality options will use it) and for on-line gaming you'd benefit from having another core for security software (firewalls, anti-virus scanners, etc) so with a dual-core application, you're already talking about quad offering real benefits. And Intel's budget quad-core Q6600 may offer "only" a 2.4GHz clock but there are plenty of reports about the G0 stepping overclocking to 3.0Ghz+ with air cooling alone.

Finally, it seems that even eight cores can be made use of by some games - for example Lost Planet.
Reply With Quote
  #9  
Old September 25th, 2007, 11:37 AM
Fyron's Avatar

Fyron Fyron is offline
Shrapnel Fanatic
 
Join Date: Jul 2001
Location: Southern CA, USA
Posts: 18,394
Thanks: 0
Thanked 12 Times in 10 Posts
Fyron is an unknown quantity at this point
Default Re: OT: Building a new computer...

Firewalls and resident AV engines use almost 0% of CPU cycles... unless you are running some sort of Norton bloatware or something?
__________________
It's not whether you win or lose that counts: it's how much pain you inflict along the way.
--- SpaceEmpires.net --- RSS --- SEnet ModWorks --- SEIV Modding 101 Tutorial
--- Join us in the #SpaceEmpires IRC channel on the Freenode IRC network.
--- Due to restrictively low sig limits, you must visit this link to view the rest of my signature.
Reply With Quote
  #10  
Old September 25th, 2007, 11:50 PM

AstralWanderer AstralWanderer is offline
Corporal
 
Join Date: Oct 2006
Posts: 131
Thanks: 0
Thanked 0 Times in 0 Posts
AstralWanderer is on a distinguished road
Default Re: OT: Building a new computer...

Fyron said:
Firewalls and resident AV engines use almost 0% of CPU cycles... unless you are running some sort of Norton bloatware or something?


Firewall CPU usage will depend on the amount of network traffic it has to process - some filesharing programs can open hundreds or even thousands of connections resulting in significant CPU usage on some systems. For AVs, it depends on how much they have to scan - those with web traffic scanners can slow throughput if they don't have enough CPU.

Of course there are examples of both AVs and firewalls that minimise CPU usage, but in many cases by performing less thorough checks (poorer unpacking support for AVs, weaker leaktest performance for firewalls).
Reply With Quote
Reply

Bookmarks


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is On

Forum Jump


All times are GMT -4. The time now is 05:43 AM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©1999 - 2025, Shrapnel Games, Inc. - All Rights Reserved.