Skip to content

Conversation

@Lunderberg
Copy link
Contributor

This change allows allocation of buffers with "global.vtcm" to be either 1-d (flat) or 2-d (non-flat) memory allocations.

Lunderberg and others added 3 commits March 31, 2022 12:01
Previously, all VTCM allocations were assumed to be 2-d buffers.  This
commit extends `HexagonDeviceAPIv2::AllocVtcmWorkspace` to allow both
1-d and 2-d VTCM allocations.  Matching the semantics used in
`CodeGenHexagon::CreateBufferPtr`, allocation of 1-d buffers returns a
`void*`, and allocation of 2-d buffers returns a `void**`.

Co-authored-by: Adam Straw <[email protected]>
Previously, HexagonBuffer represented 1-d buffers as 2-d buffers with
`nallocs==1`.  Since this is used to determine the return type of the
data pointer exposed to the generated code, the ambiguity between
`shape=[N]` and `shape=[1,N]` must be avoided.  This commit replaces
`HexagonBuffer::nallocs_` with `HexagonBuffer::ndim_`, avoiding this
ambiguity.
This updates `HexagonDeviceAPIv2::AllocDataSpace` to follow the
semantics of `DeviceAPI::AllocDataSpace`, to avoid breaking caller
assumptions in `tvm.nd.array` or graph_executor/aot allocation.
@Lunderberg
Copy link
Contributor Author

@adstraw @csullivan

@Lunderberg Lunderberg force-pushed the hexagon_1d_and_2d_allocations branch from 96f6a2c to 3d7ae57 Compare March 31, 2022 19:50
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; just need to clean up some unused code.

void** GetPointer();
/*! \brief Return data pointer
*
* The return type depends on the buffer being
Copy link
Contributor

Choose a reason for hiding this comment

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

This comment looks truncated.

@kparzysz-quic kparzysz-quic merged commit 21ce29f into apache:main Apr 1, 2022
@Lunderberg Lunderberg deleted the hexagon_1d_and_2d_allocations branch April 1, 2022 22:07
Lunderberg added a commit to Lunderberg/tvm that referenced this pull request Apr 1, 2022
As a follow-up from apache#10846,
completing a docstring that unintentionally ended in the middle of a
sentence.
kparzysz-quic pushed a commit that referenced this pull request Apr 2, 2022
As a follow-up from #10846,
completing a docstring that unintentionally ended in the middle of a
sentence.
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
* [Hexagon] Support both 1-d and 2-d VTCM allocations

Previously, all VTCM allocations were assumed to be 2-d buffers.  This
commit extends `HexagonDeviceAPIv2::AllocVtcmWorkspace` to allow both
1-d and 2-d VTCM allocations.  Matching the semantics used in
`CodeGenHexagon::CreateBufferPtr`, allocation of 1-d buffers returns a
`void*`, and allocation of 2-d buffers returns a `void**`.

Co-authored-by: Adam Straw <[email protected]>

* [Hexagon] Distinguish between 1-d buffer and single-alloc 2-d buffer

Previously, HexagonBuffer represented 1-d buffers as 2-d buffers with
`nallocs==1`.  Since this is used to determine the return type of the
data pointer exposed to the generated code, the ambiguity between
`shape=[N]` and `shape=[1,N]` must be avoided.  This commit replaces
`HexagonBuffer::nallocs_` with `HexagonBuffer::ndim_`, avoiding this
ambiguity.

* [Hexagon] Treat "global" scope allocations as 1-d

This updates `HexagonDeviceAPIv2::AllocDataSpace` to follow the
semantics of `DeviceAPI::AllocDataSpace`, to avoid breaking caller
assumptions in `tvm.nd.array` or graph_executor/aot allocation.

* Updated C++ unit tests for HexagonBuffer

* Remove commented GetNumAllocs and unused GetBufferDimension

Co-authored-by: Adam Straw <[email protected]>
pfk-beta pushed a commit to pfk-beta/tvm that referenced this pull request Apr 11, 2022
As a follow-up from apache#10846,
completing a docstring that unintentionally ended in the middle of a
sentence.
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Apr 11, 2022
* [Hexagon] Support both 1-d and 2-d VTCM allocations

Previously, all VTCM allocations were assumed to be 2-d buffers.  This
commit extends `HexagonDeviceAPIv2::AllocVtcmWorkspace` to allow both
1-d and 2-d VTCM allocations.  Matching the semantics used in
`CodeGenHexagon::CreateBufferPtr`, allocation of 1-d buffers returns a
`void*`, and allocation of 2-d buffers returns a `void**`.

Co-authored-by: Adam Straw <[email protected]>

* [Hexagon] Distinguish between 1-d buffer and single-alloc 2-d buffer

Previously, HexagonBuffer represented 1-d buffers as 2-d buffers with
`nallocs==1`.  Since this is used to determine the return type of the
data pointer exposed to the generated code, the ambiguity between
`shape=[N]` and `shape=[1,N]` must be avoided.  This commit replaces
`HexagonBuffer::nallocs_` with `HexagonBuffer::ndim_`, avoiding this
ambiguity.

* [Hexagon] Treat "global" scope allocations as 1-d

This updates `HexagonDeviceAPIv2::AllocDataSpace` to follow the
semantics of `DeviceAPI::AllocDataSpace`, to avoid breaking caller
assumptions in `tvm.nd.array` or graph_executor/aot allocation.

* Updated C++ unit tests for HexagonBuffer

* Remove commented GetNumAllocs and unused GetBufferDimension

Co-authored-by: Adam Straw <[email protected]>
mehrdadh pushed a commit to mehrdadh/tvm that referenced this pull request Apr 11, 2022
As a follow-up from apache#10846,
completing a docstring that unintentionally ended in the middle of a
sentence.
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