how to use quad core CPU in application

Mayank picture Mayank · Mar 30, 2010 · Viewed 17.8k times · Source

For using all the cores of a quad core processor what do I need to change in my code is it about adding support of multi threading or is it which is taken care by OS itself. I am having FreeBSD and language I am using is C++. I want to give complete CPU cycles to my application at least 90%.

Answer

sbi picture sbi · Mar 30, 2010

You need some form of parallelism. Multi-threading or multi-processing would be fine.

Usually, multiple threads are easier to handle (since they can access shared data) than multiple processes. However, usually, multiple threads are harder to handle (since they access shared data) than multiple processes. And, yes, I wrote this deliberately.

If you have a SIMD scenario, Ninefingers' suggestion to look at OpenMP is also very good. (If you don't know what SIMD means, see Ninefingers' helpful comment below.)