[Idea] Multi-threading for multi-core processors

Discuss the future of Warzone 2100 with us.
User avatar
MechWarrior001
Greenhorn
Posts: 7
Joined: 15 May 2010, 08:09
Location: Chico, CA

[Idea] Multi-threading for multi-core processors

Post by MechWarrior001 »

Hey, new here. I got this idea for Warzone. What if we/someone-else-who's-willing-until-I-improve-my-C-skills re-thread Warzone to run on multiple cores. For example:

CORE 0 - Critical Game code and Player.
CORE 1 - AI player 1
CORE 2 - AI player 2
CORE 3 - AI player 3

and etc. If I'm understanding the concept correctly, each core will be dedicated on a specific component of game, allowing main game/critical game code to have more processor time on CORE 0, while each AI player will have also have it's own dedicated CPU core, possibly sharing if less cores than CPU players. Example:

CORE 0 - Main/Critical code, Player
CORE 1 - AI Player 1 & 2
CORE 2 - AI Player 3 & 4
CORE 3 - AI Player 5 & 6

What do you think?

P.S. did I post in the right forum?
Per
Warzone 2100 Team Member
Warzone 2100 Team Member
Posts: 3780
Joined: 03 Aug 2006, 19:39

Re: [Idea] Multi-threading for multi-core processors

Post by Per »

It is something I am thinking of doing one day, but it is not so simple, since you need to be very careful in the design to avoid race conditions in the code.

Note that the game can already utilize two cores, if you have that, since we have a separate thread doing path-finding calculations.
User avatar
MechWarrior001
Greenhorn
Posts: 7
Joined: 15 May 2010, 08:09
Location: Chico, CA

Re: [Idea] Multi-threading for multi-core processors

Post by MechWarrior001 »

What do you mean by race conditions? I'm still new to C so I'm not sure if that's a function or not.
Safety0ff
Trained
Trained
Posts: 397
Joined: 18 Jul 2009, 23:23

Re: [Idea] Multi-threading for multi-core processors

Post by Safety0ff »

MechWarrior001 wrote:What do you mean by race conditions? I'm still new to C so I'm not sure if that's a function or not.
Here.
User avatar
Tenoh
Trained
Trained
Posts: 359
Joined: 18 Nov 2008, 15:06

Re: [Idea] Multi-threading for multi-core processors

Post by Tenoh »

And is there any other way we could use the cores? sadly i only got 2 T_T.
"No, you don't want to buy this Sh[beep]t from me. It shoots sideways, it was built by retard zombies in some f[beep]king outreach program." HL:G
User avatar
MechWarrior001
Greenhorn
Posts: 7
Joined: 15 May 2010, 08:09
Location: Chico, CA

Re: [Idea] Multi-threading for multi-core processors

Post by MechWarrior001 »

Well assigning AI to each core doesn't necessarily limit the total AI per match based on the amount of cores you have, we could simply just assign all AI players to CPU 1 and player+main thread to CPU 0, anything above CPU 1 will have a dedicated AI player.

For example:

Dual Core Config
Game - CPU 0
AI - CPU 1

MultiCore Config
Game - CPU 0
AI 1 - CPU 1
AI 2 - CPU 2
AI 3 - CPU 3

and etc.
User avatar
MaNGusT
Art contributor
Posts: 1154
Joined: 22 Sep 2006, 10:31
Location: Russia

Re: [Idea] Multi-threading for multi-core processors

Post by MaNGusT »

CORE 0 - Main/Critical code, Player
CORE 1 - path-finding calculations
CORE 2 - AI Players, scripts, events, triggers
CORE 3 - something else (mb net code)

I think it should work like - at launch the game detects how much cores system has, then applies/loads prepared "preset" for 2 or more cores.
Image
User avatar
MechWarrior001
Greenhorn
Posts: 7
Joined: 15 May 2010, 08:09
Location: Chico, CA

Re: [Idea] Multi-threading for multi-core processors

Post by MechWarrior001 »

It might be worth adding the ability to manually assign threads & calculations to certain cores.

What about CUDA and OpenCL? Could Warzone 2100 benefit from either of those?
User avatar
Zarel
Elite
Elite
Posts: 5770
Joined: 03 Jan 2008, 23:35
Location: Minnesota, USA

Re: [Idea] Multi-threading for multi-core processors

Post by Zarel »

MechWarrior001 wrote:It might be worth adding the ability to manually assign threads & calculations to certain cores.

What about CUDA and OpenCL? Could Warzone 2100 benefit from either of those?
CUDA is proprietary Nvidia technology. It's not designed for a game designed to run on a variety of platforms.
User avatar
Tenoh
Trained
Trained
Posts: 359
Joined: 18 Nov 2008, 15:06

Re: [Idea] Multi-threading for multi-core processors

Post by Tenoh »

Hmm.. my second core is always used by win7 and always at 27 or 30% and first core is for program use.
"No, you don't want to buy this Sh[beep]t from me. It shoots sideways, it was built by retard zombies in some f[beep]king outreach program." HL:G