Jump to content
  • Advertisement
Sign in to follow this  
suliman

Multiple cores on c++? Automatically used?

This topic is 2989 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I just got my first multi-core computer (yey!). I code games in c++ for windows using a directx 9 engine. Is processes automatically send to different cores? Or if i dont do anything will my games only use 1 core even its a quadcore for example? Thanks Erik

Share this post


Link to post
Share on other sites
Advertisement
The OS can and will allocate processes and threads to different cores as it desires. That basic distribution is done automatically. This does not however mean that suddenly your program distributes work in parallel properly. A single process, single threaded program doing all the work will force all the work on one core. There's nothing the OS can do further.

So it's your task to set things up properly.

Share this post


Link to post
Share on other sites
Quote:
Original post by suliman
so if i just use a win32 application setup in visual studio probably only one core is used?

E
Yes (Mostly). You'll need to create multiple threads to use multiple cores.

The OS can still schedule your app (It's main thread at least) to run on any core, but it'll only run on one at a time.

Share this post


Link to post
Share on other sites
Quote:

so if i just use a win32 application setup in visual studio probably only one core is used?

By your app? Not probably. Definitely. The template projects don't do anything with threading, at least not in any fashion that would noticeably benefit you. You've got to build it all yourself (or use a library to help, I suppose).

Share this post


Link to post
Share on other sites
Quote:
Original post by suliman
so if i just use a win32 application setup in visual studio probably only one core is used?

E


Every OS which supports multithreading exposes its own API to split work into threads. For c++ I've found boost::thread to be quite simple to work with, and it is cross platform too.

Other languages (.net, java, most of the new one actually) already have classes/functions in their standard library.

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!