Generalizing the VM buffer type and adding VM buffer ops.#5748
Merged
Conversation
2a82a27 to
bbd2898
Compare
Collaborator
Author
|
(still a few tests to write, but otherwise ready for review I think) |
bbd2898 to
fcee6b5
Compare
(tacking this on to the other breaking changes)
fcee6b5 to
70502d6
Compare
ScottTodd
approved these changes
May 6, 2021
Member
ScottTodd
left a comment
There was a problem hiding this comment.
No real comments :P
Straightforward buffer manipulation code that fits into the rest of the VM nicely. Thanks for the header file comments and explicit access types.
hcindyl
added a commit
to hcindyl/iree
that referenced
this pull request
May 7, 2021
Update with the identifier changes in iree-org#5748
Merged
hcindyl
added a commit
that referenced
this pull request
May 7, 2021
Update with the identifier change in #5748
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Previously the VM had a special builtin for read-only buffers and it was always just a placeholder for something more meaningful. This is the start of that. This implementation will undergo a lot of changes as VMVX is brought up but is the first wave of work to unblock that exploration.
vm.list/iree_vm_list_tare useful for storing reference-counted objects and heterogeneous element types and supports resizing, and this newvm.buffer/iree_vm_buffer_tis useful for fast access to fixed-length sets of primitive values with the ability to bitcast the storage. The buffer is access checked (preventing writes to read-only memory), origin checked (preventing inadvertent lifetime extension), bounds checked/alignment-enforced, and is a ref object like any other so that proper lifetime is tracked across host/guest/module boundaries.The intent is to have a memory-safe byte buffer that supports external host memory, read-only mapped buffer memory (.rodata sections), and read/write memory allocated from within the user VM code. There's a long list of ops in the HAL that needed this (such as
hal.command_buffer.update_buffer) and techniques like uniform buffers or mapping memory directly from devices into VM-accessible data.The op set here is relatively mundane with malloc, memset, memcmp, memcpy, etc and typed load/store routines. Future extensions to this can add more ways of loading/storing such as multi-value loads/stores to reduce overhead - VMVX may use that to emulate vector loads/stores, for example, with a
vm.buffer.load.i16x32.