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.

Please help!!

Answers


It sounds like you want to

  1. set the number of OpenMP threads to 2 (omp_set_num_threads(2)), and
  2. 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.


Need Your Help

When clicking on Datagrid ColumnHeader - How is sorting taking place? And how to override it?

c# wpf sorting .net-4.0 datagrid

When clicking on a DataGrid ColumnHeader, the datagrid would automatically sort the data, if the underlying dataSource is a CollectionView.

Why does this instruction not work?

python google-app-engine

Hi I'm trying to count using keys only and get an error message when using this line

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.