Exemple #1
0
    def _generate_mpi(self, iet, **kwargs):
        # Drop superfluous HaloSpots
        halo_spots = FindNodes(HaloSpot).visit(iet)
        mapper = {i: None for i in halo_spots if i.is_Redundant}
        iet = Transformer(mapper, nested=True).visit(iet)

        # Nothing else to do if no MPI
        if configuration['mpi'] is False:
            return iet

        # Build halo exchange Callables and Calls
        halo_spots = FindNodes(HaloSpot).visit(iet)
        heb = HaloExchangeBuilder(is_threaded(kwargs.get("dle")))
        callables, calls = heb.make(halo_spots)

        # Update the Operator internal state
        self._includes.append('mpi.h')
        self._func_table.update(
            OrderedDict([(i.name, MetaCall(i, True)) for i in callables]))

        # Transform the IET by adding in the `haloupdate` Calls
        mapper = {k: List(body=v + list(k.body)) for k, v in calls.items()}
        iet = Transformer(mapper, nested=True).visit(iet)

        return iet
Exemple #2
0
    def _dist_parallelize(self, iet):
        """
        Add MPI routines performing halo exchanges to emit distributed-memory
        parallel code.
        """
        # Build send/recv Callables and Calls
        heb = HaloExchangeBuilder(self.params['mpi'])
        call_trees, calls = heb.make(FindNodes(HaloSpot).visit(iet))

        # Transform the IET by adding in the `haloupdate` Calls
        iet = Transformer(calls, nested=True).visit(iet)

        return iet, {'includes': ['mpi.h'], 'call_trees': call_trees}