Exemple #1
0
    def summary(self, args, dtype, reduce_over=None):
        grid = args.grid
        comm = args.comm

        summary = PerformanceSummary()
        for section, data in self._sections.items():
            name = section.name

            # Time to run the section
            time = max(getattr(args[self.name]._obj, name), 10e-7)

            # Number of FLOPs performed
            ops = int(subs_op_args(data.ops, args))

            # Number of grid points computed
            points = int(subs_op_args(data.points, args))

            # Compulsory traffic
            traffic = float(subs_op_args(data.traffic, args)*dtype().itemsize)

            # Runtime itermaps/itershapes
            itermaps = [OrderedDict([(k, int(subs_op_args(v, args)))
                                     for k, v in i.items()])
                        for i in data.itermaps]
            itershapes = tuple(tuple(i.values()) for i in itermaps)

            # Add local performance data
            if comm is not MPI.COMM_NULL:
                # With MPI enabled, we add one entry per section per rank
                times = comm.allgather(time)
                assert comm.size == len(times)
                opss = comm.allgather(ops)
                pointss = comm.allgather(points)
                traffics = comm.allgather(traffic)
                sops = [data.sops]*comm.size
                itershapess = comm.allgather(itershapes)
                items = list(zip(times, opss, pointss, traffics, sops, itershapess))
                for rank in range(comm.size):
                    summary.add(name, rank, *items[rank])
            else:
                summary.add(name, None, time, ops, points, traffic, data.sops, itershapes)

        # Add global performance data
        if reduce_over is not None:
            # Vanilla metrics
            if comm is not MPI.COMM_NULL:
                summary.add_glb_vanilla(self.py_timers[reduce_over])

            # Typical finite difference benchmark metrics
            if grid is not None:
                dimensions = (grid.time_dim,) + grid.dimensions
                if all(d.max_name in args for d in dimensions):
                    max_t = args[grid.time_dim.max_name] or 0
                    min_t = args[grid.time_dim.min_name] or 0
                    nt = max_t - min_t + 1
                    points = reduce(mul, (nt,) + grid.shape)
                    summary.add_glb_fdlike(points, self.py_timers[reduce_over])

        return summary
Exemple #2
0
 def _arg_values(self, args=None, **kwargs):
     values = self._arg_defaults()
     for i, (_, mapper) in enumerate(self.owned):
         entry = values[self.name][i]
         for a in self.arguments:
             if a.is_Dimension:
                 a_m, a_M = mapper[a]
                 setattr(entry, a.min_name, subs_op_args(a_m, args))
                 setattr(entry, a.max_name, subs_op_args(a_M, args))
             else:
                 try:
                     setattr(entry, a.name, subs_op_args(mapper[a][0], args))
                 except AttributeError:
                     setattr(entry, a.name, mapper[a][0])
     return values