From f676197e6dd2a638f294e350654e32d3ffc45af8 Mon Sep 17 00:00:00 2001 From: Martin Braun Date: Mon, 7 Jan 2013 17:10:20 +0100 Subject: core: added remove_tag_item() --- gnuradio-core/src/lib/runtime/gr_block.h | 36 ++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) (limited to 'gnuradio-core/src/lib/runtime/gr_block.h') diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 57e3fda90..7a70bdaf0 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -415,6 +415,42 @@ class GR_CORE_API gr_block : public gr_basic_block { */ void add_item_tag(unsigned int which_output, const gr_tag_t &tag); + /*! + * \brief Removes a tag from the given input buffer. + * + * \param which_input an integer of which input stream to remove the tag from + * \param abs_offset a uint64 number of the absolute item number + * assicated with the tag. Can get from nitems_written. + * \param key the tag key as a PMT symbol + * \param value any PMT holding any value for the given key + * \param srcid optional source ID specifier; defaults to PMT_F + * + * If no such tag is found, does nothing. + */ + inline void remove_item_tag(unsigned int which_input, + uint64_t abs_offset, + const pmt::pmt_t &key, + const pmt::pmt_t &value, + const pmt::pmt_t &srcid=pmt::PMT_F) + { + gr_tag_t tag; + tag.offset = abs_offset; + tag.key = key; + tag.value = value; + tag.srcid = srcid; + this->remove_item_tag(which_input, tag); + } + + /*! + * \brief Removes a tag from the given input buffer. + * + * If no such tag is found, does nothing. + * + * \param which_input an integer of which input stream to remove the tag from + * \param tag the tag object to remove + */ + void remove_item_tag(unsigned int which_input, const gr_tag_t &tag); + /*! * \brief Given a [start,end), returns a vector of all tags in the range. * -- cgit From 97ff82dd63f06ad51992222c160a9673260b13f7 Mon Sep 17 00:00:00 2001 From: Ben Reynwar Date: Tue, 22 Jan 2013 12:46:01 -0700 Subject: core: Add min_noutput_items to gr_block. --- gnuradio-core/src/lib/runtime/gr_block.h | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/runtime/gr_block.h') diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 7a70bdaf0..52cf723a9 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -251,6 +251,23 @@ class GR_CORE_API gr_block : public gr_basic_block { */ void set_tag_propagation_policy(tag_propagation_policy_t p); + /*! + * \brief Return the minimum number of output items this block can + * produce during a call to work. + * + * Should be 0 for most blocks. Useful if we're dealing with packets and + * the block produces one packet per call to work. + */ + int min_noutput_items() const { return d_min_noutput_items; } + + /*! + * \brief Set the minimum number of output items this block can + * produce during a call to work. + * + * \param m the minimum noutput_items this block can produce. + */ + void set_min_noutput_items(int m) { d_min_noutput_items = m; } + /*! * \brief Return the maximum number of output items this block will * handle during a call to work. @@ -258,7 +275,7 @@ class GR_CORE_API gr_block : public gr_basic_block { int max_noutput_items(); /*! - * \brief Set the maximum number of ouput items htis block will + * \brief Set the maximum number of output items this block will * handle during a call to work. * * \param m the maximum noutput_items this block will handle. @@ -370,6 +387,7 @@ class GR_CORE_API gr_block : public gr_basic_block { gr_block_detail_sptr d_detail; // implementation details unsigned d_history; bool d_fixed_rate; + int d_min_noutput_items; bool d_max_noutput_items_set; // if d_max_noutput_items is valid int d_max_noutput_items; // value of max_noutput_items for this block tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream -- cgit From 01eab0c7e283db9c1cfff0a26296a49128062cca Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Wed, 19 Dec 2012 13:38:24 -0500 Subject: core: working thread affinity concept into gr_blocks. Example in gnuradio-core/src/examples/mp-sched/affinity_set.py Documentation describing API in docs/doxygen/other/thread_affinity.dox --- gnuradio-core/src/lib/runtime/gr_block.h | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'gnuradio-core/src/lib/runtime/gr_block.h') diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 7a70bdaf0..9906d3632 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -359,6 +359,26 @@ class GR_CORE_API gr_block : public gr_basic_block { } // ---------------------------------------------------------------------------- + // Functions to handle thread affinity + + /*! + * \brief Set the thread's affinity to processor core \p n. + * + * \param mask a vector of unsigned ints of the core numbers available to this block. + */ + void set_processor_affinity(const std::vector &mask); + + /*! + * \brief Remove processor affinity to a specific core. + */ + void unset_processor_affinity(); + + /*! + * \brief Get the current processor affinity. + */ + std::vector processor_affinity() { return d_affinity; } + + // ---------------------------------------------------------------------------- private: @@ -373,6 +393,7 @@ class GR_CORE_API gr_block : public gr_basic_block { bool d_max_noutput_items_set; // if d_max_noutput_items is valid int d_max_noutput_items; // value of max_noutput_items for this block tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream + std::vector d_affinity; // thread affinity proc. mask protected: gr_block (void){} //allows pure virtual interface sub-classes -- cgit From 8b425118da3a09e490486b83a91208d2530d9897 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 25 Jan 2013 16:35:26 -0500 Subject: sched: adding in perf counters to measure performance of blocks during exectution of flowgraph. Conflicts: CMakeLists.txt gnuradio-core/src/lib/runtime/gr_block.cc gnuradio-core/src/lib/runtime/gr_block_detail.cc gnuradio-core/src/lib/runtime/gr_block_detail.h --- gnuradio-core/src/lib/runtime/gr_block.h | 38 ++++++++++++++++++++++++++++++++ 1 file changed, 38 insertions(+) (limited to 'gnuradio-core/src/lib/runtime/gr_block.h') diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 9906d3632..c9d2d8f53 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -358,6 +358,44 @@ class GR_CORE_API gr_block : public gr_basic_block { d_min_output_buffer[port] = min_output_buffer; } + // --------------- Performance counter functions ------------- + + /*! + * \brief Gets average noutput_items performance counter. + */ + float pc_noutput_items(); + + /*! + * \brief Gets average num items produced performance counter. + */ + float pc_nproduced(); + + /*! + * \brief Gets average average fullness of \p which input buffer. + */ + float pc_input_buffers_full(int which); + + /*! + * \brief Gets average fullness of all input buffers. + */ + std::vector pc_input_buffers_full(); + + /*! + * \brief Gets average fullness of \p which input buffer. + */ + float pc_output_buffers_full(int which); + + /*! + * \brief Gets average fullness of all output buffers. + */ + std::vector pc_output_buffers_full(); + + /*! + * \brief Gets average clock cycles spent in work. + */ + float pc_work_time(); + + // ---------------------------------------------------------------------------- // Functions to handle thread affinity -- cgit From d1735360bc7bfb04be56f2b255a0b84b4db31b84 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Fri, 15 Feb 2013 16:24:39 -0500 Subject: core: adding variance calcs to perf. counters. Using running mean/variance algorithm from Knuth's Art of Computer Programming. --- gnuradio-core/src/lib/runtime/gr_block.h | 41 +++++++++++++++++++++++++++++++- 1 file changed, 40 insertions(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/runtime/gr_block.h') diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index bd9ff42df..6e21d5b97 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -382,36 +382,75 @@ class GR_CORE_API gr_block : public gr_basic_block { */ float pc_noutput_items(); + /*! + * \brief Gets variance of noutput_items performance counter. + */ + float pc_noutput_items_var(); + /*! * \brief Gets average num items produced performance counter. */ float pc_nproduced(); /*! - * \brief Gets average average fullness of \p which input buffer. + * \brief Gets variance of num items produced performance counter. + */ + float pc_nproduced_var(); + + /*! + * \brief Gets average fullness of \p which input buffer. */ float pc_input_buffers_full(int which); + /*! + * \brief Gets variance of fullness of \p which input buffer. + */ + float pc_input_buffers_full_var(int which); + /*! * \brief Gets average fullness of all input buffers. */ std::vector pc_input_buffers_full(); + /*! + * \brief Gets variance of fullness of all input buffers. + */ + std::vector pc_input_buffers_full_var(); + /*! * \brief Gets average fullness of \p which input buffer. */ float pc_output_buffers_full(int which); + /*! + * \brief Gets variance of fullness of \p which input buffer. + */ + float pc_output_buffers_full_var(int which); + /*! * \brief Gets average fullness of all output buffers. */ std::vector pc_output_buffers_full(); + /*! + * \brief Gets variance of fullness of all output buffers. + */ + std::vector pc_output_buffers_full_var(); /*! * \brief Gets average clock cycles spent in work. */ float pc_work_time(); + /*! + * \brief Gets average clock cycles spent in work. + */ + float pc_work_time_var(); + + /*! + * \brief Resets the performance counters + */ + void reset_perf_counters(); + // ---------------------------------------------------------------------------- // Functions to handle thread affinity -- cgit From d8e73d63c0af6ba6810319d866cab07b332d0e42 Mon Sep 17 00:00:00 2001 From: Tom Rondeau Date: Tue, 26 Feb 2013 12:00:47 -0500 Subject: core: adding a mutex as a protected member of gr_block for use in protecting set and work function access to variables. This is used in gr-analog's noise_source and gr-filter's fir_filter_XXX since these two cause particular problems (in next's channel model). This shows the use of the mutex for general protection when needed. --- gnuradio-core/src/lib/runtime/gr_block.h | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'gnuradio-core/src/lib/runtime/gr_block.h') diff --git a/gnuradio-core/src/lib/runtime/gr_block.h b/gnuradio-core/src/lib/runtime/gr_block.h index 6e21d5b97..0783e8684 100644 --- a/gnuradio-core/src/lib/runtime/gr_block.h +++ b/gnuradio-core/src/lib/runtime/gr_block.h @@ -484,9 +484,9 @@ class GR_CORE_API gr_block : public gr_basic_block { gr_block_detail_sptr d_detail; // implementation details unsigned d_history; bool d_fixed_rate; - int d_min_noutput_items; bool d_max_noutput_items_set; // if d_max_noutput_items is valid int d_max_noutput_items; // value of max_noutput_items for this block + int d_min_noutput_items; tag_propagation_policy_t d_tag_propagation_policy; // policy for moving tags downstream std::vector d_affinity; // thread affinity proc. mask @@ -609,6 +609,12 @@ class GR_CORE_API gr_block : public gr_basic_block { std::vector d_max_output_buffer; std::vector d_min_output_buffer; + /*! Used by block's setters and work functions to make + * setting/resetting of parameters thread-safe. + * + * Used by calling gruel::scoped_lock l(d_setlock); + */ + gruel::mutex d_setlock; // These are really only for internal use, but leaving them public avoids // having to work up an ever-varying list of friend GR_CORE_APIs -- cgit