From 5b41cecb4498398e2264cfda4f8fa129f9094ed3 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Mon, 4 Mar 2024 10:09:27 +0100 Subject: [PATCH 1/2] enable lazy eval in config Signed-off-by: Csaba Kiraly # Conflicts: # DAS/validator.py --- smallConf.py | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/smallConf.py b/smallConf.py index a166cec..065561c 100644 --- a/smallConf.py +++ b/smallConf.py @@ -111,3 +111,18 @@ def nextShape(): chiR = chiC = chi shape = Shape(blockSizeR, blockSizeRK, blockSizeC, blockSizeCK, nn, fm, fr, class1ratio, chiR, chiC, vpn1, vpn2, netDegree, bwUplinkProd, bwUplink1, bwUplink2, run) yield shape + +def evalConf(self, param, shape = None): + '''Allow lazy evaluation of params in various forms + + Examples: + sendLineUntilR = "shape.blockSizeRK" + sendLineUntilC = lambda shape : shape.blockSizeCK + perNodeQueue = "self.amIproposer" + ''' + if callable(param): + return param(shape) + elif isinstance(param, str): + return eval(param) + else: + return param From b22a096cbc3fdb02aea6b2062cb3774d99c21e29 Mon Sep 17 00:00:00 2001 From: Csaba Kiraly Date: Fri, 1 Mar 2024 12:32:19 +0100 Subject: [PATCH 2/2] set number of copies of rows/columns published Sets how many copies are sent out by the block producer over rows and over columns. Note, previously this was set to match netDegree in both dimensions. We keep this default. Signed-off-by: Csaba Kiraly --- DAS/simulator.py | 7 ++++--- smallConf.py | 5 +++++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/DAS/simulator.py b/DAS/simulator.py index a51a291..0253bd4 100644 --- a/DAS/simulator.py +++ b/DAS/simulator.py @@ -41,7 +41,8 @@ class Simulator: # pushed out by the proposer. # 1: the data is sent out exactly once on rows and once on columns (2 copies in total) # self.shape.netDegree: default behavior similar (but not same) to previous code - self.proposerPublishTo = self.shape.netDegree # TODO: make this an external parameter + self.proposerPublishToR = config.evalConf(self, config.proposerPublishToR, shape) + self.proposerPublishToC = config.evalConf(self, config.proposerPublishToR, shape) def initValidators(self): """It initializes all the validators in the network.""" @@ -171,12 +172,12 @@ class Simulator: for v in self.validators: if (self.proposerPublishOnly and v.amIproposer): for id in v.rowIDs: - count = min(self.proposerPublishTo, len(rowChannels[id])) + count = min(self.proposerPublishToR, len(rowChannels[id])) publishTo = random.sample(rowChannels[id], count) for vi in publishTo: v.rowNeighbors[id].update({vi.ID : Neighbor(vi, 0, self.shape.blockSizeR)}) for id in v.columnIDs: - count = min(self.proposerPublishTo, len(columnChannels[id])) + count = min(self.proposerPublishToC, len(columnChannels[id])) publishTo = random.sample(columnChannels[id], count) for vi in publishTo: v.columnNeighbors[id].update({vi.ID : Neighbor(vi, 1, self.shape.blockSizeC)}) diff --git a/smallConf.py b/smallConf.py index 065561c..530fb7e 100644 --- a/smallConf.py +++ b/smallConf.py @@ -62,6 +62,11 @@ blockSizes = range(64, 113, 128) # Per-topic mesh neighborhood size netDegrees = range(8, 9, 2) +# How many copies are sent out by the block producer +# Note, previously this was set to match netDegree +proposerPublishToR = "shape.netDegree" +proposerPublishToC = "shape.netDegree" + # number of rows and columns a validator is interested in chis = range(2, 3, 2)