[flang-commits] [flang] [flang][cuda] Do not register global constants (PR #118582)
Renaud Kauffmann via flang-commits
flang-commits at lists.llvm.org
Wed Dec 4 11:39:41 PST 2024
================
@@ -106,8 +106,7 @@ struct CUFAddConstructor
mlir::func::FuncOp func;
switch (attr.getValue()) {
- case cuf::DataAttribute::Device:
- case cuf::DataAttribute::Constant: {
+ case cuf::DataAttribute::Device: {
----------------
Renaud-K wrote:
Something like this:
```
module devmod
use iso_c_binding, only: c_int
integer, parameter :: amazon(10) = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
integer, constant :: google(10)
```
gets lowered to, in HLFIR:
```
fir.global @_QMdevmodECamazon(dense<0> : tensor<10xi32>) constant : !fir.array<10xi32>
fir.global @_QMdevmodEgoogle {data_attr = #cuf.cuda<constant>} : !fir.array<10xi32> {
```
I am not finding a whole lot about the `constant` attribute. Is it new? From online research, it seems to just be a protection against modification such as a pointer to constant data. If it is the case, then it should be implemented like a regular global.
The array parameter seems to be handled fine with this change. It will get the `#cuf.cuda<constant>` assigned later in the flow and will be copied to the GPU module with its initializer.
https://github.com/llvm/llvm-project/pull/118582
More information about the flang-commits
mailing list