Project Home
Project Home
Documents
Documents
Wiki
Wiki
Discussion Forums
Discussions
Project Information
Project Info
Forum Topic - Questions about libcache on QNX6.5.0: (9 Items)
   
Questions about libcache on QNX6.5.0  
Hi group, 

In our application, I've tried to use libcache from QNX 6.5.0 to improve the memory copy.

<SW>:   QNX6.5.0
<HW>:   Cortex-A8 based TI OMAP3  

What I have done is following the instructions in QNX documentation:

1. Declare the source buffers as Cacheable
2. In the case of memory copy, invalidate the cached data (CACHE_INVAL), before transferring data into the destination 
buffers.

The result is quite good, however I have some questions:
-  What are the drawbacks of using libcache in this way?

-  Anything attention?

-  After invoking CACHE_INVAL, is it necessary to call something such as CACHE_VAL (Actually I haven't found such 
functions in documentation) explicitly to enable cache again? 
RE: Questions about libcache on QNX6.5.0  
You should provide details about the access (CPU/DMA, read/write etc..) to the source and destination buffers as well as
 their size. Without this information, it's not possible to make any kind of recommendation.

-Joel

-----Original Message-----
From: Liang Zhao [mailto:community-noreply@qnx.com] 
Sent: June 1, 2011 4:41 AM
To: ostech-core_os
Subject: Questions about libcache on QNX6.5.0

Hi group, 

In our application, I've tried to use libcache from QNX 6.5.0 to improve the memory copy.

<SW>:   QNX6.5.0
<HW>:   Cortex-A8 based TI OMAP3  

What I have done is following the instructions in QNX documentation:

1. Declare the source buffers as Cacheable
2. In the case of memory copy, invalidate the cached data (CACHE_INVAL), before transferring data into the destination 
buffers.

The result is quite good, however I have some questions:
-  What are the drawbacks of using libcache in this way?

-  Anything attention?

-  After invoking CACHE_INVAL, is it necessary to call something such as CACHE_VAL (Actually I haven't found such 
functions in documentation) explicitly to enable cache again? 



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post86309
Re: RE: Questions about libcache on QNX6.5.0  
Hi Joel,

- It's copy / read from device to memory buffers via CPU. 
  Then we need to do some analyze (pattern recognization, etc ) of the memory buffers.   

- The size of each buffer is 720x480x2 = 691200 Bytes. 
  Actually it's a YUV buffer size of a  frame.

   Thank you !
  
Re: RE: Questions about libcache on QNX6.5.0  
The first question that comes to mind, is there any reason in particular you need a copy? If your trying to get things 
to the display, you could just decode into a windows buffer or into a surface depending on the framework you're using. 
This would avoid the need to have the CPU touch the data. Which means the CPU cache would be irrelevant.

-Joel


----- Original Message -----
From: Liang Zhao [mailto:community-noreply@qnx.com]
Sent: Wednesday, June 01, 2011 09:28 PM
To: ostech-core_os <post86366@community.qnx.com>
Subject: Re: RE: Questions about libcache on QNX6.5.0

Hi Joel,

- It's copy / read from device to memory buffers via CPU. 
  Then we need to do some analyze (pattern recognization, etc ) of the memory buffers.   

- The size of each buffer is 720x480x2 = 691200 Bytes. 
  Actually it's a YUV buffer size of a  frame.

   Thank you !
  



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post86366
Re: RE: Questions about libcache on QNX6.5.0  
Hello Joel,

In our application, it's not just to display the video. There are two threads, one is for displaying the video at real-
time, another one is designed to analyze the video to get extra information (e.g. sign detection). 
This kind of algorithm usually takes some time before finish, so we need to save the frame to another buffer for further
 processing.

> The first question that comes to mind, is there any reason in particular you 
> need a copy? If your trying to get things to the display, you could just 
> decode into a windows buffer or into a surface depending on the framework 
> you're using. This would avoid the need to have the CPU touch the data. Which 
> means the CPU cache would be irrelevant.
> 
> -Joel
> 
> 
> ----- Original Message -----
> From: Liang Zhao [mailto:community-noreply@qnx.com]
> Sent: Wednesday, June 01, 2011 09:28 PM
> To: ostech-core_os <post86366@community.qnx.com>
> Subject: Re: RE: Questions about libcache on QNX6.5.0
> 
> Hi Joel,
> 
> - It's copy / read from device to memory buffers via CPU. 
>   Then we need to do some analyze (pattern recognization, etc ) of the memory 
> buffers.   
> 
> - The size of each buffer is 720x480x2 = 691200 Bytes. 
>   Actually it's a YUV buffer size of a  frame.
> 
>    Thank you !
>   
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86366


Re: Questions about libcache on QNX6.5.0  
I'm not sure I fully understand what your usage model is.

Typically for "DMA" like operations you would need to do something like:

- copy from memory buffer to device via "DMA":
   . clean the cached data so memory is up to date
   . initiate the memory transfer

- copy from device to memory buffer:
   . invalidate the cached data (actually clean+invalidate) to ensure no
     cache write-backs due to dirty cache lines can occur
   . initiate the memory transfer
   . invalidate the cached data after the transfer has completed to ensure
     that no cache lines exist due to speculative cpu accesses

You don't need to explicitly "enable" the cache - it is never disabled.
That is the reason for the second invalidate above.

	Sunil.

Liang Zhao wrote:
> Hi group,
> 
> In our application, I've tried to use libcache from QNX 6.5.0 to improve 
> the memory copy.
> 
> <SW>:   QNX6.5.0
> <HW>:   Cortex-A8 based TI OMAP3 
> 
> What I have done is following the instructions in QNX documentation:
> 
> 1. Declare the source buffers as Cacheable
> 2. In the case of memory copy, invalidate the cached data (CACHE_INVAL), 
> before transferring data into the destination buffers.
> 
> The result is quite good, however I have some questions:
> -  What are the drawbacks of using libcache in this way?
> 
> -  Anything attention?
> 
> -  After invoking CACHE_INVAL, is it necessary to call something such as 
> CACHE_VAL (Actually I haven't found such functions in documentation) 
> explicitly to enable cache again?
> 
> 
> 
> _______________________________________________
> 
> OSTech
> http://community.qnx.com/sf/go/post86309
> 
Re: Questions about libcache on QNX6.5.0  
Sunil,

        I got it.
       Our case is the later one --- "copy from device to memory buffer".

       We need to do the copy operation from time to time because we need to analyze the data coming from cameras.  

       Does it mean ----
      
       The  twice invalidations mentioned by you (before & after data transfer) have to done every time we copy the data
 ? 
     
Re: Questions about libcache on QNX6.5.0  
You don't need to do the cache invalidation because the data is copied by the cpu, when the cpu touches the data, the 
cache is updated automatically. You only need to do the cache invalidation if the data is copied by dma. However, if the
 data is going to be used by another device, you must do a cache flush.
Jerry Sui | Jsui@qnx.com
O: 613-591-0836x2904 C: 613-240-9239
Cisco Support Team email: cisco_support@qnx.com‬

Sent from my blackberry

----- Original Message -----
From: Liang Zhao [mailto:community-noreply@qnx.com]
Sent: Wednesday, June 01, 2011 09:35 PM
To: ostech-core_os <post86367@community.qnx.com>
Subject: Re: Questions about libcache on QNX6.5.0

Sunil,

        I got it.
       Our case is the later one --- "copy from device to memory buffer".

       We need to do the copy operation from time to time because we need to analyze the data coming from cameras.  

       Does it mean ----
      
       The  twice invalidations mentioned by you (before & after data transfer) have to done every time we copy the data
 ? 
     



_______________________________________________

OSTech
http://community.qnx.com/sf/go/post86367

Re: Questions about libcache on QNX6.5.0  
Hi All,

could you please share some sample code snippets for usage of  DMA memory allocation, cache operations.

Thanks,
Ravinder Are