[flang][cuda] Transfer device data used in host operations (#228292)

An assignment to host data from an expression with device data is
lowered
as an implicit data transfer only when the expression also contains a
constant or a host symbol. Constants in subscripts are ignored, so
expressions such as a(3)*a(4), -a(3), -d1, or a conversion a(3) from
real(8) to real(4) were lowered as plain transfers. The scalar result
was
then computed on the host directly from device memory and stored to the
left-hand side, and array expressions failed the cuf.data_transfer
verifier.

Treat any right-hand side with device data that is not a variable as an
implicit transfer. The device data is copied to a host temporary and the
expression is evaluated on the host. An assignment of such an expression
to device data is now diagnosed as an unsupported transfer, as a = a +
10
already is.

GitOrigin-RevId: 65a82906cff9c7a7a33844812d35ce159d88a354
4 files changed
tree: 8d5fd69d96d3d9f3676a45cf925d2793f5c9b06f
  1. cmake/
  2. docs/
  3. examples/
  4. include/
  5. lib/
  6. test/
  7. tools/
  8. unittests/
  9. .clang-format
  10. .clang-tidy
  11. .drone.star
  12. .gitignore
  13. CMakeLists.txt
  14. LICENSE.TXT
  15. Maintainers.md
  16. README.md
README.md

Flang

Flang is a ground-up implementation of a Fortran front end written in modern C++. It started off as the f18 project (https://github.com/flang-compiler/f18) with an aim to replace the previous flang project (https://github.com/flang-compiler/flang) and address its various deficiencies. F18 was subsequently accepted into the LLVM project and rechristened as Flang.

Please note that flang is not ready yet for production usage.

Getting Started

Read more about flang in the docs directory. Start with the compiler overview.

To better understand Fortran as a language and the specific grammar accepted by flang, read Fortran For C Programmers and flang's specifications of the Fortran grammar and the OpenMP grammar.

Treatment of language extensions is covered in this document.

To understand the compilers handling of intrinsics, see the discussion of intrinsics.

To understand how a flang program communicates with libraries at runtime, see the discussion of runtime descriptors.

If you're interested in contributing to the compiler, read the style guide and also review how flang uses modern C++ features.

If you are interested in writing new documentation, follow LLVM's Markdown style guide.

Consult the Getting Started with Flang for information on building and running flang.