Skip to content
Snippets Groups Projects
Commit 39048ab5 authored by EXT Jean-Matthieu Etancelin's avatar EXT Jean-Matthieu Etancelin
Browse files

Automatic disjoint tasks redistribute inserts.

parent e066d32d
No related branches found
No related tags found
2 merge requests!24Resolve "Add python3.x support",!15WIP: Resolve "HySoP with tasks"
......@@ -10,7 +10,7 @@ from hysop.core.graph.graph import not_implemented, initialized, discretized, \
from hysop.core.graph.graph import ComputationalGraphNodeData
from hysop.core.graph.computational_node import ComputationalGraphNode
from hysop.core.graph.computational_operator import ComputationalGraphOperator
from hysop.core.graph.node_generator import ComputationalGraphNodeGenerator
from hysop.core.graph.node_generator import ComputationalGraphNodeGenerator, HiddenOperator
from hysop.core.graph.node_requirements import NodeRequirements, OperatorRequirements
from hysop.core.memory.memory_request import MultipleOperatorMemoryRequests
from hysop.fields.field_requirements import MultiFieldRequirements
......@@ -622,6 +622,10 @@ class ComputationalGraph(ComputationalGraphNode):
nodes = node.generate()
assert (nodes is not None), node
self.push_nodes(*nodes)
elif isinstance(node, HiddenOperator):
# Fuse al HiddenOperators
if len(self.nodes) == 0 or not isinstance(self.nodes[-1], HiddenOperator):
self.nodes.append(node)
else:
msg = 'Given node is not an instance of ComputationalGraphNode (got a {}).'
raise ValueError(msg.format(node.__class__))
......
from hysop.constants import Implementation, Backend, implementation_to_backend
from hysop.tools.decorators import debug
from hysop.tools.types import check_instance, first_not_None
from hysop.core.graph.node_generator import ComputationalGraphNodeGenerator
from hysop.core.graph.node_generator import ComputationalGraphNodeGenerator, HiddenOperator
from hysop.core.graph.graph import not_implemented
from hysop.fields.continuous_field import Field
......@@ -102,7 +102,7 @@ class ComputationalGraphNodeFrontend(ComputationalGraphNodeGenerator):
# Skip not on-task operators very early
if 'mpi_params' in self.impl_kwds.keys():
if not self.impl_kwds['mpi_params'].on_task:
return tuple()
return (HiddenOperator(mpi_params=self.impl_kwds['mpi_params']), )
op = self.impl(**self.impl_kwds)
except:
sargs = ['*{} = {}'.format(k, v.__class__)
......
This diff is collapsed.
......@@ -5,6 +5,37 @@ from hysop.tools.types import first_not_None
from hysop.core.graph.computational_node import ComputationalGraphNode
class HiddenOperator(object):
"""Object that is inserted in node list in replacement of out-of-taks operators.
This object should pass the intialization through graph building where it is definitely removed.
This object is an helper to build a graph with appropriates Inter-Task redistributes."""
def __init__(self, mpi_params):
self.mpi_params = mpi_params
self.name = ''
def available_methods(self, *args, **kwargs):
return {}
def get_node_requirements(self, *args, **kwargs):
return tuple()
def available_methods(self, *args, **kwargs):
return {}
def get_domains(self, *args, **kwargs):
return {}
def pre_initialize(self, *args, **kwargs):
pass
def initialize(self, *args, **kwargs):
pass
def post_initialize(self, *args, **kwargs):
pass
class ComputationalGraphNodeGenerator(object):
"""
A class that can generate multiple hysop.core.graph.ComputationalGraphNode.
......@@ -73,6 +104,8 @@ class ComputationalGraphNodeGenerator(object):
raise RuntimeError(msg)
self.candidate_input_tensors.update(op.candidate_input_tensors)
self.candidate_output_tensors.update(op.candidate_output_tensors)
elif isinstance(op, HiddenOperator):
nodes = (op, )
else:
msg = 'Unknown node type {}.'.format(op.__class__)
raise TypeError(msg)
......
......@@ -323,11 +323,17 @@ class RedistributeInter(RedistributeOperatorBase):
*be CartesianTopology topologies with the same global resolution
*be defined on different communicators
"""
# Base class initialisation
super(RedistributeInter, self).__init__(**kwds)
self._other_task_id = kwds['other_task_id']
self._synchronize(kwds['source_topo'], kwds['target_topo'])
if kwds:
# Base class initialisation
super(RedistributeInter, self).__init__(**kwds)
self._other_task_id = kwds['other_task_id']
self._synchronize(kwds['source_topo'], kwds['target_topo'])
else:
# Fake init. Should be called again later
self.name = "TempName"
self.mpi_params = None
self._input_fields_to_dump = []
self._output_fields_to_dump = []
def _synchronize(self, tin, tout):
"""Ensure that the two redistributes are operating on the same variable"""
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment