blob: 8b7b999d85369915eae58b6012e133fa5f924e9b [file] [log] [blame]
Joseph Huber16164072021-07-14 21:04:541Rewriting generic-mode kernel with a customized state machine. [OMP131]
2=======================================================================
3
4.. _omp131:
5
6This optimization remark indicates that a generic-mode kernel on the device was
7specialized for the given target region. When offloading in generic-mode, a
8state machine is required to schedule the work between the parallel worker
9threads. This optimization specializes the state machine in cases where there is
Joseph Huberdead50d2021-07-26 20:01:4110a known number of parallel regions inside the kernel. A much simpler state
11machine can be used if it is known that there is no nested parallelism and the
12number of regions to schedule is a static amount.
Joseph Huber16164072021-07-14 21:04:5413
14Examples
15--------
16
17This optimization should occur on any generic-mode kernel that has visibility on
Joseph Huberdead50d2021-07-26 20:01:4118all parallel regions, but cannot be moved to SPMD-mode and has no nested
19parallelism.
Joseph Huber16164072021-07-14 21:04:5420
21.. code-block:: c++
22
23 #pragma omp declare target
24 int TID;
25 #pragma omp end declare target
26
27 void foo() {
28 #pragma omp target
29 {
30 TID = omp_get_thread_num();
31 #pragma omp parallel
32 {
33 work();
34 }
35 }
36 }
37
38.. code-block:: console
39
40 $ clang++ -fopenmp -fopenmp-targets=nvptx64 -O2 -Rpass=openmp-opt omp131.cpp
41 omp131.cpp:8:1: remark: Rewriting generic-mode kernel with a customized state machine. [OMP131]
42 #pragma omp target
43 ^
44
45Diagnostic Scope
46----------------
47
48OpenMP target offloading optimization remark.