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

Re-use device buffer in yuy2 cuda helper #11737

Open
wants to merge 1 commit into
base: development
Choose a base branch
from

Conversation

attiladoor
Copy link

@attiladoor attiladoor commented Apr 27, 2023

  • add a new device buffer class which only re-allocated on demand
  • make the buffer instances static to preserve them between frames

Related issue: #11692 (comment)

Nsight systems profiling:

realsense_profiling

As we can see, there is no allocation being done at the yuy2 conversion

- add a new device buffer class which only re-allocated on demand
- make the buffer instances static to preserve them between frames

Github issue: IntelRealSense#11692 (comment)
static T* allocateBuffer(std::size_t const reserve_size)
{
T* datatemp{nullptr};
cudaMalloc(&datatemp, reserve_size * sizeof(T));
Copy link
Author

Choose a reason for hiding this comment

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

maybe i can add an assert to the return value of cudaMalloc and cudaFree above. What do you think?

@@ -284,7 +286,7 @@ void rscuda::unpack_yuy2_cuda_helper(const uint8_t* h_src, uint8_t* h_dst, int n

cudaDeviceSynchronize();
Copy link
Author

Choose a reason for hiding this comment

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

In my opinion, this is unnecessary, but better to use async copy and use the same stream across the whole function and do a stream syncronization before we return from this function. By that we can avoid extra syncing, however the gain would be probably not very significant.

https://docs.nvidia.com/cuda/cuda-runtime-api/group__CUDART__MEMORY.html#group__CUDART__MEMORY_1g85073372f776b4c4d5f89f7124b7bf79

@Nir-Az
Copy link
Collaborator

Nir-Az commented May 2, 2023

Thanks for the PR, we will investigate this issue & fix :)

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.

2 participants