TensorNetowork
TensorNetowork

Reputation: 13

Hybrid Parallelism: MPI and TBB

In TBB, the task_scheduler_init () method, which is often (and should be?) invoked internally, is a deliberate design decision.

However, if we mix TBB and MPI, is it guaranteed to be thread-safe without controlling the number of threads of each MPI process? For example, say we have 7 cores (with no hyper-threading) and 2 MPI processes. If each process spawns an individual TBB task using 4 threads simultaneously, then there is a conflict which might cause the program to crash at runtime.

I'm a newbie of TBB. Looking forward to your comments and suggestions!

Upvotes: 1

Views: 878

Answers (2)

Gilles Gouaillardet
Gilles Gouaillardet

Reputation: 8395

Generally speaking, this is a two steps tango

  1. MPI binds each task to some resources
  2. the thread runtime (TBB, same things would apply to OpenMP) is generally smart enough to bind threads within the previously provided resources.

bottom line, if MPI binds its tasks to non overlapping resources, then there should be no conflict caused by the TBB runtime.

a typical scenario is to run 2 MPI tasks with 8 OpenMP threads per task on a dual socket octo core box. as long as MPI binds a task to a socket, and the OpenMP runtime is told to bind the threads to cores, performance will be optimal.

Upvotes: 2

Alex
Alex

Reputation: 632

From Intel TBB runtime perspective it does not matter if it is a MPI process or not. So if you have two processes you will have two independent instances of Intel TBB runtime. I am not sure that I understand the question related to thread-safeness but it should work correctly. However, you may have oversubscription that can lead to performance issues.

In addition, you should check the MPI implementation documentation if you use MPI routines concurrently (from multiple threads) because it can cause some issues.

Upvotes: 2

Related Questions