-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathNativeRuntime.tex
20 lines (11 loc) · 2.68 KB
/
NativeRuntime.tex
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
\section{Native Runtime}
The native runtime implements the following OpenMP 4.5 routines.
\begin{itemize}
\item \code{void omp_set_default_device(int device_num)} call sets the default device ID in the ICV of the encountering task.
\item \code{int omp_get_default_device(void)} call retrieves the default device ID in the ICV of the encountering task.
\item \code{int omp_get_num_teams(void)} returns the number of teams for target teams construct executing on the host.
\item \code{int omp_get_team_num(void)} returns the team number associated with the encountering task for target teams construct executing on the host.
\end{itemize}
Several target constructs have \code{nowait} and \code{depend} clauses. These clauses enable asynchronous execution and at the same time enforce the required data dependences. These dependences can be handled by the native runtime like any other dependences; however, some devices may enforce dependences between target tasks more efficiently. The offloading infrastructure supports offloading the enforcement of these dependences directly to the devices. Native runtimes are not forced to use this infrastructure, as they can always elect to enforce dependences natively.
When electing to offload the enforcement of dependences among target tasks, a native runtime will need to add two data fields to their target-task data-structures: first, a field that contains the device ID associated with the target task; and second, a field that contains a reference to a completion synchronization event associated with the completion of the target task. This event is an abstract data type, whose content is specific to a given device type. A native runtime also communicate to the offloading infrastructure. This is accomplished with callback functions that enable the offloading infrastructure to instruct the native runtime that a given target task has completed. This callback enables a native runtime to clean up the dependence data-structure of the completed target task, and to activate other host tasks that may be dependent on the completion of that target task.
An overview of the flow of operations is as follows. A native runtime obtains a reference to an synchronization event when launching an asynchronous target task via an asynchronous \code{libomptarget.o} interface call. When handling dependences for a new target task B, if the native runtime detects that B is dependent on another target task, say A, and that this specific dependences (A $\rightarrow$ B) can be handled by their respective devices, then the native runtime will provide the synchronization event associated with the completion of A to the asynchronous \code{libomptarget.o} interface call that launches B.