summaryrefslogtreecommitdiff
path: root/gnuradio-runtime
diff options
context:
space:
mode:
Diffstat (limited to 'gnuradio-runtime')
-rwxr-xr-xgnuradio-runtime/examples/mp-sched/affinity_set.py8
-rwxr-xr-xgnuradio-runtime/examples/mp-sched/plot_flops.py15
-rwxr-xr-xgnuradio-runtime/examples/mp-sched/run_synthetic.py39
-rw-r--r--gnuradio-runtime/include/gnuradio/basic_block.h7
-rw-r--r--gnuradio-runtime/include/gnuradio/tpb_detail.h3
-rw-r--r--gnuradio-runtime/include/gnuradio/types.h23
-rw-r--r--gnuradio-runtime/lib/basic_block.cc23
-rw-r--r--gnuradio-runtime/lib/block.cc7
-rw-r--r--gnuradio-runtime/lib/tpb_thread_body.cc87
-rw-r--r--gnuradio-runtime/python/gnuradio/__init__.py4
-rw-r--r--gnuradio-runtime/python/gnuradio/eng_option.py16
11 files changed, 57 insertions, 175 deletions
diff --git a/gnuradio-runtime/examples/mp-sched/affinity_set.py b/gnuradio-runtime/examples/mp-sched/affinity_set.py
index 15d2233b6a..e6637b44bf 100755
--- a/gnuradio-runtime/examples/mp-sched/affinity_set.py
+++ b/gnuradio-runtime/examples/mp-sched/affinity_set.py
@@ -8,9 +8,9 @@ from gnuradio import eng_notation
from gnuradio import gr
from gnuradio import blocks
from gnuradio import filter
-from gnuradio.eng_option import eng_option
+from gnuradio.eng_arg import eng_arg
from gnuradio.filter import firdes
-from optparse import OptionParser
+from argparse import ArgumentParser
import sys
class affinity_set(gr.top_block):
@@ -51,8 +51,8 @@ class affinity_set(gr.top_block):
self.samp_rate = samp_rate
if __name__ == '__main__':
- parser = OptionParser(option_class=eng_option, usage="%prog: [options]")
- (options, args) = parser.parse_args()
+ parser = ArgumentParser()
+ args = parser.parse_args()
tb = affinity_set()
tb.start()
diff --git a/gnuradio-runtime/examples/mp-sched/plot_flops.py b/gnuradio-runtime/examples/mp-sched/plot_flops.py
index d9d810ae2f..c80820b8a3 100755
--- a/gnuradio-runtime/examples/mp-sched/plot_flops.py
+++ b/gnuradio-runtime/examples/mp-sched/plot_flops.py
@@ -28,7 +28,7 @@ import re
import sys
import os
import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
def parse_file(input_filename, output):
@@ -84,14 +84,11 @@ def handle_file(input_filename):
def main():
- usage = "usage: %prog [options] file.dat"
- parser = OptionParser(usage=usage)
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
-
- handle_file(args[0])
+ parser = ArgumentParser()
+ parser.add_argument('file', help='Input file', nargs=1)
+ args = parser.parse_args()
+
+ handle_file(args.file[0])
if __name__ == '__main__':
diff --git a/gnuradio-runtime/examples/mp-sched/run_synthetic.py b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
index 4896bca462..802fb9fd34 100755
--- a/gnuradio-runtime/examples/mp-sched/run_synthetic.py
+++ b/gnuradio-runtime/examples/mp-sched/run_synthetic.py
@@ -27,7 +27,7 @@ import re
import sys
import os
import tempfile
-from optparse import OptionParser
+from argparse import ArgumentParser
def write_shell_script(f, data_filename, description, ncores, gflops, max_pipes_and_stages):
@@ -70,31 +70,26 @@ total runtime of about 43 minutes, assuming that your values for -n and -f are r
For x86 machines, assume 3 FLOPS per processor Hz. E.g., 3 GHz machine -> 9 GFLOPS.
plot_flops.py will make pretty graphs from the output data generated by %prog.
"""
- usage = "usage: %prog [options] output.dat"
- parser = OptionParser(usage=usage, description=description)
- parser.add_option("-d", "--description", metavar="DESC",
- help="machine description, e.g., \"Dual quad-core Xeon 3 GHz\"", default=None)
- parser.add_option("-n", "--ncores", type="int", default=1,
- help="number of processor cores [default=%default]")
- parser.add_option("-g", "--gflops", metavar="GFLOPS", type="float", default=3.0,
- help="estimated GFLOPS per core [default=%default]")
- parser.add_option("-m", "--max-pipes-and-stages", metavar="MAX", type="int", default=16,
- help="maximum number of pipes and stages to use [default=%default]")
- (options, args) = parser.parse_args()
- if len(args) != 1:
- parser.print_help()
- raise SystemExit, 1
-
- output_filename = args[0]
+ parser = ArgumentParser(description=description)
+ parser.add_argument("-d", "--description", metavar="DESC",
+ 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]")
+ parser.add_argument("-g", "--gflops", metavar="GFLOPS", type=float, default=3.0,
+ 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")
+ args = parser.parse_args()
shell = os.popen("/bin/sh", "w")
write_shell_script(shell,
- output_filename,
- options.description,
- options.ncores,
- options.gflops,
- options.max_pipes_and_stages)
+ args.output_file_name,
+ args.description,
+ args.ncores,
+ args.gflops,
+ args.max_pipes_and_stages)
if __name__ == '__main__':
main()
diff --git a/gnuradio-runtime/include/gnuradio/basic_block.h b/gnuradio-runtime/include/gnuradio/basic_block.h
index 25d9fb5a78..fa454c95ed 100644
--- a/gnuradio-runtime/include/gnuradio/basic_block.h
+++ b/gnuradio-runtime/include/gnuradio/basic_block.h
@@ -252,13 +252,6 @@ namespace gr {
*/
pmt::pmt_t delete_head_nowait( pmt::pmt_t which_port);
- /*!
- * \param[in] which_port The message port from which to get the message.
- * \param[in] millisec Optional timeout value (0=no timeout).
- * \returns returns pmt at head of queue or pmt::pmt_t() if empty.
- */
- pmt::pmt_t delete_head_blocking(pmt::pmt_t which_port, unsigned int millisec = 0);
-
msg_queue_t::iterator get_iterator(pmt::pmt_t which_port) {
return msg_queue[which_port].begin();
}
diff --git a/gnuradio-runtime/include/gnuradio/tpb_detail.h b/gnuradio-runtime/include/gnuradio/tpb_detail.h
index 9b7454b508..4e660144f2 100644
--- a/gnuradio-runtime/include/gnuradio/tpb_detail.h
+++ b/gnuradio-runtime/include/gnuradio/tpb_detail.h
@@ -58,7 +58,10 @@ namespace gr {
//! Called by pmt msg posters
void notify_msg() {
+ gr::thread::scoped_lock guard(mutex);
+ input_changed = true;
input_cond.notify_one();
+ output_changed = true;
output_cond.notify_one();
}
diff --git a/gnuradio-runtime/include/gnuradio/types.h b/gnuradio-runtime/include/gnuradio/types.h
index 6cb0f72834..c91538e60e 100644
--- a/gnuradio-runtime/include/gnuradio/types.h
+++ b/gnuradio-runtime/include/gnuradio/types.h
@@ -37,29 +37,6 @@ typedef std::vector<double> gr_vector_double;
typedef std::vector<void *> gr_vector_void_star;
typedef std::vector<const void *> gr_vector_const_void_star;
-/*
- * #include <config.h> must be placed beforehand
- * in the source file including gnuradio/types.h for
- * the following to work correctly
- */
-#ifdef HAVE_STDINT_H
#include <stdint.h>
-typedef int16_t gr_int16;
-typedef int32_t gr_int32;
-typedef int64_t gr_int64;
-typedef uint16_t gr_uint16;
-typedef uint32_t gr_uint32;
-typedef uint64_t gr_uint64;
-#else
-/*
- * Note: these defaults may be wrong on 64-bit systems
- */
-typedef short gr_int16;
-typedef int gr_int32;
-typedef long long gr_int64;
-typedef unsigned short gr_uint16;
-typedef unsigned int gr_uint32;
-typedef unsigned long long gr_uint64;
-#endif /* HAVE_STDINT_H */
#endif /* INCLUDED_GR_TYPES_H */
diff --git a/gnuradio-runtime/lib/basic_block.cc b/gnuradio-runtime/lib/basic_block.cc
index 082d0753c8..89aa9b8671 100644
--- a/gnuradio-runtime/lib/basic_block.cc
+++ b/gnuradio-runtime/lib/basic_block.cc
@@ -228,29 +228,6 @@ namespace gr {
}
pmt::pmt_t
- basic_block::delete_head_blocking(pmt::pmt_t which_port, unsigned int millisec)
- {
- gr::thread::scoped_lock guard(mutex);
-
- if (millisec) {
- boost::system_time const timeout = boost::get_system_time() + boost::posix_time::milliseconds(millisec);
- while (empty_p(which_port)) {
- if (!msg_queue_ready[which_port]->timed_wait(guard, timeout)) {
- return pmt::pmt_t();
- }
- }
- } else {
- while(empty_p(which_port)) {
- msg_queue_ready[which_port]->wait(guard);
- }
- }
-
- pmt::pmt_t m(msg_queue[which_port].front());
- msg_queue[which_port].pop_front();
- return m;
- }
-
- pmt::pmt_t
basic_block::message_subscribers(pmt::pmt_t port)
{
return pmt::dict_ref(d_message_subscribers,port,pmt::PMT_NIL);
diff --git a/gnuradio-runtime/lib/block.cc b/gnuradio-runtime/lib/block.cc
index 2bae8ea9f8..e329e0657a 100644
--- a/gnuradio-runtime/lib/block.cc
+++ b/gnuradio-runtime/lib/block.cc
@@ -707,8 +707,7 @@ namespace gr {
//std::cout << "system_handler " << msg << "\n";
pmt::pmt_t op = pmt::car(msg);
if(pmt::eqv(op, pmt::mp("done"))){
- d_finished = pmt::to_long(pmt::cdr(msg));
- global_block_registry.notify_blk(alias());
+ d_finished = pmt::to_bool(pmt::cdr(msg));
} else {
std::cout << "WARNING: bad message op on system port!\n";
pmt::print(msg);
@@ -737,7 +736,7 @@ namespace gr {
currlist = pmt::cdr(currlist);
basic_block_sptr blk = global_block_registry.block_lookup(block);
- blk->post(port, pmt::cons(pmt::mp("done"), pmt::mp(true)));
+ blk->post(port, pmt::cons(pmt::mp("done"), pmt::PMT_T));
//std::cout << "notify finished --> ";
//pmt::print(pmt::cons(block,port));
@@ -750,7 +749,7 @@ namespace gr {
bool
block::finished()
{
- if((detail()->ninputs() != 0) || (detail()->noutputs() != 0))
+ if(detail()->ninputs() != 0)
return false;
else
return d_finished;
diff --git a/gnuradio-runtime/lib/tpb_thread_body.cc b/gnuradio-runtime/lib/tpb_thread_body.cc
index 93591feee2..32c846d8a4 100644
--- a/gnuradio-runtime/lib/tpb_thread_body.cc
+++ b/gnuradio-runtime/lib/tpb_thread_body.cc
@@ -93,9 +93,10 @@ namespace gr {
block->clear_finished();
while(1) {
- tpb_loop_top:
boost::this_thread::interruption_point();
+ d->d_tpb.clear_changed();
+
// handle any queued up messages
BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
// Check if we have a message handler attached before getting
@@ -116,97 +117,57 @@ namespace gr {
}
}
- d->d_tpb.clear_changed();
// run one iteration if we are a connected stream block
if(d->noutputs() >0 || d->ninputs()>0){
s = d_exec.run_one_iteration();
}
else {
s = block_executor::BLKD_IN;
+ // a msg port only block wants to shutdown
+ if(block->finished()) {
+ s = block_executor::DONE;
+ }
}
- // if msg ports think we are done, we are done
- if(block->finished())
+ if(block->finished() && s == block_executor::READY_NO_OUTPUT) {
s = block_executor::DONE;
+ d->set_done(true);
+ }
+
+ if(!d->ninputs() && s == block_executor::READY_NO_OUTPUT) {
+ s = block_executor::BLKD_IN;
+ }
switch(s){
- case block_executor::READY: // Tell neighbors we made progress.
+ case block_executor::READY: // Tell neighbors we made progress.
d->d_tpb.notify_neighbors(d);
break;
- case block_executor::READY_NO_OUTPUT: // Notify upstream only
+ case block_executor::READY_NO_OUTPUT: // Notify upstream only
d->d_tpb.notify_upstream(d);
break;
- case block_executor::DONE: // Game over.
+ case block_executor::DONE: // Game over.
block->notify_msg_neighbors();
d->d_tpb.notify_neighbors(d);
return;
- case block_executor::BLKD_IN: // Wait for input.
+ case block_executor::BLKD_IN: // Wait for input.
{
gr::thread::scoped_lock guard(d->d_tpb.mutex);
- while(!d->d_tpb.input_changed) {
-
- // wait for input or message
- while(!d->d_tpb.input_changed && block->empty_handled_p()){
- boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds(250);
- if(!d->d_tpb.input_cond.timed_wait(guard, timeout)){
- goto tpb_loop_top; // timeout occurred (perform sanity checks up top)
- }
- }
- // handle all pending messages
- BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
- if(block->has_msg_handler(i.first)) {
- while((msg = block->delete_head_nowait(i.first))) {
- guard.unlock(); // release lock while processing msg
- block->dispatch_msg(i.first, msg);
- guard.lock();
- }
- }
- else {
- // leave msg in queue if no handler is defined
- // start dropping if we have too many
- if(block->nmsgs(i.first) > max_nmsgs){
- GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
- msg = block->delete_head_nowait(i.first);
- }
- }
- }
- if (d->done()) {
- return;
- }
+ if(!d->d_tpb.input_changed) {
+ boost::system_time const timeout=boost::get_system_time()+ boost::posix_time::milliseconds(250);
+ d->d_tpb.input_cond.timed_wait(guard, timeout);
}
}
break;
- case block_executor::BLKD_OUT: // Wait for output buffer space.
+ case block_executor::BLKD_OUT: // Wait for output buffer space.
{
- gr::thread::scoped_lock guard(d->d_tpb.mutex);
- while(!d->d_tpb.output_changed) {
- // wait for output room or message
- while(!d->d_tpb.output_changed && block->empty_handled_p())
- d->d_tpb.output_cond.wait(guard);
-
- // handle all pending messages
- BOOST_FOREACH(basic_block::msg_queue_map_t::value_type &i, block->msg_queue) {
- if(block->has_msg_handler(i.first)) {
- while((msg = block->delete_head_nowait(i.first))) {
- guard.unlock(); // release lock while processing msg
- block->dispatch_msg(i.first, msg);
- guard.lock();
- }
- }
- else {
- // leave msg in queue if no handler is defined
- // start dropping if we have too many
- if(block->nmsgs(i.first) > max_nmsgs){
- GR_LOG_WARN(LOG,"asynchronous message buffer overflowing, dropping message");
- msg = block->delete_head_nowait(i.first);
- }
- }
- }
+ gr::thread::scoped_lock guard(d->d_tpb.mutex);
+ while(!d->d_tpb.output_changed) {
+ d->d_tpb.output_cond.wait(guard);
}
}
break;
diff --git a/gnuradio-runtime/python/gnuradio/__init__.py b/gnuradio-runtime/python/gnuradio/__init__.py
index dd7b89650b..43274dbd1c 100644
--- a/gnuradio-runtime/python/gnuradio/__init__.py
+++ b/gnuradio-runtime/python/gnuradio/__init__.py
@@ -38,12 +38,8 @@ if path.endswith(path_ending):
__path__.append(os.path.join(build_path, 'gr-audio', 'python'))
__path__.append(os.path.join(build_path, 'gr-qtgui', 'python'))
__path__.append(os.path.join(build_path, 'gr-wxgui', 'python'))
- __path__.append(os.path.join(build_path, 'gr-atsc', 'python'))
- __path__.append(os.path.join(build_path, 'gr-noaa', 'python'))
- __path__.append(os.path.join(build_path, 'gr-pager', 'python'))
__path__.append(os.path.join(build_path, 'gr-video-sdl', 'python'))
__path__.append(os.path.join(build_path, 'gr-vocoder', 'python'))
- __path__.append(os.path.join(build_path, 'gr-fcd', 'python'))
__path__.append(os.path.join(build_path, 'gr-comedi', 'python'))
__path__.append(os.path.join(build_path, 'gr-channels', 'python'))
__path__.append(os.path.join(build_path, 'gr-fec', 'python'))
diff --git a/gnuradio-runtime/python/gnuradio/eng_option.py b/gnuradio-runtime/python/gnuradio/eng_option.py
index 5d8660f0f2..ae000fe442 100644
--- a/gnuradio-runtime/python/gnuradio/eng_option.py
+++ b/gnuradio-runtime/python/gnuradio/eng_option.py
@@ -39,25 +39,9 @@ def check_intx (option, opt, value):
raise OptionValueError (
"option %s: invalid integer value: %r" % (opt, value))
-def check_subdev (option, opt, value):
- """
- Value has the form: (A|B)(:0|1)?
-
- Returns:
- a 2-tuple (0|1, 0|1)
- """
- d = { 'A' : (0, 0), 'A:0' : (0, 0), 'A:1' : (0, 1), 'A:2' : (0, 2),
- 'B' : (1, 0), 'B:0' : (1, 0), 'B:1' : (1, 1), 'B:2' : (1, 2) }
- try:
- return d[value.upper()]
- except:
- raise OptionValueError(
- "option %s: invalid subdev: '%r', must be one of %s" % (opt, value, ', '.join(sorted(d.keys()))))
-
class eng_option (Option):
TYPES = Option.TYPES + ("eng_float", "intx", "subdev")
TYPE_CHECKER = copy (Option.TYPE_CHECKER)
TYPE_CHECKER["eng_float"] = check_eng_float
TYPE_CHECKER["intx"] = check_intx
- TYPE_CHECKER["subdev"] = check_subdev