17 Commits

Author SHA1 Message Date
Andy Kaylor
1e45ea12db
[CIR] Add support for function linkage and visibility (#145600)
This change adds support for function linkage and visibility and related
attributes. Most of the test changes are generalizations to allow
'dso_local' to be accepted where we aren't specifically testing for it.
Some tests based on CIR inputs have been updated to add 'private' to
function declarations where required by newly supported interfaces.

The dso-local.c test has been updated to add specific tests for
dso_local being set correctly, and a new test, func-linkage.cpp tests
other linkage settings.

This change sets `comdat` correctly in CIR, but it is not yet applied to
functions when lowering to LLVM IR. That will be handled in a later
change.
2025-06-25 10:59:30 -07:00
erichkeane
eed98e1493 [OpenACC][CIR] 'attach' clause lowering for combined/compute
Attach is identical to 'present', except it generates an acc.attach and
acc.detach.  This patch implements these, just like the preivous handful
of clauses.
2025-06-06 17:06:49 -07:00
erichkeane
4eb72312e2 [OpenACC][CIR] Implement 'present' lowering for compute/combined
'present' has a data-in operation acc.present, and uses 'delete' for its
data out.  Otherwise it is identical to no_create.
2025-06-06 16:54:58 -07:00
erichkeane
b09b1d65ef [OpenACC][CIR] Implement lowering for 'no_create' clause for comp/comb
no_create has its own 'data-in', plus uses the 'delete' for the data-out
operation.  Additionally, like all data clauses it uses the 'async'
functionality previous implemented.  This patch implements no_create for
combined/compute constructs completely, and ensures that the feature is
tested.
2025-06-06 16:36:11 -07:00
erichkeane
39bb267445 [OpenACC][CIR][NFC] Add device_ptr async clause tests
Add a test to ensure that device_ptr properly respects the 'async'
functionality we added for copy/etc.
2025-06-06 11:58:58 -07:00
erichkeane
b84127bb13 [OpenACC][CIR] Lowering for 'deviceptr' for compute/combined constructs
This ends up being a simple clause that only adds 'acc.deviceptr' to the
dataOperands list on the compute construct operation.
2025-06-06 11:26:35 -07:00
Andy Kaylor
ea3c225786
[CIR] Add alignment support for global, store, and load ops (#141163)
This adds alignment support for GlobalOp, LoadOp, and StoreOp.

Tests which failed because cir.store/cir.load now print alignment were
updated with wildcard matches, except where the alignment was relevant
to the test. Tests which check for cir.store/cir.load in cases that
don't have explicit alignment were not updated.

New tests for alignment are alignment.c, align-load.c, and
align-store.c.
2025-05-23 15:34:59 -07:00
erichkeane
6d7b5c3742 [OpenACC][CIR] Update tests after #140122
Patch #140122 changed the format of OpenACC 'async', without changing
the clang tests.  This patch updates the test.
2025-05-15 16:24:45 -07:00
Erich Keane
881f6de812
[OpenACC][CIR] Lower 'wait' clause for compute/data constructs (#137359)
The 'wait' clause is a bit complicated, and is laid out awkwardly in the
IR addative functions, so this patch has to do a little bit of work to
do that (mostly the 'devnum' work).

Otherwise, this is very similar to how num_gangs works, with the
additional complexity of the 'empty' wait being represented differently
as well, but this is similar to how 'async' and a few others work as
well.
2025-04-25 13:15:03 -07:00
Erich Keane
bae4c946a1
[OpenACC][CIR] Implement 'num_gangs' lowering (#137216)
This is similar to the previous handful of lowering commits, except that
it takes an array of int-expressions rather than a single one. This
complicates the list of things that need updating (as the 'segments'
array also needs updating), which resulted in a bit of a refactor.

At the moment, only parallel/kernels are enabled (not parallel
    loop/kernels loop), so tests are added just for those.

---------

Co-authored-by: Valentin Clement (バレンタイン クレメン) <clementval@gmail.com>
2025-04-24 14:12:20 -07:00
Erich Keane
c9eb1ffcfe
[OpenACC][CIR] Implement 'async' lowering. (#136626)
Async acts just like num_workers/vector_length in that it gets a new
variant per device_type and is lowered as an operand.

However, it has one additional complication, in that it can have a
variant that has no argument, which produces an attribute with the
correct devicetype.

Additionally, this syncronizes us with the implementation of flang,
  which prohibits multiple 'async' clauses per-device_type.
2025-04-22 06:41:59 -07:00
erichkeane
b7c521b922 [OpenACC][CIR] Lowering for 'vector_length' on compute constructs
This is the same as the 'num_workers', with slightly different names in
places, so we just do the same exact implementation.  This extracts the
implementation as well, which should make it easier to reuse.
2025-04-21 12:47:47 -07:00
Erich Keane
0ae9dac262
[OpenACC][CIR] Lower 'num_workers' for parallel/kernels (#136578)
This patch also includes the first one to handle 'device_type' properly,
which is where most of the 'challenge' here comes from.

From the best I can tell: we must keep two lists of the same size, 1 of
all of the 'num_workers' items, and 1 of the 'device_type' value for
that 'num_workers'. Additionally, the 'device_type' list can only handle
single 'device_type' values, so we have to duplicate the 'num_workers'
items in cases where there are multiple applicable 'device_type' values.

This patch accomplishes this by keeping the two in sync, and saving the
current 'device_type' in the visitor.
2025-04-21 11:51:26 -07:00
erichkeane
6ad922b75a [OpenACC][CIR] Implement lowering for 'if' on compute constructs
This is the same for these as the 'self' was, except it doesn't support
the 'empty' variant, so we have to just generate the condition.  This
patch does that, and extracts the 'condition' emission to a separate
function since the two share it.
2025-04-15 16:34:11 -07:00
Erich Keane
af63e1b505
[OpenACC][CIR] Implement 'self' lowering on compute constructs (#135851)
This is our first attempt at lowering a clause that is an 'operand' in
the OpenACC operand, so it does quite a bit of refactoring. My previous
plans on how to emit the clauses was not viable, so we instead do
'create the op, then use the visitor to fill in the operands'. This
resulted in the 'applyAttributes' function getting removed and a few
other functions simplified.

Additionally, it requires setting the insertion point a little to make
sure we're inserting 'around' the operation correctly.

Finally, since the OpenACC dialect only understands the MLIR types, we
had to introduce a use of the unrealized-conversion-cast, which we'll
probably getting good use out of in the future.
2025-04-15 15:52:04 -07:00
Erich Keane
fa273e1158
[OpenACC][CIR] Implement 'data' construct lowering (#135038)
This patch does the lowering of the OpenACC 'data' construct, which
requires getting the `default` clause (as `data` requires at least 1 of
a list of clauses, and this is the easiest one). The lowering of the
clauses appears to happen in 1 of 2 ways: a- as an operand. or b- as an
attribute.

This patch adds infrastructure to lower as an attribute, as that is how
'data' works.

In addition to that, it changes the OpenACCClauseVisitor a bit, which
previously just required that each of the derived classes have all of
the clauses covered. This patch modifies it so that the visitor directly
calls the derived class from its visitor function, which leaves the
base-class ones the ability to defer to a generic function. This was
previously like this because I had some use cases that I didn't end up
using, and the 'generic' function here seems much more useful.
2025-04-09 10:45:17 -07:00
Erich Keane
6e7c40b83d
[OpenACC][CIR] Initial patch to do OpenACC->IR lowering (#134936)
This patch adds some lowering code for Compute Constructs, plus the
infrastructure to someday do clauses. Doing this requires adding the
dialect to the CIRGenerator.

This patch does not however implement/correctly initialize lowering from
OpenACC-Dialect to anything lower however.
2025-04-09 06:05:31 -07:00