Skip to content

Allocmem array extents #1158

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 5 commits into from
Oct 27, 2021
Merged

Allocmem array extents #1158

merged 5 commits into from
Oct 27, 2021

Conversation

vdonaldson
Copy link
Collaborator

Fixed sized allocmem array extents are part of the type, and should not
be duplicated as dynamic values.

Fixed sized allocmem array extents are part of the type, and should not
be duplicated as dynamic values.
Copy link
Collaborator

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Logic looks good, please use regex somehow for the ssa numbers in the test.

auto shapeOp = getOrReadExtentsAndShapeOp(loc, rewriter, load, extents);
auto arrTy = fir::unwrapRefType(load.memref().getType());
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using fir::unwrapPassByRefType here removes the need of the if BoxType below.

! CHECK: %[[aa:[0-9]+]] = fir.address_of(@_QEaa) : !fir.ref<!fir.array<2650000xf32>>{{$}}
integer, parameter :: N = 2650000
real aa(N)
! CHECK: %7 = fir.array_coor %[[aa]](%1) %6 : (!fir.ref<!fir.array<2650000xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think you should either run the script to generate the test or manually capture all the ssa value number, otherwise, this test is really likely to break for small unrelated changes adding some other value and changing the numbering.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oops, I only wanted to focus on the array ops

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There is more than just %7, there is still dozens of ssa values here and there (%1, %6, %32, %33.....) I think you need a more radical sed to replace them by {{.*}} if you do not care about them.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, yes, thanks for pointing that out

Copy link

@schweitzpgi schweitzpgi left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

+1

@@ -797,11 +797,17 @@ class ArrayUpdateConversionBase : public mlir::OpRewritePattern<ArrayOp> {
LLVM_DEBUG(llvm::outs() << "Yes, conflict was found\n");
rewriter.setInsertionPoint(loadOp);
// Copy in.
llvm::SmallVector<mlir::Value> extents;
llvm::SmallVector<mlir::Value> extents, nonconstantExtents;

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: please make these two distinct declarations.

real aa(N)
! CHECK: fir.array_coor %[[aa]](%[[shape]]) %{{[0-9]+}} : (!fir.ref<!fir.array<2650000xf32>>, !fir.shape<1>, index) -> !fir.ref<f32>
aa = -2
! CHECK: %[[temp:[0-9]+]] = fir.allocmem !fir.array<2650000xf32>

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice.

Shouldn't there be a test for a non-constant sized array and a test for a mix of constant and non-constant extents?

Copy link
Collaborator

@jeanPerier jeanPerier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, please squash your commits into a single one before merging (and use the rebase and merge option in github to merge without merge commit) to make it easier to integrate it in the rebase.

@vdonaldson vdonaldson merged commit efea0c9 into flang-compiler:fir-dev Oct 27, 2021
@vdonaldson vdonaldson deleted the vkd1 branch October 27, 2021 17:18
jeanPerier pushed a commit that referenced this pull request Oct 28, 2021
Fixed sized allocmem array extents are part of the type, and should not
be duplicated as dynamic values.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants