42 lines · plain
1.. _omp170:2 3OpenMP runtime call <call> deduplicated. [OMP170]4====================================================================5 6This optimization remark indicates that a call to an OpenMP runtime call was7replaced with the result of an existing one. This occurs when the compiler knows8that the result of a runtime call is immutable. Removing duplicate calls is done9by replacing all calls to that function with the result of the first call. This10cannot be done automatically by the compiler because the implementations of the11OpenMP runtime calls live in a separate library the compiler cannot see.12 13Example14-------15 16This optimization will trigger for known OpenMP runtime calls whose return value17will not change.18 19.. code-block:: c++20 21 void foo(int N) {22 double *A = malloc(N * omp_get_thread_limit());23 double *B = malloc(N * omp_get_thread_limit());24 25 #pragma omp parallel26 work(&A[omp_get_thread_num() * N]);27 #pragma omp parallel28 work(&B[omp_get_thread_num() * N]);29 }30 31.. code-block:: console32 33 $ clang -fopenmp -O2 -Rpass=openmp-opt omp170.c34 ompi170.c:2:26: remark: OpenMP runtime call omp_get_thread_limit deduplicated. [OMP170]35 double *A = malloc(N * omp_get_thread_limit());36 ^37 38Diagnostic Scope39----------------40 41OpenMP optimization remark.42