Exemple #1
0
def test_run():
    run_script.run(script,
                   workdir=workdir,
                   ncount=ncount,
                   ntotalthreads=int(1e6 / 512 * 256),
                   threads_per_block=256)
    return
Exemple #2
0
def test_component_long(ncount = 1e6):
    instr = os.path.join(thisdir, "src_mon_instrument.py")
    outdir = 'out.psd_monitor'
    ncount = int(ncount)
    run_script.run(instr, outdir, ncount=ncount, monitor_factory=psd_monitor)
    if interactive:
        import histogram.hdf as hh
        hist = hh.load(os.path.join(outdir, "psd.h5"))
        from histogram import plot as plotHist
        plotHist(hist)
    return
Exemple #3
0
def run(instrument_script,
        ncount,
        niters,
        mpi=False,
        nodes=1,
        acc_run=False,
        skip_ncounts=[],
        **kwds):
    outdir = 'out.debug-check-speed'
    if os.path.exists(outdir):
        shutil.rmtree(outdir)

    # TODO: this stdout file gets overwritten on each call, move or use append?
    stdout = open("./check-speed-stdout.txt", "w")
    sys.stderr = stdout

    avg_times = []
    for n in ncount:
        if n in skip_ncounts:
            # insert element to preserve ordering
            avg_times.append(np.nan)
            continue

        print(" Running '{}' with n={}".format(instrument_script, n))

        times = []
        # redirect script output to reduce terminal clutter
        for iter in range(niters + 1):
            sys.stdout = stdout
            buffer_size = int(n) if n > 1e6 else int(1e6)
            if buffer_size > 1e9:
                buffer_size = int(1e9)

            # get the runtime for the script. Note: this probably isn't the
            # best timing, since it will include the overhead of launching the
            # script and any file IO done inside the script, but there is no
            # current way to time individual components.
            # TODO: the stdout could be parsed to pull the process timings for acc components
            # TODO: there is still mcvine component output, likely from a subprocess in which this redirection has no effect
            if mpi:
                # run script in MPI mode
                # NOTE: with mcvine=0.44, pyyaml 5.3 must be used to avoid yaml load error. This is fixed in newer versions of mcvine.
                time_before = time.time_ns()
                run_script.run_mpi(instrument_script,
                                   outdir,
                                   nodes=nodes,
                                   buffer_size=buffer_size,
                                   ncount=n,
                                   overwrite_datafiles=True,
                                   **kwds)
                time_after = time.time_ns()
            elif acc_run:
                # use accelerated run script
                time_before = time.time_ns()
                run_acc_script.run(instrument_script,
                                   outdir,
                                   buffer_size=buffer_size,
                                   ncount=n,
                                   overwrite_datafiles=True,
                                   **kwds)
                time_after = time.time_ns()
            else:
                # use default run script (mcvine, single node)
                time_before = time.time_ns()
                run_script.run1(instrument_script,
                                outdir,
                                buffer_size=buffer_size,
                                ncount=n,
                                overwrite_datafiles=True,
                                **kwds)
                time_after = time.time_ns()

            # skip first run
            if iter < 1:
                continue

            delta = time_after - time_before
            times.append(delta)

        sys.stdout = sys.__stdout__

        time_avg = np.sum(np.asarray(times)) / len(times)
        avg_times.append(time_avg)
        print(" TIME = {} ms ({} s)".format(time_avg * 1e-6, time_avg * 1e-9))

    sys.stdout = sys.__stdout__
    sys.stderr = sys.__stderr__
    stdout.close()

    return avg_times
Exemple #4
0
def test_run():
    run_script.run(script, workdir, ncount=ncount)
    return