Skip to content
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

[Hexagon] Refactor to keep HexagonBuffer private to the device api #10910

Merged
merged 2 commits into from
Apr 6, 2022
Merged

[Hexagon] Refactor to keep HexagonBuffer private to the device api #10910

merged 2 commits into from
Apr 6, 2022

Conversation

csullivan
Copy link
Contributor

@csullivan csullivan commented Apr 5, 2022

Refactoring the DeviceAPI a bit to privatize the HexagonBuffer class and no longer return it across the API boundary. So far we haven't seen a need to identify the memory scope, layout, and other properties of a HexagonBuffer outside the Device API.

@csullivan csullivan requested a review from mehrdadh April 5, 2022 22:32
@csullivan
Copy link
Contributor Author

cc @adstraw

Copy link
Contributor

@Lunderberg Lunderberg left a comment

Choose a reason for hiding this comment

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

Just a few general cleanups, and looks good to me. I like this change, so that nothing outside the device api needs to track how the internal memory is handled.

@@ -47,14 +47,6 @@
namespace tvm {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we remove the now empty namespace blocks?

if (it != this->hexagon_buffer_map_.end()) {
return it->second.get();
}
return nullptr;
Copy link
Contributor

Choose a reason for hiding this comment

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

Since the nullptr check is done after each lookup, let's move it in here as CHECK(it != this->hexagon_buffer_map_.end()).

Copy link
Contributor

Choose a reason for hiding this comment

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

Agree with @Lunderberg's comment and also think that lookup_hexagon_buffer could / should be a member of HexagonDeviceAPIv2 named LookupHexagonBuffer alongside the "Allocate" and "Free" methods.

Copy link
Contributor

Choose a reason for hiding this comment

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

I like that, because that would let it be used in the free_nd function as well. Though, I think it should be private, unlike the "Allocate" and "Free" methods.

*/
template <typename... Args>
void* AllocateHexagonBuffer(Args&&... args) {
auto buf = std::unique_ptr<HexagonBuffer>(new HexagonBuffer(std::forward<Args>(args)...));
Copy link
Contributor

Choose a reason for hiding this comment

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

Since TVM uses C++14, we can use std::make_unique<HexagonBuffer>(std::forward<Args>(args)...) instead of new.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Alas my configuration for hexagon was giving false negatives on finding std::make_unique in the std. I had intended to circle back on this one before pushing but forgot, so thank you for the reminder!

Copy link
Contributor

@adstraw adstraw left a comment

Choose a reason for hiding this comment

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

LGTM. No comments beyond what @Lunderberg already mentioned. Thanks @csullivan!

@adstraw
Copy link
Contributor

adstraw commented Apr 6, 2022

Note that the "external" constructor for HexagonBuffer using void* is no longer required after this PR and furthermore HexagonBuffer can be simplified as it no longer needs to separately track managed and unmanaged allocations. I think it's OK to follow up with a PR to do this cleanup work in HexagonBuffer --- just wanted to note it here.

Copy link
Member

@mehrdadh mehrdadh left a comment

Choose a reason for hiding this comment

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

LGTM!

@mehrdadh mehrdadh merged commit 27c5910 into apache:main Apr 6, 2022
@mehrdadh
Copy link
Member

mehrdadh commented Apr 6, 2022

@csullivan @adstraw @Lunderberg @kparzysz-quic thanks! merged now!

pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
…pache#10910)

* No longer return HexagonBuffer from device api.

* fixup! No longer return HexagonBuffer from device api.
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Apr 11, 2022
…pache#10910)

* No longer return HexagonBuffer from device api.

* fixup! No longer return HexagonBuffer from device api.
Lucien0 pushed a commit to Lucien0/tvm that referenced this pull request Apr 19, 2022
…pache#10910)

* No longer return HexagonBuffer from device api.

* fixup! No longer return HexagonBuffer from device api.
altanh pushed a commit to altanh/tvm that referenced this pull request Apr 28, 2022
…pache#10910)

* No longer return HexagonBuffer from device api.

* fixup! No longer return HexagonBuffer from device api.
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.

None yet

5 participants