Bay 12 Games Forum

Please login or register.

Login with username, password and session length
Advanced search  
Pages: 1 [2]

Author Topic: Multithreading Workshop  (Read 4029 times)

numerobis

  • Bay Watcher
    • View Profile
Re: Multithreading Workshop
« Reply #15 on: September 14, 2008, 02:17:15 pm »

I feel like OpenMP grew out of HPF (high performance fortran).  So that would be why olemars finds it so familiar.

Loop parallel algorithms are nice, but sadly, that's not usually what we end up with (when was the last time you wrote a loop that iterated over a few thousand things, all of them independent).  The likeliest things to fit the framework would be flows, temperature, and weather.
Logged

olemars

  • Bay Watcher
    • View Profile
Re: Multithreading Workshop
« Reply #16 on: September 14, 2008, 03:52:05 pm »

I feel like OpenMP grew out of HPF (high performance fortran).  So that would be why olemars finds it so familiar.

Loop parallel algorithms are nice, but sadly, that's not usually what we end up with (when was the last time you wrote a loop that iterated over a few thousand things, all of them independent).  The likeliest things to fit the framework would be flows, temperature, and weather.

It indeed works well on lattice models of fluid flows used for scientific simulations. But then again, how accurate do the flows need to be in a game like this? I would think there is some simpler way to fake something flowlike in a tile-based world.
Logged

numerobis

  • Bay Watcher
    • View Profile
Re: Multithreading Workshop
« Reply #17 on: September 14, 2008, 04:31:32 pm »

Toady is essentially using a very simple finite difference method for the flows.  He follows standard practice and calls it a cellular automaton; the language and the way of thinking differ, but the math is basically identical.

Basically, every tile computes "how much water will I have next by pushing water to/from my neighbours."  That's trivial to parallelize.  Of course there's no point computing this on tiles that won't change, so you have to only run "every tile" on those that may change.  There are some other complications, which all make it less trivial to parallelize, but I'd still expect you could openMP this stuff.  I'm not clear whether Amdahl's Law suggests this is a good idea or a red herring, and I can't be clear since I can't profile Toady's code.
Logged

isitanos

  • Bay Watcher
  • Seasonal river flood nostalgic
    • View Profile
Re: Multithreading Workshop
« Reply #18 on: September 16, 2008, 12:06:32 pm »

Wow Dreiche, that's a very well researched and presented thread. One thing that you didn't mention is that instead of creating threads you can create separate processes, which can communicate through pipes or other means. I'm currently learning to use the fork() command in Unix/Linux programming: it's pretty interesting since after the fork() instruction your code is actually executed by two separate processes, and you can put checks in the code to identify the father or son process and act accordingly.

Processes seem easier to work with, and less error-prone if they communicate through standard input/output, but it's slower and more memory-intensive than threads.
Logged

isitanos

  • Bay Watcher
  • Seasonal river flood nostalgic
    • View Profile
Re: Multithreading Workshop
« Reply #19 on: September 16, 2008, 12:16:19 pm »

It might help Toady if someone spent the time applying these changes to Battle Champions or Kobold Quest, so he could see it in action.

I really enjoy the interplay between the community's programmers and The Programmer himself. I think his idea to release a portion of DF code in the form of Battle Champions was a great idea. Thanks for posting all this!

Battle Champions? Never heard about that, and a forum and google search yield nothing. Is it sitting in some very obscure corner of the Bay 12 Website?
Logged

korora

  • Bay Watcher
    • View Profile
Re: Multithreading Workshop
« Reply #20 on: September 16, 2008, 12:26:17 pm »

It's "Battle Champs", and it lives in the Announcement thread for 40c.
Logged
DFPaint, a cross-platform 'screenbuilder' utility

Maggarg - Eater of chicke

  • Bay Watcher
  • His Maleficent Magnificence of Nur
    • View Profile
Re: Multithreading Workshop
« Reply #21 on: September 17, 2008, 01:25:06 pm »

Oh no, coding!
I was never good at languages.
Logged
...I keep searching for my family's raw files, for modding them.
Pages: 1 [2]