diff options
author | Josh Morman <jmorman@gnuradio.org> | 2021-11-24 12:53:58 -0500 |
---|---|---|
committer | mormj <34754695+mormj@users.noreply.github.com> | 2021-11-24 14:41:53 -0500 |
commit | 51ec89501552c35b2bd0721c0501302f224fe44d (patch) | |
tree | 442036c424c286ece0976dcd3c36891cddefcd25 /gnuradio-runtime/examples/mp-sched | |
parent | e426b9ad20dbbf41326c103b31a7418a80362b06 (diff) |
runtime: pep8 formatting
Signed-off-by: Josh Morman <jmorman@gnuradio.org>
Diffstat (limited to 'gnuradio-runtime/examples/mp-sched')
-rw-r--r-- | gnuradio-runtime/examples/mp-sched/affinity_set.py | 24 | ||||
-rw-r--r-- | gnuradio-runtime/examples/mp-sched/plot_flops.py | 10 | ||||
-rw-r--r-- | gnuradio-runtime/examples/mp-sched/run_synthetic.py | 23 | ||||
-rw-r--r-- | gnuradio-runtime/examples/mp-sched/synthetic.py | 33 | ||||
-rw-r--r-- | gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py | 44 |
5 files changed, 71 insertions, 63 deletions
diff --git a/gnuradio-runtime/examples/mp-sched/affinity_set.py b/gnuradio-runtime/examples/mp-sched/affinity_set.py index 4516b96f54..530742ef22 100644 --- a/gnuradio-runtime/examples/mp-sched/affinity_set.py +++ b/gnuradio-runtime/examples/mp-sched/affinity_set.py @@ -13,6 +13,7 @@ from gnuradio.filter import firdes from argparse import ArgumentParser import sys + class affinity_set(gr.top_block): def __init__(self): @@ -27,19 +28,23 @@ class affinity_set(gr.top_block): # Blocks ################################################## vec_len = 1 - self.blocks_throttle_0 = blocks.throttle(gr.sizeof_gr_complex*vec_len, samp_rate) - self.blocks_null_source_0 = blocks.null_source(gr.sizeof_gr_complex*vec_len) - self.blocks_null_sink_0 = blocks.null_sink(gr.sizeof_gr_complex*vec_len) - self.filter_filt_0 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) - self.filter_filt_1 = filter.fir_filter_ccc(1, 40000*[0.2+0.3j,]) + self.blocks_throttle_0 = blocks.throttle( + gr.sizeof_gr_complex * vec_len, samp_rate) + self.blocks_null_source_0 = blocks.null_source( + gr.sizeof_gr_complex * vec_len) + self.blocks_null_sink_0 = blocks.null_sink( + gr.sizeof_gr_complex * vec_len) + self.filter_filt_0 = filter.fir_filter_ccc(1, 40000 * [0.2 + 0.3j, ]) + self.filter_filt_1 = filter.fir_filter_ccc(1, 40000 * [0.2 + 0.3j, ]) - self.filter_filt_0.set_processor_affinity([0,]) - self.filter_filt_1.set_processor_affinity([0,1]) + self.filter_filt_0.set_processor_affinity([0, ]) + self.filter_filt_1.set_processor_affinity([0, 1]) ################################################## # Connections ################################################## - self.connect((self.blocks_null_source_0, 0), (self.blocks_throttle_0, 0)) + self.connect((self.blocks_null_source_0, 0), + (self.blocks_throttle_0, 0)) self.connect((self.blocks_throttle_0, 0), (self.filter_filt_0, 0)) self.connect((self.filter_filt_0, 0), (self.filter_filt_1, 0)) self.connect((self.filter_filt_1, 0), (self.blocks_null_sink_0, 0)) @@ -50,6 +55,7 @@ class affinity_set(gr.top_block): def set_samp_rate(self, samp_rate): self.samp_rate = samp_rate + if __name__ == '__main__': parser = ArgumentParser() args = parser.parse_args() @@ -69,4 +75,4 @@ if __name__ == '__main__': except ValueError: print("Invalid number") else: - tb.filter_filt_0.set_processor_affinity([n,]) + tb.filter_filt_0.set_processor_affinity([n, ]) diff --git a/gnuradio-runtime/examples/mp-sched/plot_flops.py b/gnuradio-runtime/examples/mp-sched/plot_flops.py index 918197f9f4..5b58e1ddcf 100644 --- a/gnuradio-runtime/examples/mp-sched/plot_flops.py +++ b/gnuradio-runtime/examples/mp-sched/plot_flops.py @@ -47,9 +47,11 @@ def parse_file(input_filename, output): def handle_file(input_filename): - cmd_file = tempfile.NamedTemporaryFile(mode='w+', prefix='pf', suffix='.cmd') + cmd_file = tempfile.NamedTemporaryFile( + mode='w+', prefix='pf', suffix='.cmd') cmd_file_name = cmd_file.name - data_file = tempfile.NamedTemporaryFile(mode='w+', prefix='pf', suffix='.dat') + data_file = tempfile.NamedTemporaryFile( + mode='w+', prefix='pf', suffix='.dat') data_file_name = data_file.name desc = parse_file(input_filename, data_file) if len(desc) > 0: @@ -68,8 +70,8 @@ def handle_file(input_filename): os.system("gnuplot " + cmd_file_name + " -") - #sys.stdout.write(open(cmd_file_name,'r').read()) - #sys.stdout.write(open(data_file_name,'r').read()) + # sys.stdout.write(open(cmd_file_name,'r').read()) + # sys.stdout.write(open(data_file_name,'r').read()) def main(): diff --git a/gnuradio-runtime/examples/mp-sched/run_synthetic.py b/gnuradio-runtime/examples/mp-sched/run_synthetic.py index 35e7f1820d..db8378efe0 100644 --- a/gnuradio-runtime/examples/mp-sched/run_synthetic.py +++ b/gnuradio-runtime/examples/mp-sched/run_synthetic.py @@ -38,18 +38,20 @@ def write_shell_script(f, data_filename, description, ncores, gflops, max_pipes_ # We'd like each run of synthetic to take ~10 seconds desired_time_per_run = 10 est_gflops_avail = min(nstages * npipes, ncores) * gflops - nsamples = (est_gflops_avail * desired_time_per_run) / (512.0 * nstages * npipes) + nsamples = (est_gflops_avail * desired_time_per_run) / \ + (512.0 * nstages * npipes) nsamples = int(nsamples * 1e9) - cmd = "./synthetic.py -m -s %d -p %d -N %d\n" % (nstages, npipes, nsamples) + cmd = "./synthetic.py -m -s %d -p %d -N %d\n" % ( + nstages, npipes, nsamples) f.write(cmd) f.write('if test $? -ge 128; then exit 128; fi\n') - f.write(") 2>&1 | grep --line-buffered -v '^>>>' | tee %s\n" % (data_filename,)) + f.write(") 2>&1 | grep --line-buffered -v '^>>>' | tee %s\n" % + (data_filename,)) f.flush() - def main(): description = """%prog gathers multiprocessor scaling data using the ./synthetic.py benchmark. All combinations of npipes and nstages between 1 and --max-pipes-and-stages are tried. @@ -61,14 +63,15 @@ plot_flops.py will make pretty graphs from the output data generated by %prog. """ parser = ArgumentParser(description=description) parser.add_argument("-d", "--description", metavar="DESC", - help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"") + help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"") parser.add_argument("-n", "--ncores", type=int, default=1, - help="number of processor cores [default=%(default)s]") + help="number of processor cores [default=%(default)s]") parser.add_argument("-g", "--gflops", metavar="GFLOPS", type=float, default=3.0, - help="estimated GFLOPS per core [default=%(default)s]") + help="estimated GFLOPS per core [default=%(default)s]") parser.add_argument("-m", "--max-pipes-and-stages", metavar="MAX", type=int, default=16, - help="maximum number of pipes and stages to use [default=%(default)s]") - parser.add_argument("output_file_name", metavar="FILE", help="output file name") + help="maximum number of pipes and stages to use [default=%(default)s]") + parser.add_argument("output_file_name", metavar="FILE", + help="output file name") args = parser.parse_args() shell = os.popen("/bin/sh", "w") @@ -80,6 +83,6 @@ plot_flops.py will make pretty graphs from the output data generated by %prog. args.gflops, args.max_pipes_and_stages) + if __name__ == '__main__': main() - diff --git a/gnuradio-runtime/examples/mp-sched/synthetic.py b/gnuradio-runtime/examples/mp-sched/synthetic.py index 4d6f3b9a22..cff6fd970d 100644 --- a/gnuradio-runtime/examples/mp-sched/synthetic.py +++ b/gnuradio-runtime/examples/mp-sched/synthetic.py @@ -24,7 +24,7 @@ class pipeline(gr.hier_block2): gr.hier_block2.__init__(self, "pipeline", gr.io_signature(1, 1, gr.sizeof_float), gr.io_signature(0, 0, 0)) - taps = ntaps*[1.0 / ntaps] + taps = ntaps * [1.0 / ntaps] upstream = self for i in range(nstages): op = filter.fir_filter_fff(1, taps) @@ -41,14 +41,14 @@ class top(gr.top_block): default_nsamples = 10e6 parser = ArgumentParser() parser.add_argument("-p", "--npipelines", type=intx, default=1, - metavar="NPIPES", help="the number of pipelines to create (default=%(default)s)") + metavar="NPIPES", help="the number of pipelines to create (default=%(default)s)") parser.add_argument("-s", "--nstages", type=intx, default=1, metavar="NSTAGES", - help="the number of stages in each pipeline (default=%(default)s)") + help="the number of stages in each pipeline (default=%(default)s)") parser.add_argument("-N", "--nsamples", type=eng_float, default=default_nsamples, - help=("the number of samples to run through the graph (default=%s)" % - (eng_notation.num_to_str(default_nsamples)))) + help=("the number of samples to run through the graph (default=%s)" % + (eng_notation.num_to_str(default_nsamples)))) parser.add_argument("-m", "--machine-readable", action="store_true", default=False, - help="enable machine readable output") + help="enable machine readable output") args = parser.parse_args() @@ -74,23 +74,24 @@ def time_it(tb): start = os.times() tb.run() stop = os.times() - delta = list(map((lambda a, b: a-b), stop, start)) + delta = list(map((lambda a, b: a - b), stop, start)) user, sys, childrens_user, childrens_sys, real = delta total_user = user + childrens_user - total_sys = sys + childrens_sys + total_sys = sys + childrens_sys if tb.machine_readable: print("%3d %3d %.3e %7.3f %7.3f %7.3f %7.3f %.6e %.3e" % ( - tb.npipes, tb.nstages, tb.nsamples, real, total_user, total_sys, (total_user+total_sys) / real, tb.flop, tb.flop / real)) + tb.npipes, tb.nstages, tb.nsamples, real, total_user, total_sys, (total_user + total_sys) / real, tb.flop, tb.flop / real)) else: - print("npipes %7d" % (tb.npipes,)) - print("nstages %7d" % (tb.nstages,)) - print("nsamples %s" % (eng_notation.num_to_str(tb.nsamples),)) + print("npipes %7d" % (tb.npipes,)) + print("nstages %7d" % (tb.nstages,)) + print("nsamples %s" % (eng_notation.num_to_str(tb.nsamples),)) print("real %7.3f" % (real,)) print("user %7.3f" % (total_user,)) print("sys %7.3f" % (total_sys,)) print("(user+sys)/real %7.3f" % ((total_user + total_sys) / real,)) - print("pseudo_flop %s" % (eng_notation.num_to_str(tb.flop),)) - print("pseudo_flop/real %s" % (eng_notation.num_to_str(tb.flop / real),)) + print("pseudo_flop %s" % (eng_notation.num_to_str(tb.flop),)) + print("pseudo_flop/real %s" % + (eng_notation.num_to_str(tb.flop / real),)) if __name__ == "__main__": @@ -99,7 +100,3 @@ if __name__ == "__main__": time_it(tb) except KeyboardInterrupt: raise SystemExit(128) - - - - diff --git a/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py b/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py index f78404a66a..d2fa94b8ad 100644 --- a/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py +++ b/gnuradio-runtime/examples/mp-sched/wfm_rcv_pll_to_wav.py @@ -17,14 +17,15 @@ from argparse import ArgumentParser import sys import math + class wfm_rx_block (gr.top_block): def __init__(self): gr.top_block.__init__(self) parser = ArgumentParser(description="Decode WFM signal into WAV file.") parser.add_argument("-V", "--volume", type=eng_float, - help="Volume (dB) <%r, %r> (default is midpoint)" % \ - self.volume_range()[:2]) + help="Volume (dB) <%r, %r> (default is midpoint)" % + self.volume_range()[:2]) parser.add_argument("input_file", help="Input file (complex samples)") parser.add_argument("output_file", help="Output WAV file") @@ -34,7 +35,8 @@ class wfm_rx_block (gr.top_block): # build graph - self.src = blocks.file_source(gr.sizeof_gr_complex, args.input_file, False) + self.src = blocks.file_source( + gr.sizeof_gr_complex, args.input_file, False) adc_rate = 64e6 # 64 MS/s usrp_decim = 200 @@ -44,19 +46,17 @@ class wfm_rx_block (gr.top_block): audio_decimation = 10 audio_rate = demod_rate / audio_decimation # 32 kHz - - chan_filt_coeffs = filter.optfir.low_pass (1, # gain - usrp_rate, # sampling rate - 80e3, # passband cutoff - 115e3, # stopband cutoff - 0.1, # passband ripple - 60) # stopband attenuation - #print len(chan_filt_coeffs) - chan_filt = filter.fir_filter_ccf (chanfilt_decim, chan_filt_coeffs) - + chan_filt_coeffs = filter.optfir.low_pass(1, # gain + usrp_rate, # sampling rate + 80e3, # passband cutoff + 115e3, # stopband cutoff + 0.1, # passband ripple + 60) # stopband attenuation + # print len(chan_filt_coeffs) + chan_filt = filter.fir_filter_ccf(chanfilt_decim, chan_filt_coeffs) #self.guts = analog.wfm_rcv (demod_rate, audio_decimation) - self.guts = analog.wfm_rcv_pll (demod_rate, audio_decimation) + self.guts = analog.wfm_rcv_pll(demod_rate, audio_decimation) # FIXME rework {add,multiply}_const_* to handle multiple streams self.volume_control_l = blocks.multiply_const_ff(self.vol) @@ -67,24 +67,24 @@ class wfm_rx_block (gr.top_block): sink = blocks.wavfile_sink(args.output_file, 2, int(audio_rate), blocks.FORMAT_WAV, blocks.FORMAT_PCM_16) else: - sink = audio.sink (int (audio_rate), - args.audio_output, - False) # ok_to_block + sink = audio.sink(int(audio_rate), + args.audio_output, + False) # ok_to_block # now wire it all together - self.connect (self.src, chan_filt, self.guts) - self.connect ((self.guts, 0), self.volume_control_l, (sink, 0)) - self.connect ((self.guts, 1), self.volume_control_r, (sink, 1)) + self.connect(self.src, chan_filt, self.guts) + self.connect((self.guts, 0), self.volume_control_l, (sink, 0)) + self.connect((self.guts, 1), self.volume_control_r, (sink, 1)) if args.volume is None: g = self.volume_range() - args.volume = float(g[0]+g[1]) / 2 + args.volume = float(g[0] + g[1]) / 2 # set initial values self.set_vol(args.volume) - def set_vol (self, vol): + def set_vol(self, vol): g = self.volume_range() self.vol = max(g[0], min(g[1], vol)) self.volume_control_l.set_k(10**(self.vol / 10)) |