SFML community forums

Help => General => Topic started by: tom64 on March 27, 2013, 06:26:31 am

Title: Parallel processing?
Post by: tom64 on March 27, 2013, 06:26:31 am
Does anyone know of an easy way to get the computer to do something like: 4 completely separate tasks (assuming you have 4 cores), for each core?

i.e.

core_1( *task_1() )
core_2( *task_2() )
core_3( *task_3() )
core_4( *task_4() )

I know with parallel processing there are usually problems like collisions, but what if you give the different cores completely separate tasks with separate memory that won't collide?

Sincerely,
Tom
Title: Re: Parallel processing?
Post by: Laurent on March 27, 2013, 08:13:26 am
If each task is completely separated from each other, then just run each one in a its own thread. If you want to make sure that each thread runs on a separate core, you can heack a little with OS functions, but that shouldn't be necessary, the OS is supposed to dispatch threads optimally.
Title: Re: Parallel processing?
Post by: eXpl0it3r on March 27, 2013, 08:24:56 am
sf::Thread (http://www.sfml-dev.org/documentation/2.0/classsf_1_1Thread.php) or std::thread (http://en.cppreference.com/w/cpp/thread/thread). ;)

Keep in mind though that parallel programming is not at all a trivial task, but if things are  completely separated, then there shouldn't be many problems.