Skip to content

Commit

Permalink
Correction in python script for compute graph
Browse files Browse the repository at this point in the history
Buffer numbering issue for memory optimzation and buffer sharing
  • Loading branch information
christophe0606 committed Sep 14, 2022
1 parent 06c439f commit 142dcec
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmsisdsp/cg/static/scheduler/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def __init__(self):
# Prefix to add before the global FIFO buffer names
self.prefix = ""

# Experimental so disbaled by default
# Experimental so disabled by default
self.memoryOptimization = False

# Path to CG module for Python simu
Expand Down
15 changes: 11 additions & 4 deletions cmsisdsp/cg/static/scheduler/description.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def initializeFIFODescriptions(self,config,allFIFOs, fifoLengths,maxTime):
allBuffers=[]

# Compute a graph describing when FIFOs are used at the same time
# The use graph coloring to allocate buffer to those FIFOs.
# Then use graph coloring to allocate buffer to those FIFOs.
# Then size the buffer based on the longest FIFO using it
if config.memoryOptimization:
G = nx.Graph()
Expand All @@ -376,7 +376,7 @@ def initializeFIFODescriptions(self,config,allFIFOs, fifoLengths,maxTime):
currentTime=0
while currentTime<=maxTime:
# Remove fifo no more active.
# Thei stop time < currenTime
# Their stop time < currentTime
toDelete=[]
for k in active:
start,stop=k._liveInterval
Expand All @@ -394,9 +394,11 @@ def initializeFIFODescriptions(self,config,allFIFOs, fifoLengths,maxTime):
start,stop=fifo._liveInterval
# If a src -> node -> dst
# At time t, node will read for src and the stop time
# will be currentTime t.
# will be currentTime t because once read
# the buffer can be reused.
# And it will write to dst and the start time will be
# currentTime
# currentTime because once written the buffer
# cannot be used again until it has been read.
# So, src and dst are both live at this time.
# Which means the condition on the stop time must be
# stop >= currentTime and not a strict comparison
Expand All @@ -410,6 +412,7 @@ def initializeFIFODescriptions(self,config,allFIFOs, fifoLengths,maxTime):

# To debug and display the graph
if False:
import matplotlib.pyplot as plt
labels={}
for n in G.nodes:
labels[n]="%s -> %s" % (n.src.owner.nodeName,n.dst.owner.nodeName)
Expand Down Expand Up @@ -450,6 +453,9 @@ def initializeFIFODescriptions(self,config,allFIFOs, fifoLengths,maxTime):
sharedA = FifoBuffer(theID,CType(UINT8),maxSizes[theID])
allBuffers.append(sharedA)


# bufferID must start after all shared buffers
bufferID = bufferID + 1
for fifo in allFIFOs:
# Use shared buffer if memory optimization
if fifo.isArray and config.memoryOptimization:
Expand All @@ -472,6 +478,7 @@ def initializeFIFODescriptions(self,config,allFIFOs, fifoLengths,maxTime):

#for fifo in allFIFOs:
# fifo.dump()

return(allBuffers)


Expand Down
3 changes: 1 addition & 2 deletions cmsisdsp/cg/static/scheduler/templates/codeSwitch.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,7 @@
{% block schedArray %}
/*
Description of the scheduling. It is a list of nodes to call.
The values are indexes in the previous array.
Description of the scheduling.
*/
static unsigned int schedule[{{schedLen}}]=
Expand Down
2 changes: 1 addition & 1 deletion cmsisdsp/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
# Python wrapper version
__version__ = "1.7.0"
__version__ = "1.7.1"

0 comments on commit 142dcec

Please sign in to comment.