Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: CPU Optimizations  (Read 872 times)

William

  • Bay Watcher
    • View Profile
CPU Optimizations
« on: February 13, 2008, 04:24:00 pm »

I'm just wondering if you could include CPU optimizations such as SSE2, SSE, MMX, etc. to speed up game processing. While it's not the most important thing to do I think it may increase the frame rates for many people play Dwarf Fortress. It could break the game or something, or it might not even be possible, but would be something I'd like and I don't think it'd require any additional programming.
Logged

Ihlosi

  • Bay Watcher
    • View Profile
Re: CPU Optimizations
« Reply #1 on: February 13, 2008, 05:37:00 pm »

quote:
I'm just wondering if you could include CPU optimizations such as SSE2, SSE, MMX, etc. to speed up game processing.

I would guess not. These extensions are mainly for signal processing/multimedia stuff, which I would assume DF does very, very little if any at all.

One thing that may speed up the game would probably be multithreading (thereby making use of todays multi-core CPUs), but I can say as a programmer myself that getting a multithreaded app to work right, and debugging it, is orders of magnitude more complex than dealing with a single-threaded program. Then again, DF would probably lend itself quite well to multithreading (several threads could compute the new state for different parts of the play area, and only the tiles connecting the parts would require special treatment).

Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: CPU Optimizations
« Reply #2 on: February 13, 2008, 06:26:00 pm »

Actually, I think that in terms of multi-threading, the things that get "split off" as it were would be Flows, Temperature, and Weather.  It doesn't matter too much if it's out of sync (you could only tell with flows, first off (they'd flow REALLY fast or REALLY slow compaired to the rest of the fort before you notice issues), and second by doing so you'd move the most CPU intensive tasks off of the main game thread making both run faster).

Weather would just give updates as it happens (being kept in line with a low frequency "once a season" type tick so that if one side is running slower the other side can compensate).
Temperature would be the same way, the tick being more often (once a day?).
Flows would have to be kept in check almost every frame, though.

The hard part about coding is being able to slow down one side while the other catches up.  But if Weather, Temp, and Flows do run faster than the main game, it's easier: main game requests an update, setting a flag, [flows|weather|temp] having been already calculated sends the data and resets the flag.  Seeing the flag reset it calculates new flows.

Logged

numerobis

  • Bay Watcher
    • View Profile
Re: CPU Optimizations
« Reply #3 on: February 13, 2008, 07:00:00 pm »

Weather is pretty independent of the fort, far as I know.  Flows are very much not, so you need tight integration there; but you could probably parallelize the flow calculation quite well.  You might be able to parallelize the dwarves' path planning or thought processes, but there's a fair chance that it would require a lot of recoding to do so.

But none of this is easy.  In fact, one could say it's extremely hard.  Not only that, the speed advantage on just a 2- or 4-core machine would be pretty slight.

Logged

numerobis

  • Bay Watcher
    • View Profile
Re: CPU Optimizations
« Reply #4 on: February 13, 2008, 07:03:00 pm »

quote:
Originally posted by William:
<STRONG>I'm just wondering if you could include CPU optimizations such as SSE2, SSE, MMX, etc... I don't think it'd require any additional programming.</STRONG>

Say what?  Do you mean "please compile with optimization on rather than off"?  I'm hoping that's already done.  Otherwise, coding stuff up to use vectorized operations is rather non-trivial, although tools like Shark (with Apple's Xcode) make it a bit easier.

Logged

Draco18s

  • Bay Watcher
    • View Profile
Re: CPU Optimizations
« Reply #5 on: February 13, 2008, 11:09:00 pm »

quote:
Originally posted by benoit.hudson:
<STRONG>Weather is pretty independent of the fort, far as I know.</STRONG>
 

Thus makes a good candidate for a separate thread.

quote:
<STRONG>Flows are very much not, so you need tight integration there; but you could probably parallelize the flow calculation quite well.  You might be able to parallelize the dwarves' path planning or thought processes, but there's a fair chance that it would require a lot of recoding to do so.

But none of this is easy.  In fact, one could say it's extremely hard.  Not only that, the speed advantage on just a 2- or 4-core machine would be pretty slight.</STRONG>


Oh, yes, it'd still be hard, but would be easier in comparison than other things.

Logged