Joseph Huber | 1616407 | 2021-07-14 21:04:54 | [diff] [blame] | 1 | Rewriting generic-mode kernel with a customized state machine. [OMP131] |
| 2 | ======================================================================= |
| 3 | |
| 4 | .. _omp131: |
| 5 | |
| 6 | This optimization remark indicates that a generic-mode kernel on the device was |
| 7 | specialized for the given target region. When offloading in generic-mode, a |
| 8 | state machine is required to schedule the work between the parallel worker |
| 9 | threads. This optimization specializes the state machine in cases where there is |
Joseph Huber | dead50d | 2021-07-26 20:01:41 | [diff] [blame] | 10 | a known number of parallel regions inside the kernel. A much simpler state |
| 11 | machine can be used if it is known that there is no nested parallelism and the |
| 12 | number of regions to schedule is a static amount. |
Joseph Huber | 1616407 | 2021-07-14 21:04:54 | [diff] [blame] | 13 | |
| 14 | Examples |
| 15 | -------- |
| 16 | |
| 17 | This optimization should occur on any generic-mode kernel that has visibility on |
Joseph Huber | dead50d | 2021-07-26 20:01:41 | [diff] [blame] | 18 | all parallel regions, but cannot be moved to SPMD-mode and has no nested |
| 19 | parallelism. |
Joseph Huber | 1616407 | 2021-07-14 21:04:54 | [diff] [blame] | 20 | |
| 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 | |
| 45 | Diagnostic Scope |
| 46 | ---------------- |
| 47 | |
| 48 | OpenMP target offloading optimization remark. |