UPGRADE YOUR BROWSER

We have detected your current browser version is not the latest one. Xilinx.com uses the latest web technologies to bring you the best online experience possible. Please upgrade to a Xilinx.com supported browser:Chrome, Firefox, Internet Explorer 11, Safari. Thank you!

cancel
Showing results for 
Search instead for 
Did you mean: 
Visitor angel_alink
Visitor
404 Views
Registered: ‎07-02-2019

How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

We would like to know how to set the minimum CMA Size Requirement for the VCU Encoder.

We have a Zynq UltraScale+ Device (xczu4ev) with the Xilinx H.264/H.265 Video Codec Unit v1.2.
For our use case, we're only using the encoder.

In the default setup, our application consumes the contiguous memory like this:
CMA_Usage.PNG

We are checked above behavior by monitoring the CmaTotal and CmaFree values from here: /proc/meminfo.

In the working setup above, our CMA Reserved region is set to 1000 MB as adviced from the product guide.
Product Guide: https://www.xilinx.com/support/documentation/ip_documentation/vcu/v1_2/pg252-vcu.pdf

But we want to try it for the minimum CMA Reserved region.
From the working setup above, it seems that the maximum CMA Usage is around 56 MB.
So we set a private CMA Reserved region for VCU Only at 64 MB. It seems that 64 MB is enough for our use case.

However, we encountered this error after reducing CMA Reserved region to 64 MB:

[ 117.575670] cma: cma_alloc: alloc failed, req-size: 259 pages, ret: -12
[ 117.582290] al5e a0000000.al5e: Failed internal buffers allocation, channel wasn't created
Failed to create Encoder:
/!\ encoder: memory allocation failure (firmware or ctrlsw) (135)
[E] [TreatSetStateCommand]: OMX_ErrorInsufficientResources


I've checked the CMA Size Requirements from Page 32 of this product guide:
https://www.xilinx.com/support/documentation/ip_documentation/vcu/v1_2/pg252-vcu.pdf#page=32

 

So I arrived with the following CMA Size Requirement for our use case:

Computation for Theoretical CMA Size Requirement for our use case:

Height: 480
Width: 640
Bit Depth: 8-bit
Chroma Format : 4:2:0
Encoding: AVC

computation.PNG

From above computation, it seems our working setup follows the theoretical CMA Size Requirement.
It seems 64 MB should be enough but it isn't.

So I actually have several questions:

1) Is my understanding of the CMA Size Requirement computation correct?
2) If the actual CMA Usage is around ~21 MB, why does memory allocation failure occur at 64 MB?
3) How can I properly determine the minimum CMA Size Requirement for VCU Encoder?

Any help is greatly really appreciated.

Thank you!

Tags (3)
1 Solution

Accepted Solutions
Moderator
Moderator
179 Views
Registered: ‎11-09-2015

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hi @angel_alink 

Thank you for pointing this out. I think I found my mistake.
I should have been using the VCU IP configuration settings instead of using our SW application's use case for computing the CMA Size Requirement.
Is my understanding correct?

[Florent] - Yes you need to make sure the VCU IP configuration is the closest to your need to have optimal resources utilization

 


So your configuration of the VCU will also have an impact. For example, did you enable the encode buffer in the VCU IP configuration?

No, we disabled the encoder buffer in the VCU IP configuration.

I tried to re-compute again following Table 3-11 of PG252 using our VCU IP configuration.
I came up with 84 MB wherein our application can now operate without the memory allocation failure.

computation_v2.PNG

I added the roughly 33MB we observed being used by the VCU Kernel Modules while there's no video streaming yet which, by the way, I cannot find any documentation anywhere.

Can you help me confirm if I finally understood Table 3-10 and Table 3-11 of PG252 correctly?
[Florent] - It looks correct as your values are close from the PG252


 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**

View solution in original post

8 Replies
Moderator
Moderator
314 Views
Registered: ‎11-09-2015

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hi @angel_alink 

The minimum CMA size is what is defined in the PG252. The numbers given are not random, they are the results of testing. You should follow them.

If you don't want to follow them, then you are on your own to do your own characterization. But I am not even sure you will be able to get better results.

Regards


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
Visitor angel_alink
Visitor
295 Views
Registered: ‎07-02-2019

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hello @florentw 

Thank you very much for the response.


The minimum CMA size is what is defined in the PG252. The numbers given are not random, they are the results of testing. You should follow them.

I'd like to ask for clarification. By minimum CMA size, which does it refer to in PG252 (v1.2)?

  1. Table 3-9: Encoder Block Memory Footprint
  2. Step 4 in Debugging the VCU Interface

I might have been confused. I thought the Table 3-9 shows minimum CMA size.
But if we try to allot the CMA size from Table 3-9 , we encounter the memory allocation failure.

For clarification, the minimum CMA size is 1000 MB then. Is this correct?

0 Kudos
Moderator
Moderator
275 Views
Registered: ‎11-09-2015

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hi @angel_alink 

The CMA size requirement is detailed in table 3-10. It depends on your configuration:

 

CMA.JPG

 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Visitor angel_alink
Visitor
260 Views
Registered: ‎07-02-2019

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hello @florentw ,

Thank you for the direct response again.


The CMA size requirement is detailed in table 3-10. It depends on your configuration:

Sorry for failing to specify, but this is actually what I already referred to in the first post.

Our configuration falls below 1280 x 720 (MB)  4:2:2 10-bit AVC.
Based on Table 3-10, we are expecting that 27 MB should have been the minimum CMA Requirment.

But as I've exhibited on the first post, it wasn't enough. Memory allocation failure occurs even at allocation greater than 27 MB (i.e.64 MB).

I also computed the CMA Size requriement specifically for our configuration, based on Table 3-11 of PG252 v1.2,  also provided in the first post.


If you don't want to follow them, then you are on your own to do your own characterization. But I am not even sure you will be able to get better results.

So we are following them within Table 3-10 of PG252 CMA Size Requirement.
But the resutls we are getting is not what is claimed in PG252.

Again, we actually followed that 27 MB minimum CMA Size Requirement provided in Table 3-10 (and even provided a little more),
yet the system encountered memory allocation failure.

Could it be that there should be more memory allocated than what is documented in the PG252 VCU Encoder CMA Requirements
but failed to be emphasized in the product guide?

Or, are we having an incorrect understanding of the CMA Size Requirement from PG252 and that it doesn't represent the minimum CMA allocation?

Thank you very much for the assistance.

0 Kudos
Moderator
Moderator
257 Views
Registered: ‎11-09-2015

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hi @angel_alink 

Also refer to the note one below the table:

AVC requires extra intermediate buffers when it is using multiple-cores, AVC standard does not support Tile processing
unlike HEVC, so to exploit data processing parallelism it requires two intermediate buffers.

So your configuration of the VCU will also have an impact. For example, did you enable the encode buffer in the VCU IP configuration?


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**
0 Kudos
Visitor angel_alink
Visitor
194 Views
Registered: ‎07-02-2019

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hello @florentw 

Thank you very much for patiently responding.

AVC requires extra intermediate buffers when it is using multiple-cores, AVC standard does not support Tile processing
unlike HEVC, so to exploit data processing parallelism it requires two intermediate buffers.

Thank you for pointing this out. I think I found my mistake.
I should have been using the VCU IP configuration settings instead of using our SW application's use case for computing the CMA Size Requirement.
Is my understanding correct?


So your configuration of the VCU will also have an impact. For example, did you enable the encode buffer in the VCU IP configuration?

No, we disabled the encoder buffer in the VCU IP configuration.

I tried to re-compute again following Table 3-11 of PG252 using our VCU IP configuration.
I came up with 84 MB wherein our application can now operate without the memory allocation failure.

computation_v2.PNG

I added the roughly 33MB we observed being used by the VCU Kernel Modules while there's no video streaming yet which, by the way, I cannot find any documentation anywhere.

Can you help me confirm if I finally understood Table 3-10 and Table 3-11 of PG252 correctly?

computation_v2.PNG
0 Kudos
Moderator
Moderator
180 Views
Registered: ‎11-09-2015

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hi @angel_alink 

Thank you for pointing this out. I think I found my mistake.
I should have been using the VCU IP configuration settings instead of using our SW application's use case for computing the CMA Size Requirement.
Is my understanding correct?

[Florent] - Yes you need to make sure the VCU IP configuration is the closest to your need to have optimal resources utilization

 


So your configuration of the VCU will also have an impact. For example, did you enable the encode buffer in the VCU IP configuration?

No, we disabled the encoder buffer in the VCU IP configuration.

I tried to re-compute again following Table 3-11 of PG252 using our VCU IP configuration.
I came up with 84 MB wherein our application can now operate without the memory allocation failure.

computation_v2.PNG

I added the roughly 33MB we observed being used by the VCU Kernel Modules while there's no video streaming yet which, by the way, I cannot find any documentation anywhere.

Can you help me confirm if I finally understood Table 3-10 and Table 3-11 of PG252 correctly?
[Florent] - It looks correct as your values are close from the PG252


 


Florent
Product Application Engineer - Xilinx Technical Support EMEA
**~ Don't forget to reply, give kudos, and accept as solution.~**

View solution in original post

Visitor angel_alink
Visitor
150 Views
Registered: ‎07-02-2019

Re: How to determine the minimum CMA Size Requirement for VCU Encoder?

Jump to solution

Hello @florentw ,

Thank you very much for your help and for patiently answering our queries! :)

 

0 Kudos