From b0092101b35c9cb62f67fb16672e9b86f66ff3a0 Mon Sep 17 00:00:00 2001
From: Jean-Matthieu Etancelin <jean-matthieu.etancelin@univ-pau.fr>
Date: Fri, 19 Jun 2020 11:29:22 +0200
Subject: [PATCH] fixup for sequential runs (without tasks)

---
 hysop/core/graph/computational_node_frontend.py | 3 ++-
 hysop/core/graph/graph_builder.py               | 3 ++-
 hysop/core/graph/node_generator.py              | 3 ++-
 hysop/problem.py                                | 4 +++-
 4 files changed, 9 insertions(+), 4 deletions(-)

diff --git a/hysop/core/graph/computational_node_frontend.py b/hysop/core/graph/computational_node_frontend.py
index 55bc7d4f0..930f09146 100644
--- a/hysop/core/graph/computational_node_frontend.py
+++ b/hysop/core/graph/computational_node_frontend.py
@@ -102,7 +102,8 @@ 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 (HiddenOperator(mpi_params=self.impl_kwds['mpi_params']), )
+                    return (HiddenOperator(domain=first_not_None(field.domain for field in self.impl_kwds['variables'].keys()),
+                                           mpi_params=self.impl_kwds['mpi_params']), )
             op = self.impl(**self.impl_kwds)
         except:
             sargs = ['*{} = {}'.format(k, v.__class__)
diff --git a/hysop/core/graph/graph_builder.py b/hysop/core/graph/graph_builder.py
index baa9113d2..8833f452f 100644
--- a/hysop/core/graph/graph_builder.py
+++ b/hysop/core/graph/graph_builder.py
@@ -336,6 +336,7 @@ class GraphBuilder(object):
                 # add operator node and fill vertex properties
                 opnode = self.new_node(op, subgraph, current_level, node, node_id, opvertex)
                 if isinstance(node, RedistributeInter):
+                    assert self.search_intertasks_ops
                     # Save graph building state for filling next nodes topologies after graph completion
                     redistribute_inter.append((node_id, node, subgraph, node_ops, node_vertices, from_subgraph, opvertex, op, opnode))
                     gprint("  *Will be handled later")
@@ -703,7 +704,7 @@ class GraphBuilder(object):
                         is_graph_updated = _closure(f, t, double_check_inputs[f][t], self.topology_states[f])
 
         # Final intertask redistributes as closure
-        if (current_level == 0) and outputs_are_inputs:
+        if self.search_intertasks_ops and (current_level == 0) and outputs_are_inputs:
             available_elems, needed_elems = {}, {}
             needed_elems.update(self.input_fields)
             available_elems.update(self.output_fields)
diff --git a/hysop/core/graph/node_generator.py b/hysop/core/graph/node_generator.py
index d195f9295..9c342ce11 100644
--- a/hysop/core/graph/node_generator.py
+++ b/hysop/core/graph/node_generator.py
@@ -10,8 +10,9 @@ class HiddenOperator(object):
     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):
+    def __init__(self, mpi_params, domain):
         self.mpi_params = mpi_params
+        self.domain = domain
         self.name = ''
 
     def available_methods(self, *args, **kwargs):
diff --git a/hysop/problem.py b/hysop/problem.py
index 859c6ce13..358ef95c4 100644
--- a/hysop/problem.py
+++ b/hysop/problem.py
@@ -53,8 +53,10 @@ class Problem(ComputationalGraph):
         for node in [_ for _ in self.nodes if isinstance(_, Problem)]:
             node.initialize(outputs_are_inputs=True, topgraph_method=None, is_root=True)
             node.discretize()
+        search_intertasks_ops = all([node.domain.has_tasks for node in self.nodes])
         self.initialize(outputs_are_inputs=outputs_are_inputs,
-                        topgraph_method=None, is_root=True, search_intertasks_ops=True)
+                        topgraph_method=None, is_root=True,
+                        search_intertasks_ops=search_intertasks_ops)
 
         if (args is not None) and args.stop_at_discretization:
             return 'discretization'
-- 
GitLab