示例#1
0
def collect_timings(outdir, tic):

    # list_timings(TimingClear.keep, [TimingType.wall, TimingType.system])

    # t = timings(TimingClear.keep, [TimingType.wall, TimingType.user, TimingType.system])
    t = timings(TimingClear.keep, [TimingType.wall])
    # Use different MPI reductions
    t_sum = MPI.sum(MPI.comm_world, t)
    # t_min = MPI.min(MPI.comm_world, t)
    # t_max = MPI.max(MPI.comm_world, t)
    t_avg = MPI.avg(MPI.comm_world, t)
    # Print aggregate timings to screen
    print('\n' + t_sum.str(True))
    # print('\n'+t_min.str(True))
    # print('\n'+t_max.str(True))
    print('\n' + t_avg.str(True))

    # Store to XML file on rank 0
    if MPI.rank(MPI.comm_world) == 0:
        f = File(MPI.comm_self, os.path.join(outdir, "timings_aggregate.xml"))
        f << t_sum
        # f << t_min
        # f << t_max
        f << t_avg

    dump_timings_to_xml(os.path.join(outdir, "timings_avg_min_max.xml"),
                        TimingClear.clear)
    elapsed = time.time() - tic

    comm = mpi4py.MPI.COMM_WORLD
    rank = comm.Get_rank()
    size = comm.Get_size()

    if rank == 0:
        with open(os.path.join(outdir, 'timings.pkl'), 'w') as f:
            json.dump({'elapsed': elapsed, 'size': size}, f)

    pass
        (fig2, ax1, ax2) = pp.plot_spectrum(parameters, data, tc)
        plt.legend(loc='lower left')
        # ax2.set_ylim(-1e-7, 2e-4)
        fig2.savefig(os.path.join(experiment, "spectrum.pdf"),
                     bbox_inches='tight')

    from dolfin import list_timings, TimingType, TimingClear

    list_timings(TimingClear.keep, [TimingType.wall, TimingType.system])
    t = list_timings(TimingClear.keep,
                     [TimingType.wall, TimingType.user, TimingType.system])
    # Use different MPI reductions
    # t_sum = MPI.sum(MPI.comm_world, t[0])
    # t_min = MPI.min(MPI.comm_world, t[1])
    # t_max = MPI.max(MPI.comm_world, t[2])
    t_avg = MPI.avg(MPI.comm_world, t[3])

    # Print aggregate timings to screen
    # print('\n'+t_sum.str(True))
    # print('\n'+t_min.str(True))
    # print('\n'+t_max.str(True))
    print('\n' + t_avg.str(True))

    # Store to XML file on rank 0
    if MPI.rank(MPI.comm_world) == 0:
        f = File(MPI.comm_self,
                 os.path.join(experiment, "timings_aggregate.xml"))
        # f << t_sum
        # f << t_min
        # f << t_max
        f << t_avg