+.. _omp110:
+
Moving globalized variable to the stack. [OMP110]
=================================================
-.. _omp110:
-
This optimization remark indicates that a globalized variable was moved back to
thread-local stack memory on the device. This occurs when the optimization pass
-can determine that a globalized variable is not possibly be shared between
-threads and globalization was unnecessary. Using stack memory is the best-case
-scenario for data globalization as the variable can now be stored in fast
-register files on the device. This optimization requires full visibility of each
-variable.
+can determine that a globalized variable cannot possibly be shared between
+threads and globalization was ultimately unnecessary. Using stack memory is the
+best-case scenario for data globalization as the variable can now be stored in
+fast register files on the device. This optimization requires full visibility of
+each variable.
Globalization typically occurs when a pointer to a thread-local variable escapes
the current scope. The compiler needs to be pessimistic and assume that the
.. code-block:: c++
void use(int *x) { }
-
+
void foo() {
int x;
use(&x);
}
-
+
int main() {
#pragma omp target parallel
foo();
.. code-block:: c++
#include <complex>
-
+
using complex = std::complex<double>;
-
+
void zaxpy(complex *X, complex *Y, const complex D, int N) {
#pragma omp target teams distribute parallel for firstprivate(D)
for (int i = 0; i < N; ++i)