SFML community forums
Help => General => Topic started 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
-
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.
-
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.