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

VITIS-12792 HIP Binding: Memory pool APIs #8268

Merged
merged 83 commits into from
Oct 6, 2024

Conversation

zhangchiming
Copy link
Collaborator

Problem solved by the commit
add initial implementation of hip stream ordered memory allocator.

How problem was solved, alternative solutions (if any) and why they were rejected
N/A

Risks (if any) associated the changes in the commit
None. Code will only be built with switch "-hip".

What has been tested and how, request additional testing if necessary
Compiled and tested on Ubuntu 22.04 (running on Ryzen 7840).

Documentation impact (if any)
None.

zhangchiming and others added 30 commits June 5, 2024 20:48
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
2) avoid crash from getting hip mem object from null pointer
3) allow setting 0 for kernel arguments

Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming Zhang <[email protected]>
@zhangchiming
Copy link
Collaborator Author

retest this please

@chvamshi-xilinx
Copy link
Collaborator

Merging this change. Will send separate PR later if there are any cleanups..

@chvamshi-xilinx chvamshi-xilinx merged commit 1733fa0 into Xilinx:master Oct 6, 2024
22 checks passed
aktondak pushed a commit to aktondak/XRT that referenced this pull request Oct 8, 2024
* add hipMemsetD32Async().

Signed-off-by: Chiming Zhang <[email protected]>

* fix typo.

Signed-off-by: Chiming Zhang <[email protected]>

* Replace hard coded name with __func__.

Signed-off-by: Chiming Zhang <[email protected]>

* fix staled pointer error.

Signed-off-by: Chiming Zhang <[email protected]>

* fix double allocation issue.

Signed-off-by: Chiming Zhang <[email protected]>

* fix incorrect share_ptr use.

Signed-off-by: Chiming Zhang <[email protected]>

* add hipMemsetD32Async().

Signed-off-by: Chiming Zhang <[email protected]>

* fix typo.

Signed-off-by: Chiming Zhang <[email protected]>

* Replace hard coded name with __func__.

Signed-off-by: Chiming Zhang <[email protected]>

* fix staled pointer error.

Signed-off-by: Chiming Zhang <[email protected]>

* fix double allocation issue.

Signed-off-by: Chiming Zhang <[email protected]>

* 1) add lock in memory_database::get_hip_mem_from_addr()
2) avoid crash from getting hip mem object from null pointer
3) allow setting 0 for kernel arguments

Signed-off-by: Chiming Zhang <[email protected]>

* fix incorrect share_ptr use.

Signed-off-by: Chiming Zhang <[email protected]>

* Fix rebase error.

Signed-off-by: Chiming Zhang <[email protected]>

* move to_hex() into core/common/utils.h

Signed-off-by: Chiming Zhang <[email protected]>

* remove extra member in class copy_buffer.

Signed-off-by: Chiming Zhang <[email protected]>

* fix a typo.

Signed-off-by: Chiming Zhang <[email protected]>

* fix a typo.

Signed-off-by: Chiming Zhang <[email protected]>

* fix some typo and remove template use from copy_buffer class implementation.

Signed-off-by: Chiming Zhang <[email protected]>

* change type of err_msg argument of helper function throw_if() to const char*.

Signed-off-by: Chiming <[email protected]>

* fix incorrect usage of shared_ptr in copy_buffer constructor.

Signed-off-by: Chiming Zhang <[email protected]>

* change the place where host_vec is moved.

Signed-off-by: Chiming Zhang <[email protected]>

* add back missing std::move in copy_from_host_buffer_commad constructor.

Signed-off-by: Chiming Zhang <[email protected]>

* Add initial implementation of hip stream ordered memory allocator.

Signed-off-by: Chiming Zhang <[email protected]>

* Fix the size alignment in memory pool allocator.

Signed-off-by: Chiming Zhang <[email protected]>

* fix rebase error.

Signed-off-by: Chiming Zhang <[email protected]>

* fix rebase error.

Signed-off-by: Chiming Zhang <[email protected]>

* fix rebase error.

Signed-off-by: Chiming Zhang <[email protected]>

* Add comment for the choice of shared_ptr vs unique_ptr in in enqueing the async memcpy commands.

Signed-off-by: Chiming Zhang <[email protected]>

* Add comment for using shared_ptr for storage of pointer to memory_pool pointers.

Signed-off-by: Chiming Zhang <[email protected]>

* use unique_ptr for device_cache.

Signed-off-by: Chiming <[email protected]>

* Fix issues raised in code review.

Signed-off-by: Chiming <[email protected]>

* fix the error in memory::write().

Signed-off-by: Chiming <[email protected]>

* remove curly braces.

Signed-off-by: Chiming <[email protected]>

* Fix issues in hipMallocAsync() and hipFreeAsync().

Signed-off-by: Chiming <[email protected]>

* fix error found in unit testing.

Signed-off-by: Chiming <[email protected]>

* use sub class of hip::memory for async allocation from hip memory pool.

Signed-off-by: Chiming <[email protected]>

* fix the error in sub mem lookup from memory_database.

Signed-off-by: Chiming <[email protected]>

* remove sub_mem address map.

Signed-off-by: Chiming <[email protected]>

* code clean up.

Signed-off-by: Chiming <[email protected]>

* add code for hipDeviceGetDefaultMemPool(), hipDeviceGetMemPool() and hipDeviceSetMemPool().

Signed-off-by: Chiming <[email protected]>

* fix nullptr error.

Signed-off-by: Chiming <[email protected]>

* Fix compile error on Linux.

Signed-off-by: Chiming Zhang <[email protected]>

* Fix compile warning caused by using "int" type.

Signed-off-by: Chiming Zhang <[email protected]>

* fix compile error in release builds.

Signed-off-by: Chiming Zhang <[email protected]>

* Fix compile error.

Signed-off-by: Chiming Zhang <[email protected]>

---------

Signed-off-by: Chiming Zhang <[email protected]>
Signed-off-by: Chiming <[email protected]>
Co-authored-by: Chiming <[email protected]>
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