I find SNPE has two functions registerIonBuffers and deregisterIonBuffers, are these two functions used to avoid memory copy between cpu and dsp? If so, how to use them?
How SNPE use ION buffers to avoid memory copy ?
Posted: Fri, 2023-03-10 02:36
I find SNPE has two functions registerIonBuffers and deregisterIonBuffers, are these two functions used to avoid memory copy between cpu and dsp? If so, how to use them?
Opinions expressed in the content posted here are the personal opinions of the original authors, and do not necessarily reflect those of Qualcomm Incorporated or its subsidiaries (“Qualcomm”). The content is provided for informational purposes only and is not meant to be an endorsement or representation by Qualcomm or any other party. This site may also provide links or references to non-Qualcomm sites and resources. Qualcomm makes no representations, warranties, or other commitments whatsoever about any non-Qualcomm sites or third-party resources that may be referenced, accessible from, or linked to this site.
Dear developer,
You can call the API of
bool registerIonBuffers(const zdl::DlSystem::UserMemoryMap & ionBufferMap)in your application directly. The parameter of ionBufferMap will allocate ION buffer according to your SNPE instance.
BR.
Wei
Dear wei,
Thanks for your reply.
I tried three ways to use regiserIonBuffers, but none works.
1. use ioctl&mmap to alloc ION buffer beforehand, and assign the buffer to registerIonBuffers functions like:
registerIonBuffers will return false from above pseudo code.
2. Do not alloc ION buffer in advance, and map add NULL like:
registerIonBuffers will also return false from above pseudo code.
3. Do not alloc ION buffer in advance, and map is empty like:
Nothing happened.
So, I just wonder whether shold I alloc ION buffer by myself or leave this work to SNPE. I want to use ION buffers because my app needs to transfer a huge data between CPU and DSP memories, alloc a ION shared buffer between them to avoid memcpy is a good choice, but I have no way to make SNPE know I alreadly alloc an ION buffer and just use it. Can you give me a tiny sample code?
Sincely,
guangchao