hi, everyone!
What's the difference between persistent memory and scratch memory? how can I use them when I write my own algorithm?
put DATA or Program into them,is their efficiency same?
Thanks very much!
This thread has been locked.
If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.
hi, everyone!
What's the difference between persistent memory and scratch memory? how can I use them when I write my own algorithm?
put DATA or Program into them,is their efficiency same?
Thanks very much!
William, I found an ppt in davinci wiki web site. The ppt describes both of memory briefly.
One of demonstrations about the two memories is :
 Scratch : used by algorithm during execution only
 Persistent : used to store state information during instance lifespan
(quote from this ppt)
But I think an algorithm "lifespan" is equal with "execution period". I need TI experts to help me to explain it.
Thanks.
Life span refers to the time period between codec instance creation (e.g. via VIDENC_create or similar) and deletion (e.g. via VIDENC_delete or similar); the codec algorithm does not necessarily have to be processing anything.
I believe the PPT Lorry pointed to does a pretty good job of explaining the differences. My understanding is that you always need a small amount of persistent memory to store the state and maybe entry point information of the codec functions (nothing more than data-structure); additionally, a video codec may want to set some persistent memory aside to do its work instead of having to allocate/deallocate memory for every macro-block in every frame it needs to process; persistent memory normally resides in less expensive external RAM. scratch memory is typically used to store small temporary data and normally resides in limited and more expensice internal RAM.
I may regret giving this example, but here it goes. Altough it is not a one to one correspondance, there is some correlation in thinking of persistent memory as coming from the heap, and scratch memory as coming from the stack. Of course it is not quite the same, but just to illustrate when you may want to use one versus the other for our C programmers more familiar with heap/stack nomenclature.
Juan,
From the difference between "persistent memory" and "scratch memory", I think persistent memory is as stack , and scratch memory should be like a heap.
As I know, stack memory stores some static variables and function address. And heap stores some temperary varianbles.
For example:
int i = 0; // i should be stored in stack
int main(){
foo(); // the address of "foo" which is called by main function should be stored in stack;
return 0;
}
void foo()
{
int j = 0; // "j" is stored in heap;
// .......
}
Is that right?
Lorry
Lorry,
Although it helps me visualize persistent and scratch memeory by associating them with heap and stack; I do not believe there is a one to one correspondance. This is why I was hesitant to make the analogy, but thought it may help others...so I went ahead and did it.
That said, you are interpreting my analogy as intended; but please note that there is not a one to one correspondance necessarily. Hope it does not cause too much confusion!
Lorry,
"Stack" and "heap" is not an appropriate analogy because ALL of the memory can come from the heap. When the instance is created it would be malloc'd from the heap and when it is deleted it would be free.
The difference between the two comes down to whether the memory can be shared, like a UNION in C. The scratch memory can be shared amongst several algorithms allowing for efficient use of the precious internal memory. This is why algorithms with shared scratch memory MUST be of the same priority level. Otherwise one might pre-empt the other and trash the shared scratch.
Brad
Thanks for all response!
From above response,I have a little confusion, does scratch memory correspondance to heap,persistent memory correspondance to stack? or scratch memory normally resides in internal RAM,persistent memory normally resides in extern RAM?
How to distinguish the scratch and persistent memory?
Is their efficiency same ?
Thanks very much!
william,
william said:From above response,I have a little confusion, does scratch memory correspondance to heap,persistent memory correspondance to stack? or scratch memory normally resides in internal RAM,persistent memory normally resides in extern RAM?
As Brad said above, ""Stack" and "heap" is not an appropriate analogy because ALL of the memory can come from the heap. " . I think "scratch memory" and "persistent memory" come from "DDRALGHEAP" . So I believe both of momeries are allocated from external RAM. Another reason why both of them come from the external, I think, because the internal RAM is very small, sometimes you need a big block of memory to deal with your video signal. So the internal can not afford it.
william said:
How to distinguish the scratch and persistent memory?
Is their efficiency same ?
Please see Section 2.3.2 of this document for a more complete description. It's only a couple pages:
http://www-s.ti.com/sc/techlit/spru352
Also, I just wanted to point out that when this memory is dynamically allocated there is nothing requiring it to come from external memory. An algorithm requests memory through the IALG interface by filling out a table. There are independent fields to specify whether a block of memory is scratch or persistent, as well as whether it should come from internal or external memory. The internal memory is a good candidate to use for "scratch" memory since that enables the same memory to be used by multiple algorithms (i.e. the scratch memory can be a UNION of all the scratch requirements within a particular scratch group).