-
Notifications
You must be signed in to change notification settings - Fork 15.2k
[flang-rt] Add APIs to retrive base_addr and DataSizeInBytes from Descriptor. #152756
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -48,6 +48,30 @@ void RTDEF(CopyAndUpdateDescriptor)(Descriptor &to, const Descriptor &from, | |
} | ||
} | ||
|
||
void *RTDEF(DescriptorGetBaseAddress)( | ||
const Descriptor &desc, const char *sourceFile, int sourceLine) { | ||
Terminator terminator{sourceFile, sourceLine}; | ||
void *baseAddr = desc.raw().base_addr; | ||
if (!baseAddr) { | ||
terminator.Crash("Could not retrieve Descriptor's base address"); | ||
} | ||
return baseAddr; | ||
} | ||
|
||
std::size_t RTDEF(DescriptorGetDataSizeInBytes)( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is So there are existing operations that should allow you to get all the data for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks @clementval and @vzakhari for feedback. Will check if these fir ops work in our scenario e2e. Closing the pull request for now. |
||
const Descriptor &desc, const char *sourceFile, int sourceLine) { | ||
Terminator terminator{sourceFile, sourceLine}; | ||
std::size_t descElements{desc.Elements()}; | ||
if (!descElements) { | ||
terminator.Crash("Could not retrieve Descriptor's Elements"); | ||
} | ||
std::size_t descElementBytes{desc.ElementBytes()}; | ||
if (!descElementBytes) { | ||
terminator.Crash("Could not retrieve Descriptor's ElementBytes"); | ||
} | ||
return descElements * descElementBytes; | ||
} | ||
|
||
RT_EXT_API_GROUP_END | ||
} // extern "C" | ||
} // namespace Fortran::runtime |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As Valentin said, there is
fir.box_addr
operation that allows taking the base address from a descriptor.