9 Commits

Author SHA1 Message Date
Jakub Kuderski
9aaf0b89f5
[mlir] Apply clang-tidy check llvm-use-vector-utils. NFC. (#178526) 2026-01-29 02:19:00 +00:00
Razvan Lupusoru
ab7217a089
[acc][flang] Add isDeviceData APIs for device data detection (#176219)
Add comprehensive APIs to detect device-resident data across OpenACC
type and operation interfaces. This enables passes to identify data that
is already on the device (e.g., CUF device/managed/constant memory, GPU
address spaces) and handle it appropriately.

New interface methods:
- PointerLikeType::isDeviceData(Value): Returns true if the pointer
points to device data.
- MappableType::isDeviceData(Value): Returns true if the variable
represents device data.
- GlobalVariableOpInterface::isDeviceData(): Returns true if the global
variable is device data.

New utilities in OpenACCUtils:
- acc::isDeviceValue(Value): Checks if a value represents device data by
querying type interfaces, PartialEntityAccessOpInterface for base
entities, and AddressOfGlobalOpInterface for global symbols.
- acc::isValidValueUse(Value, Region): Checks if a value is legal in an
OpenACC region by verifying it comes from a data operation, is only used
by private clauses, or is device data.

Updated isValidSymbolUse to check
GlobalVariableOpInterface::isDeviceData()
for symbols referencing device-resident globals.

FIR implementations check for CUF data attributes (device, managed,
constant, shared, unified) on operations, block arguments, and globals.
The implementation traces through fir.rebox, fir.embox, fir.declare,
hlfir.declare, and fir.address_of to find the underlying data source.

Memref implementations check for gpu::AddressSpaceAttr on the memref
type.

Updated ACCImplicitData to use acc::isDeviceValue for generating
acc.deviceptr clauses for device-resident data instead of
copyin/copyout.

Updated OpenACCSupport::isValidValueUse to fallback to the new
acc::isValidValueUse utility.
2026-01-15 20:56:26 +00:00
Longsheng Mou
dddd244ca9
[mlir] Using getDefiningOp<OpTy>() instead of dyn_cast_or_null<OpTy>(getDefiningOp()) (NFC) (#173445) 2025-12-24 19:15:57 +08:00
Valentin Clement (バレンタイン クレメン)
bf81bdec66
[mlir][acc] Add isValidValueUse to OpenACCSupport (#171538)
Add a new API `isValidValueUse ` to OpenACCSupport. This is used in
ACCImplicitData to check value that are already legal in the OpenACC
region and do not require implicit clause to be generated. An example
would be a CUDA Fortran device variable that is already on the GPU.
2025-12-10 08:19:04 -08:00
nvptm
85e7860319
[mlir][acc] Make getDominatingDataClauses an OpenACC utility (#170549)
Moving getDominatingDataClauses to OpenACCUtils allows reuse.
2025-12-05 09:31:26 -08:00
Razvan Lupusoru
6a6b99aa80
[acc][flang][cir] Add recipes to data entry operations (#149210)
This patch refactors the OpenACC dialect to attach recipe symbols
directly to data operations (acc.private, acc.firstprivate,
acc.reduction)
rather than to compute constructs (acc.parallel, acc.serial, acc.loop).

Motivation:
The previous design required compute constructs to carry both the recipe
symbol and the variable reference, leading to complexity. Additionally,
recipes were required even when they could be generated automatically
through MappableType interfaces.

Changes:
- Data operations (acc.private, acc.firstprivate, acc.reduction) now
  require a 'recipe' attribute referencing their respective recipe
  operations
- Verifier enforces recipe attribute presence for non-MappableType
  operands; MappableType operands can generate recipes on demand
- Compute constructs (acc.parallel, acc.serial, acc.loop) no longer
  carry recipe symbols in their operands
- Updated flang lowering to attach recipes to data operations instead
  of passing them to compute constructs

Format Migration:
Old format:
```
  acc.parallel private(@recipe -> %var : !fir.ref<i32>) { ... }
```

New format:
```
  %private = acc.private varPtr(%var : !fir.ref<i32>)
              recipe(@recipe) -> !fir.ref<i32>
  acc.parallel private(%private : !fir.ref<i32>) { ... }
```

Test Updates:
- Updated all CIR and Flang OpenACC tests to new format
- Fixed CHECK lines to verify recipe attributes on data operations
2025-11-25 17:59:45 +00:00
Atmn Patel
621cbcde01
[mlir][acc] Adds attr to acc.present to identify default clause origin (#169114)
The `acc.present` Op as generated by ACCImplicitData does not provide a
way to differentiate between `acc.present` ops that are generated
implicitly and the ones that are generated as result of an explicit
`default(present)` clause in the source code. This differentiation would
allow for better communication to the user on the decisions made by the
compiler while managing data automatically between the host and the
device. This commit adds this information as a discardable attribute on
the `acc.present` op.
2025-11-24 10:15:00 -08:00
Kazu Hirata
2844d86734
[mlir] Remove unused local variables (NFC) (#167107)
Identified with bugprone-unused-local-non-trivial-variable.
2025-11-08 07:41:15 -08:00
Razvan Lupusoru
28c6ed5914
[mlir][acc] Add ACCImplicitData pass for implicit data attributes (#166472)
This change adds the ACCImplicitData pass which implements the OpenACC
specification for "Variables with Implicitly Determined Data Attributes"
(OpenACC 3.4 spec, section 2.6.2).

The pass automatically generates data clause operations (copyin,
copyout, present, firstprivate, etc.) for variables used within OpenACC
compute constructs (parallel, kernels, serial) that do not already have
explicit data clauses.

Key features:
- Respects default(none) and default(present) clauses
- Handles scalar vs. aggregate variables with different semantics:
  * Aggregates: present clause (if default(present)) or copy clause
  * Scalars: copy clause (kernels) or firstprivate (parallel/serial)
- Generates privatization recipes when needed for firstprivate clauses
- Performs alias analysis to avoid redundant data mappings
- Ensures proper data clause ordering for partial entity access
- Generates exit operations (copyout, delete) to match entry operations

Requirements:
- Types must implement acc::MappableType and/or acc::PointerLikeType
interfaces to be considered candidates.
- Operations accessing partial entities or creating subviews should
implement acc::PartialEntityAccess and/or mlir::ViewLikeOpInterface for
proper clause ordering.
- Optionally pre-register acc::OpenACCSupport and mlir::AliasAnalysis if
custom alias analysis, variable name determination, or error reporting
is needed.
2025-11-06 07:34:25 -08:00