Xilinx / xfopencv

Other
321 stars 144 forks source link

Add an option to allocate the memory of xf::Mat as cacheable #66

Open ghost opened 4 years ago

ghost commented 4 years ago

The memory of xf::Mat is currently always allocated with sds_alloc_non_cacheable, e.g.: https://github.com/Xilinx/xfopencv/blob/701cf6d88b4980d7e4e73aa7d84fa58bc60f2aa3/include/common/xf_structs.h#L469

In my use case (pass input image(s) from the CPU as a xf::Mats, run a single custom image processing step as a SDX accelerator function, return results as an xf::Mat image and continue processing on the CPU), I experience significant performance improvements when accessing the result xf::Mat from the CPU if I allocate the memory with sds_alloc instead.

Currently, I do this by manually setting the height, width and data (and allocatedFlag) of the Mat objects instead of simply calling init. But I consider this a rather ugly hack - would it be an option to add a bool parameter cacheable to the allocating functions/constructors of xf::Mat that determines whether the memory is allocated with sds_alloc or sds_alloc_non_cacheable?