Jump to content
  • Advertisement
Sign in to follow this  
pulpfist

Programming multiple cpu's

This topic is 4872 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

There has been a lot of talk about PC's with multiple cpu's lately. I was wondering if it is possible to get access to different cpu's in a c/c++ program? (Assuming a windows platform is used) And if so, would you have to take care of critical sections and the like yourself?

Share this post


Link to post
Share on other sites
Advertisement
Quote:
Original post by pulpfist

There has been a lot of talk about PC's with multiple cpu's lately.

I was wondering if it is possible to get access to different cpu's in a c/c++ program?
And if so, would you have to take care of critical sections and the like yourself?
Most new age processors have multiple processors already built inside, for intel this is called "hyper threading", for AMD I think the name is "dual-core". Usually there is a "affinity" applied that tells where a process should run from.

Might want to read more on SMP :)

Share this post


Link to post
Share on other sites
Quote:
Original post by EmperiorRune
Quote:
Original post by pulpfist

There has been a lot of talk about PC's with multiple cpu's lately.

I was wondering if it is possible to get access to different cpu's in a c/c++ program?
And if so, would you have to take care of critical sections and the like yourself?
Most new age processors have multiple processors already built inside, for intel this is called "hyper threading", I don't know what they call it for the AMD counterpart. Usually there is a "affinity" applied that tells where a process should run from.


Hyper-Threading is *not* multiple processors. It is Intel's implementation of simultaneous multithreading and happens on a single processor.

As for the OP's question, since you mentioned windows, you can use the Processes and Threads and Synchronization APIs.


jfl.

Share this post


Link to post
Share on other sites
As far as I know you won't be able to specify the processor to be used with the Windows Threading API. You just call CreateThread and Windows will decide on which CPU to create the thread.

There is however an open standard for multi processing in C/C++ if your compiler supports it, OpenMP
Visual Studio .NET 2005 supports OpenMP.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
Quote:
Original post by pulpfist

There has been a lot of talk about PC's with multiple cpu's lately.

I was wondering if it is possible to get access to different cpu's in a c/c++ program? (Assuming a windows platform is used)
And if so, would you have to take care of critical sections and the like yourself?



One thing I saw recently (in a Book) was something about synchronizing/lock mechanisms working differently across SMP processors. There may be extra wait time for the shared memory/caches to stabalize/settle (theres a term I cant remember for this). The book talked about the 'spinwait' being more useful/efficient (a lock call sitting and waiting for a while for a memory based lock to clear instead of doing a thread switch immediately -- something that is mostly useless on a thread run uniprocessor).

From what I have heard (Im looking into using multiprocessors in future also) that threads from a multi-threaded C program will run on different CPUs and you are able to designate which one each thread if you want.

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!