This is an archive of the discontinued LLVM Phabricator instance.

[flang][runtime] Add ragged array runtime functions
ClosedPublic

Authored by clementval on Nov 24 2021, 6:49 AM.

Details

Summary

This patch adds the runtime function to allocate and
deallocate ragged arrays.

This patch is part of the upstreaming effort from fir-dev branch.

Co-authored-by: Eric Schweitz <eschweitz@nvidia.com>

Diff Detail

Event Timeline

clementval created this revision.Nov 24 2021, 6:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 24 2021, 6:49 AM
Herald added a subscriber: mgorny. · View Herald Transcript
clementval requested review of this revision.Nov 24 2021, 6:49 AM
Herald added a project: Restricted Project. · View Herald TranscriptNov 24 2021, 6:49 AM

Might be good to get a review from @klausler.

klausler requested changes to this revision.Nov 29 2021, 9:24 AM

There's no documentation in these APIs and the code doesn't look anything like the rest of the runtime. Please document what this code does and how it works.

This revision now requires changes to proceed.Nov 29 2021, 9:24 AM

There's no documentation in these APIs and the code doesn't look anything like the rest of the runtime. Please document what this code does and how it works.

@schweitz Can you take over this patch since you are the original author of these APIs in fir-dev?

clementval updated this revision to Diff 390976.Dec 1 2021, 4:17 AM

Add update from Eric

klausler added inline comments.Dec 1 2021, 11:07 AM
flang/include/flang/Runtime/ragged.h
28

Could you convert the "flags" data member into a bool and a std::uint8_t? It's just holding a flag and an integer in the range 1-15, if I understand this rightly.

flang/runtime/ragged.cpp
15

These would both be better encoded as member functions, if that's possible.

26

Please use braced initialization in the runtime.

36

When bufferPointer is allocated with operator new [], it should be deleted with operator delete [], not std::free() as is done below. But maybe you should avoid the use of C++ runtime features to reduce the risk of making the Fortran runtime library dependent on a C++ runtime. Can you rewrite as a call to std::malloc()?

Address review comments

klausler added inline comments.Dec 7 2021, 9:13 AM
flang/include/flang/Runtime/ragged.h
28

Ping; this is the last unaddressed comment. Will this improvement be possible to make?

clementval marked 5 inline comments as done.Dec 7 2021, 10:25 AM
clementval added inline comments.
flang/include/flang/Runtime/ragged.h
28

It's done just forgot to mark it as done.

klausler accepted this revision.Dec 7 2021, 11:54 AM
This revision is now accepted and ready to land.Dec 7 2021, 11:54 AM
This revision was automatically updated to reflect the committed changes.
clementval marked an inline comment as done.