Multithreaded programming

Started by
23 comments, last by Khatharr 11 years, 1 month ago

What multithreading library would you recommend for C++? POSIX, boost?

Learn them all (one at a time) and also WINAPI threads. They all do more or less the same thing. You'll probably want to prefer C++ threads, though, since it'll end up being the most portable. A typical thread lib doesn't really have an overwhelming number of components for you to learn. The problem is learning to use them in a sane fashion.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.
Advertisement

If the tasks you do in parallell has no dependencies on each other, you might get close to NumberOfThreads times the performance, but a game engine states is by its nature quite dependent on each other, having lots of requirements on what needs to be done before what, and is very tricky to multithread in an efficient way.

Slight nitpick: The speedup potential of parallel threads approaches the number of cores, not the number of threads.

Annoying slight nitpick of nitpick: If task is CPU-bound.

If the tasks you do in parallell has no dependencies on each other, you might get close to NumberOfThreads times the performance, but a game engine states is by its nature quite dependent on each other, having lots of requirements on what needs to be done before what, and is very tricky to multithread in an efficient way.

Slight nitpick: The speedup potential of parallel threads approaches the number of cores, not the number of threads.

Annoying slight nitpick of nitpick: If task is CPU-bound.

Supper annoying slight nitpick: or unless the task is superlinear, in which the speedup exceeds the number of cores.



If the tasks you do in parallell has no dependencies on each other, you might get close to NumberOfThreads times the performance, but a game engine states is by its nature quite dependent on each other, having lots of requirements on what needs to be done before what, and is very tricky to multithread in an efficient way.

Slight nitpick: The speedup potential of parallel threads approaches the number of cores, not the number of threads.
Annoying slight nitpick of nitpick: If task is CPU-bound.
Supper annoying slight nitpick: or unless the task is superlinear, in which the speedup exceeds the number of cores.

Nitpick... annoying, etc: hyper-threading can give a speed up beyond the number of cores, due to hiding latencies.
Natpick: Hyperspatial computing can provide the results of concurrent operations prior to program start.
void hurrrrrrrr() {__asm sub [ebp+4],5;}

There are ten kinds of people in this world: those who understand binary and those who don't.

This topic is closed to new replies.

Advertisement