Executing a particular function on specified core using openMP
Is it possible to fix one function to run on a particular core using OpenMP ?
For example: I have two functions namely : Foo1 and Foo2
And my computer(Linux OS) has two cores: core0 and core1.
So, How can I run application Foo1 always on core0 and Foo2 always on core1 simultaneously?
I am using C++ for coding.
It sounds like you want to
- set the number of OpenMP threads to 2 (omp_set_num_threads(2)), and
- in a parallel region, check the thread ID and call Foo1 or Foo2 accordingly.
How to do these things is described in the OpenMP documentation.
An alternative approach would be to create two openMP tasks, each running one of your functions.