Multi-thread (ofThread) and multi-core (on Mac)

Please tell me if these two are right:
(when running oF projects on Mac).

  1. For multi-core processing, the codes must be multi-threaded.
  2. Multi-threading do not always mean multi-core processing.

2 yes . In newest iOS and OSX is implemented in hight level API, and all routine work do in OS level, that divide process to cores.

  1. In OF we do it manually by use ofThread objects (we count number of cores and divide tasks between themes) - it is more and more difficult

Thanks Shiny.
BTW, what do you mean by “themes”?

===
And maybe my questions are a bit vague.
Here again:

  1. For utilizing the power of a multi-core processor, I must use ofThread. Otherwise, all tasks will be done on just one core. Is this right?

  2. But even if I use ofThread, I can’t be sure that each task will be done by separate core. Is this right?

1 Like

I mean “between cores”, this is the principle of multithreading as I know.
The second approach is use the call back functions. We send a function as argument in function.

Hi,

I’m not quite sure how things get scheduled for processing on the CPU, by the OS or maybe lower level, but if you use an ofThread the computations that you do in the threadedFunction() will be run in parallel.

You can have more threads than you have cores of course, so exactly where it’s running is up to the OS, but if you are looking to get the most out of your CPU, moving heavy computations onto ofThread based objects is a great way to get more speed. There is some extra work needed to share the data between threads, but for stuff like processing input from cameras it’s great.

Keep in mind you can’t do any OpenGL stuff from an ofThread, this is an OpenGL limitation.

2 Likes

Now it’s very clear.
Thanks a lot!