www.ti.com
4.1DataMemory
4.1.1HeapMemory
DataMemory
TheonlyresourcesconsumedbyeXpressDSP-compliantalgorithmsareMIPSandmemory.AllI/O,
peripheralcontrol,devicemanagement,andschedulingismanagedbytheapplication—notthe
algorithm.Thus,weneedtocharacterizecodeanddatamemoryrequirementsandworst-caseexecution
time.
Thereisoneimportantaddition,however.Itispossibleforanalgorithmtoinadvertentlydisruptthe
schedulingofthreadsinasystembydisablinginterruptsforextendedperiods.Sinceitisnotpossiblefora
schedulertogetcontroloftheCPUwhileinterruptsaredisabled,itisimportantthatalgorithmsminimize
thedurationoftheseperiodsanddocumenttheworst-caseduration.Itisimportanttorealizethat,dueto
thepipelineofmodernDSPs,therearemanysituationswhereinterruptsareimplicitlydisabled;e.g.,in
somezero-overheadloops.Thus,evenifanalgorithmdoesnotexplicitlydisableinterrupts,itmaycause
interruptstobedisabledforextendedperiods.
Alldatamemoryforanalgorithmfallsintooneofthreecategories:
•Heapmemory-datamemorythatispotentially(re)allocatedatrun-time;
•Stackmemory-theCrun-timestack;and
•Staticdata-datathatisfixedatprogrambuildtime.
Heapmemoryisbulkmemorythatisusedbyafunctiontoperformitscomputations.Fromthefunction's
pointofview,thelocationandcontentsofthismemorymaypersistacrossfunctionscalls,maybe
(re)allocatedatrun-time,anddifferentbuffersmaybeinphysicallydistinctmemories.Stackmemory,on
theotherhand,isscratchmemorywhoselocationmayvarybetweenconsecutivefunctioncalls,is
allocatedandfreedatrun-time,andismanagedusingaLIFO(LastInFirstOut)allocationpolicy.Finally,
staticdataisanydatathatisallocatedatdesign-time(i.e.,program-buildtime)andwhoselocationisfixed
duringrun-time.
Intheremainderofthissection,wedefineperformancemetricsthatdescribeanalgorithm'sdatamemory
requirements.
Heapmemoryisrun-time(re)allocablebulkmemorythatisusedbyafunctiontoperformitscomputations.
Fromafunction'spointofview,thelocationandcontentsofthismemorymaypersistacrossfunctions
calls,maybe(re)allocatedatrun-time,anddifferentbuffersmaybeinphysicallydistinctmemories.
Itisimportanttonotethatheapmemorycanbeallocatedatdesign-timeandavoidthecodespace
overheadofrun-timememorymanagement.Theonlyrequirementisthatallfunctionsthataccessthis
memorymustassumethatitmaybeallocatedatrun-time.Thus,thesefunctionsmustreferencethis
memoryviaapointerratherthanadirectreferencetoanamedbuffer.
Rule19
Allalgorithmsmustcharacterizetheirworst-caseheapdatamemoryrequirements(including
alignment).
Allalgorithmsmustcharacterizetheirworst-casedatamemoryrequirementsbyfillingoutthetablebelow.
Eachentryshouldcontainapairofnumberscorrespondingtothesize(in8-bitbytes)requiredandan
alignment(in8-bitbytes).Ifnospecialalignmentisrequired,thealignmentnumbershouldbesettozero.
Notethatthenumberssuppliedmayrepresentaggregatetotals.Forexample,ifanalgorithmrequirestwo
unalignedExternaldatabuffers,itmayreportthesumofthesizesofthesebuffers.
DARAMSARAMExternal
SizeAlignSizeAlignSizeAlign
Scratch001920000
Persistent000014400
AlgorithmPerformanceCharacterization 38SPRU352G–June2005–RevisedFebruary2007
SubmitDocumentationFeedback