mirror of
https://github.com/alicevision/Meshroom.git
synced 2025-07-23 19:47:39 +02:00
[core] parallelization: introduce the notion of node 'size'
* node size is an estimation of the number of element to process on a given node, that may be used for parallelization. * replace the explicit reference to an attribute on a node (Parallelization.inputListParamName) * size can be: * dynamic: depends on the size of the node connected to a specific Attribute * static
This commit is contained in:
parent
877025090e
commit
e8c579c942
13 changed files with 56 additions and 18 deletions
|
@ -223,8 +223,7 @@ class Range:
|
||||||
|
|
||||||
|
|
||||||
class Parallelization:
|
class Parallelization:
|
||||||
def __init__(self, inputListParamName='', staticNbBlocks=0, blockSize=0):
|
def __init__(self, staticNbBlocks=0, blockSize=0):
|
||||||
self.inputListParamName = inputListParamName
|
|
||||||
self.staticNbBlocks = staticNbBlocks
|
self.staticNbBlocks = staticNbBlocks
|
||||||
self.blockSize = blockSize
|
self.blockSize = blockSize
|
||||||
|
|
||||||
|
@ -234,18 +233,10 @@ class Parallelization:
|
||||||
node:
|
node:
|
||||||
Returns: (blockSize, fullSize, nbBlocks)
|
Returns: (blockSize, fullSize, nbBlocks)
|
||||||
"""
|
"""
|
||||||
if self.inputListParamName:
|
size = node.size
|
||||||
# Look for this attribute on preceding nodes
|
if self.blockSize:
|
||||||
parentNodes, edges = node.graph.dfsOnFinish(startNodes=[node])
|
nbBlocks = int(math.ceil(float(size) / float(self.blockSize)))
|
||||||
for parentNode in parentNodes:
|
return (self.blockSize, size, nbBlocks)
|
||||||
if self.inputListParamName in parentNode.getAttributes().keys():
|
|
||||||
fullSize = len(parentNode.attribute(self.inputListParamName))
|
|
||||||
nbBlocks = int(math.ceil(float(fullSize) / float(self.blockSize)))
|
|
||||||
return (self.blockSize, fullSize, nbBlocks)
|
|
||||||
# No attribute has been found (parallelization won't work): raise
|
|
||||||
raise RuntimeError(
|
|
||||||
'Cannot find the "inputListParamName": "{}" in the list of input nodes: {} for node: {}'.format(
|
|
||||||
self.inputListParamName, parentNodes, node.name))
|
|
||||||
if self.staticNbBlocks:
|
if self.staticNbBlocks:
|
||||||
return (1, self.staticNbBlocks, self.staticNbBlocks)
|
return (1, self.staticNbBlocks, self.staticNbBlocks)
|
||||||
return None
|
return None
|
||||||
|
@ -262,6 +253,27 @@ class Parallelization:
|
||||||
return ranges
|
return ranges
|
||||||
|
|
||||||
|
|
||||||
|
class DynamicNodeSize(object):
|
||||||
|
def __init__(self, param):
|
||||||
|
self._param = param
|
||||||
|
|
||||||
|
def computeSize(self, node):
|
||||||
|
param = node.attribute(self._param)
|
||||||
|
if param.isLink:
|
||||||
|
return param.getLinkParam().node.size
|
||||||
|
if isinstance(param.desc, ListAttribute):
|
||||||
|
return len(param)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
class StaticNodeSize(object):
|
||||||
|
def __init__(self, size):
|
||||||
|
self._size = size
|
||||||
|
|
||||||
|
def computeSize(self, node):
|
||||||
|
return self._size
|
||||||
|
|
||||||
|
|
||||||
class Node(object):
|
class Node(object):
|
||||||
"""
|
"""
|
||||||
"""
|
"""
|
||||||
|
@ -273,6 +285,7 @@ class Node(object):
|
||||||
packageVersion = ''
|
packageVersion = ''
|
||||||
inputs = []
|
inputs = []
|
||||||
outputs = []
|
outputs = []
|
||||||
|
size = StaticNodeSize(1)
|
||||||
parallelization = None
|
parallelization = None
|
||||||
|
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
|
|
|
@ -621,6 +621,7 @@ class Node(BaseObject):
|
||||||
self.graph = None # type: Graph
|
self.graph = None # type: Graph
|
||||||
self._chunks = []
|
self._chunks = []
|
||||||
self._cmdVars = {}
|
self._cmdVars = {}
|
||||||
|
self._size = 0
|
||||||
self._attributes = DictModel(keyAttrName='name', parent=self)
|
self._attributes = DictModel(keyAttrName='name', parent=self)
|
||||||
self.attributesPerUid = defaultdict(set)
|
self.attributesPerUid = defaultdict(set)
|
||||||
self._initFromDesc()
|
self._initFromDesc()
|
||||||
|
@ -795,6 +796,7 @@ class Node(BaseObject):
|
||||||
chunk.updateStatisticsFromCache()
|
chunk.updateStatisticsFromCache()
|
||||||
|
|
||||||
def updateInternals(self):
|
def updateInternals(self):
|
||||||
|
self.setSize(self.nodeDesc.size.computeSize(self))
|
||||||
if self.isParallelized:
|
if self.isParallelized:
|
||||||
try:
|
try:
|
||||||
ranges = self.nodeDesc.parallelization.getRanges(self)
|
ranges = self.nodeDesc.parallelization.getRanges(self)
|
||||||
|
@ -860,6 +862,15 @@ class Node(BaseObject):
|
||||||
def statusNames(self):
|
def statusNames(self):
|
||||||
return [s.status.name for s in self.status]
|
return [s.status.name for s in self.status]
|
||||||
|
|
||||||
|
def getSize(self):
|
||||||
|
return self._size
|
||||||
|
|
||||||
|
def setSize(self, value):
|
||||||
|
if self._size == value:
|
||||||
|
return
|
||||||
|
self._size = value
|
||||||
|
self.sizeChanged.emit()
|
||||||
|
|
||||||
def __repr__(self):
|
def __repr__(self):
|
||||||
return self.name
|
return self.name
|
||||||
|
|
||||||
|
@ -872,6 +883,8 @@ class Node(BaseObject):
|
||||||
depth = Property(int, depth.fget, notify=depthChanged)
|
depth = Property(int, depth.fget, notify=depthChanged)
|
||||||
chunksChanged = Signal()
|
chunksChanged = Signal()
|
||||||
chunks = Property(Variant, getChunks, notify=chunksChanged)
|
chunks = Property(Variant, getChunks, notify=chunksChanged)
|
||||||
|
sizeChanged = Signal()
|
||||||
|
size = Property(int, getSize, notify=sizeChanged)
|
||||||
|
|
||||||
WHITE = 0
|
WHITE = 0
|
||||||
GRAY = 1
|
GRAY = 1
|
||||||
|
|
|
@ -4,6 +4,7 @@ from meshroom.core import desc
|
||||||
class CameraConnection(desc.CommandLineNode):
|
class CameraConnection(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_cameraConnection {allParams}'
|
commandLine = 'aliceVision_cameraConnection {allParams}'
|
||||||
|
size = desc.DynamicNodeSize('ini')
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
desc.File(
|
desc.File(
|
||||||
|
|
|
@ -45,6 +45,8 @@ class CameraInit(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_cameraInit {allParams}'
|
commandLine = 'aliceVision_cameraInit {allParams}'
|
||||||
|
|
||||||
|
size = desc.DynamicNodeSize('viewpoints')
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
desc.ListAttribute(
|
desc.ListAttribute(
|
||||||
name="viewpoints",
|
name="viewpoints",
|
||||||
|
|
|
@ -4,7 +4,8 @@ class DepthMap(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_depthMapEstimation {allParams}'
|
commandLine = 'aliceVision_depthMapEstimation {allParams}'
|
||||||
gpu = desc.Level.INTENSIVE
|
gpu = desc.Level.INTENSIVE
|
||||||
parallelization = desc.Parallelization(inputListParamName='viewpoints', blockSize=3)
|
size = desc.DynamicNodeSize('ini')
|
||||||
|
parallelization = desc.Parallelization(blockSize=3)
|
||||||
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
|
|
@ -4,7 +4,8 @@ class DepthMapFilter(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_depthMapFiltering {allParams}'
|
commandLine = 'aliceVision_depthMapFiltering {allParams}'
|
||||||
gpu = desc.Level.NORMAL
|
gpu = desc.Level.NORMAL
|
||||||
parallelization = desc.Parallelization(inputListParamName='viewpoints', blockSize=10)
|
size = desc.DynamicNodeSize('ini')
|
||||||
|
parallelization = desc.Parallelization(blockSize=10)
|
||||||
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
|
|
@ -5,7 +5,8 @@ from meshroom.core import desc
|
||||||
class FeatureExtraction(desc.CommandLineNode):
|
class FeatureExtraction(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_featureExtraction {allParams}'
|
commandLine = 'aliceVision_featureExtraction {allParams}'
|
||||||
parallelization = desc.Parallelization(inputListParamName='viewpoints', blockSize=10)
|
size = desc.DynamicNodeSize('input')
|
||||||
|
parallelization = desc.Parallelization(blockSize=10)
|
||||||
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
|
|
@ -5,7 +5,8 @@ from meshroom.core import desc
|
||||||
class FeatureMatching(desc.CommandLineNode):
|
class FeatureMatching(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_featureMatching {allParams}'
|
commandLine = 'aliceVision_featureMatching {allParams}'
|
||||||
parallelization = desc.Parallelization(inputListParamName='viewpoints', blockSize=20)
|
size = desc.DynamicNodeSize('input')
|
||||||
|
parallelization = desc.Parallelization(blockSize=20)
|
||||||
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
commandLineRange = '--rangeStart {rangeStart} --rangeSize {rangeBlockSize}'
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
|
|
|
@ -6,6 +6,7 @@ from meshroom.core import desc
|
||||||
class ImageMatching(desc.CommandLineNode):
|
class ImageMatching(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_imageMatching {allParams}'
|
commandLine = 'aliceVision_imageMatching {allParams}'
|
||||||
|
size = desc.DynamicNodeSize('input')
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
desc.File(
|
desc.File(
|
||||||
|
|
|
@ -3,6 +3,7 @@ from meshroom.core import desc
|
||||||
class Meshing(desc.CommandLineNode):
|
class Meshing(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_meshing {allParams}'
|
commandLine = 'aliceVision_meshing {allParams}'
|
||||||
|
|
||||||
cpu = desc.Level.INTENSIVE
|
cpu = desc.Level.INTENSIVE
|
||||||
ram = desc.Level.INTENSIVE
|
ram = desc.Level.INTENSIVE
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ from meshroom.core import desc
|
||||||
class PrepareDenseScene(desc.CommandLineNode):
|
class PrepareDenseScene(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_prepareDenseScene {allParams}'
|
commandLine = 'aliceVision_prepareDenseScene {allParams}'
|
||||||
|
size = desc.DynamicNodeSize('input')
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
desc.File(
|
desc.File(
|
||||||
|
|
|
@ -6,6 +6,7 @@ import os
|
||||||
|
|
||||||
|
|
||||||
class Publish(desc.Node):
|
class Publish(desc.Node):
|
||||||
|
size = desc.DynamicNodeSize('inputFiles')
|
||||||
inputs = [
|
inputs = [
|
||||||
desc.ListAttribute(
|
desc.ListAttribute(
|
||||||
elementDesc=desc.File(
|
elementDesc=desc.File(
|
||||||
|
|
|
@ -5,6 +5,7 @@ from meshroom.core import desc
|
||||||
class StructureFromMotion(desc.CommandLineNode):
|
class StructureFromMotion(desc.CommandLineNode):
|
||||||
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
internalFolder = '{cache}/{nodeType}/{uid0}/'
|
||||||
commandLine = 'aliceVision_incrementalSfM {allParams}'
|
commandLine = 'aliceVision_incrementalSfM {allParams}'
|
||||||
|
size = desc.DynamicNodeSize('input')
|
||||||
|
|
||||||
inputs = [
|
inputs = [
|
||||||
desc.File(
|
desc.File(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue