[flang-commits] [flang] [Flang][MLIR][OpenMP] Create a deferred declare target marking process for Bridge.cpp (PR #78502)
Sergio Afonso via flang-commits
flang-commits at lists.llvm.org
Thu Feb 22 03:42:08 PST 2024
================
@@ -0,0 +1,124 @@
+<!--===- docs/OpenMP-declare-target.md
+
+ Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
+ See https://llvm.org/LICENSE.txt for license information.
+ SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
+
+-->
+
+# Introduction to Declare Target
+
+In OpenMP `declare target` is a directive that can be applied to a function or variable (primarily global) to notate to the compiler that it should be generated in a particular devices environment. In essence whether something should be emitted for host or device, or both. An example of its usage for both data and functions can be seen below.
+
+```Fortran
+module test_0
+ integer :: sp = 0
+!$omp declare target link(sp)
+end module test_0
+
+program main
+ use test_0
+!$omp target map(tofrom:sp)
+ sp = 1
+!$omp end target
+end program
+```
+
+In the above example, we created a variable in a seperate module, mark it as `declare target` and then map it, embedding it into the device IR and assigning to it.
----------------
skatrak wrote:
```suggestion
In the above example, we create a variable in a separate module, mark it as `declare target` and then map it, embedding it into the device IR and assigning to it.
```
https://github.com/llvm/llvm-project/pull/78502
More information about the flang-commits
mailing list