APIs for Custom Synchronization
Using User-Defined Synchronization APIs in Your Code
Use This in C/C++ Code
Use This in Fortran Code
To Do This
Intel Inspectorthat the code received a signal on the specified synchronization object.
Intel Inspectorthat the code is about to send a signal on the specified synchronization object.
Intel Inspectorthat the synchronization object will not be used again, so the
Intel Inspectorcan dispose of bookkeeping information associated with this object.
API Usage Tips
- Insert anacquiredAPI immediatelyafteryour code stops waiting for a synchronization object.
- Insert areleasingAPI immediatelybeforethe code signals that it no longer holds a synchronization object.
Usage Example: User-Defined Synchronized Critical Section
- TheacquiredAPI is placed immediately after the code obtains the user lock.
- ThereleasingAPI is placed before the code releases the user lock. This ensures another thread does not call theacquiredAPI before theIntel Inspectorrealizes this thread has released the lock.
Usage Example: User-Level Synchronized Barrier
- There are two synchronization objects in this barrier code. Thecounterobject is used to do a gather-like signaling from all the threads to the final thread indicating that each thread has entered the barrier. Once the last thread hits the barrier, it uses theteamflagobject to signal all the other threads that they may proceed.
- As each thread enters the barrier, it calls thereleasingAPI to tell theIntel Inspectorit is about to signal the last thread by incrementingcounter.
- The last thread to enter the barrier calls theacquiredAPI to tell theIntel Inspectorit was successfully signaled by all the other threads.
- The last thread to enter the barrier then calls thereleasingAPI to tell theIntel Inspectorit is going to signal the barrier completion to all the other threads by settingteamflag.
- Finally, before leaving the barrier, each thread calls theacquiredAPI to tell theIntel Inspectorit successfully received the end-of-barrier signal.