Intel® Advisor User Guide

ID 766448
Date 3/22/2024
Public

A newer version of this document is available. Customers should click here to go to the newest version.

Document Table of Contents

Intel® oneAPI Threading Building Blocks (oneTBB) Mutexes

With Intel® oneAPI Threading Building Blocks (oneTBB) , you can associate a mutex with a shared object to enforce mutually exclusive access to that object. A mutex is either locked or unlocked. For a thread to safely access the object:

  • The thread acquires a lock on the mutex.

  • The thread accesses the associated shared object.

  • The thread releases its lock on the mutex.

When a mutex is locked, if another thread tries to also acquire a lock on it, this second thread is stalled until the first thread releases its lock on the mutex. This functionality provided by a mutex is exactly the semantic function intended by the Intel Advisor annotations ANNOTATE_LOCK_ACQUIRE() and ANNOTATE_LOCK_RELEASE().

With oneTBB , the annotation lock address becomes the mutex object. The ANNOTATE_LOCK_ACQUIRE() and ANNOTATE_LOCK_RELEASE() annotations become operations on this mutex.

oneTBB provides several classes for locking, each with different properties. For more information, refer to the oneTBB documentation. If you are not sure what type of a mutex is most appropriate, consider using tbb::mutex as your initial choice.