diff options
Diffstat (limited to 'gnuradio-core')
-rw-r--r-- | gnuradio-core/src/lib/general/gr_annotator_1to1.cc | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/general/gr_annotator_alltoall.cc | 3 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/gr_block_executor.cc | 18 | ||||
-rw-r--r-- | gnuradio-core/src/lib/runtime/qa_block_tags.cc | 122 |
4 files changed, 77 insertions, 69 deletions
diff --git a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc index 273f684ed..8b1da5778 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_1to1.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_1to1.cc @@ -86,8 +86,6 @@ gr_annotator_1to1::general_work (int noutput_items, uint64_t N = 10000; int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { - abs_N++; - // the min() is a hack to make sure this doesn't segfault if there are a // different number of ins and outs. This is specifically designed to test // the 1-to-1 propagation policy. @@ -101,6 +99,7 @@ gr_annotator_1to1::general_work (int noutput_items, out = (float*)output_items[i]; out[j] = in[j]; } + abs_N++; } consume_each(noutput_items); diff --git a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc index f1fb8bc31..699d5a256 100644 --- a/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc +++ b/gnuradio-core/src/lib/general/gr_annotator_alltoall.cc @@ -85,8 +85,6 @@ gr_annotator_alltoall::general_work (int noutput_items, uint64_t N = 10000; int noutputs = output_items.size(); for(int j = 0; j < noutput_items; j++) { - abs_N++; - for(int i = 0; i < noutputs; i++) { if(abs_N % N == 0) { pmt::pmt_t value = pmt::pmt_from_uint64(d_tag_counter++); @@ -101,6 +99,7 @@ gr_annotator_alltoall::general_work (int noutput_items, out[j] += in[j]; } } + abs_N++; } consume_each(noutput_items); diff --git a/gnuradio-core/src/lib/runtime/gr_block_executor.cc b/gnuradio-core/src/lib/runtime/gr_block_executor.cc index 86d10f81b..dd0993ec7 100644 --- a/gnuradio-core/src/lib/runtime/gr_block_executor.cc +++ b/gnuradio-core/src/lib/runtime/gr_block_executor.cc @@ -87,7 +87,7 @@ min_available_space (gr_block_detail *d, int output_multiple) return min_space; } -static int +static bool propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d, const std::vector<uint64_t> &start_nitems_read) { @@ -95,12 +95,12 @@ propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d, // if a sink, we don't need to move downstream; // and do not bother if block uses TAGS_NONE attribute if(d->sink_p()) { - return 0; + return true; } switch(policy) { case(gr_block::TPP_DONT): - return 0; + return true; break; case(gr_block::TPP_ALL_TO_ALL): // every tag on every input propogates to everyone downstream @@ -129,15 +129,15 @@ propagate_tags(gr_block::TAG_PROPAGATION_POLICY policy, gr_block_detail *d, } } else { - std::cerr << "Error: propagation_policy 'ONE-TO-ONE' requires ninputs == noutputs" << std::endl; - return -1; + std::cerr << "Error: gr_block_executor: propagation_policy 'ONE-TO-ONE' requires ninputs == noutputs" << std::endl; + return false; } break; default: - return 0; + return true; } - return 0; + return true; } gr_block_executor::gr_block_executor (gr_block_sptr block) @@ -350,7 +350,7 @@ gr_block_executor::run_one_iteration() // determine where to start looking for new tags as 1 past nitems read for (int i = 0; i < d->ninputs(); i++) - d_start_nitems_read[i] = d->nitems_read(i)+1; + d_start_nitems_read[i] = d->nitems_read(i); // Do the actual work of the block int n = m->general_work (noutput_items, d_ninput_items, @@ -358,7 +358,7 @@ gr_block_executor::run_one_iteration() LOG(*d_log << " general_work: noutput_items = " << noutput_items << " result = " << n << std::endl); - if(propagate_tags(m->tag_propagation_policy(), d, d_start_nitems_read) == -1) + if(!propagate_tags(m->tag_propagation_policy(), d, d_start_nitems_read)) goto were_done; if (n == gr_block::WORK_DONE) diff --git a/gnuradio-core/src/lib/runtime/qa_block_tags.cc b/gnuradio-core/src/lib/runtime/qa_block_tags.cc index 2560b7860..8612a1067 100644 --- a/gnuradio-core/src/lib/runtime/qa_block_tags.cc +++ b/gnuradio-core/src/lib/runtime/qa_block_tags.cc @@ -103,24 +103,24 @@ qa_block_tags::t1 () str2 << ann2->name() << ann2->unique_id(); pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt_from_uint64(40000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt_from_uint64(40000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(7)); + expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); std::vector<pmt::pmt_t> tags0 = ann0->data(); std::vector<pmt::pmt_t> tags3 = ann3->data(); @@ -130,6 +130,7 @@ qa_block_tags::t1 () CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); // For annotator 3, we know it gets tags from ann0 and ann1, test this + CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); for(size_t i = 0; i < tags3.size(); i++) { std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; //pmt_equal(tags3[i], expected_tags3[i]) @@ -138,6 +139,7 @@ qa_block_tags::t1 () // For annotator 4, we know it gets tags from ann0 and ann2, test this std::cout << std::endl; + CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); for(size_t i = 0; i < tags4.size(); i++) { std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); @@ -183,42 +185,48 @@ qa_block_tags::t2 () str1 << ann1->name() << ann1->unique_id(); pmt_t expected_tags2[12]; - expected_tags2[0] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(0)); - expected_tags2[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(0)); - expected_tags2[2] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags2[3] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags2[4] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags2[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags2[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(6)); - expected_tags2[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags2[8] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags2[9] = mp(pmt_from_uint64(40000), mp(str1.str()), mp("seq"), mp(9)); - expected_tags2[10] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags2[11] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(7)); + expected_tags2[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags2[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags2[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags2[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags2[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags2[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags2[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(6)); + expected_tags2[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags2[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags2[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(9)); + expected_tags2[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags2[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); pmt_t expected_tags4[12]; - expected_tags4[0] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags4[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(0)); - expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(5)); - expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(8)); - expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags4[8] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[9] = mp(pmt_from_uint64(40000), mp(str1.str()), mp("seq"), mp(11)); - expected_tags4[10] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(6)); - expected_tags4[11] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(7)); + expected_tags4[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(2)); + expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags4[2] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(5)); + expected_tags4[4] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[6] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(8)); + expected_tags4[7] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags4[8] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[9] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(11)); + expected_tags4[10] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags4[11] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); std::vector<pmt::pmt_t> tags0 = ann0->data(); std::vector<pmt::pmt_t> tags1 = ann1->data(); std::vector<pmt::pmt_t> tags2 = ann2->data(); + std::vector<pmt::pmt_t> tags3 = ann4->data(); std::vector<pmt::pmt_t> tags4 = ann4->data(); // The first annotator does not receive any tags from the null sink upstream CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); CPPUNIT_ASSERT_EQUAL(tags1.size(), (size_t)8); + // Make sure the rest all have 12 tags + CPPUNIT_ASSERT_EQUAL(tags2.size(), (size_t)12); + CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)12); + CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)12); + // For annotator[2-4], we know it gets tags from ann0 and ann1 // but the tags from the different outputs of ann1 are different for each. // Just testing ann2 and ann4; if they are correct it would be @@ -276,24 +284,24 @@ qa_block_tags::t3 () str2 << ann2->name() << ann2->unique_id(); pmt_t expected_tags3[8]; - expected_tags3[0] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(0)); - expected_tags3[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(0)); - expected_tags3[2] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(1)); - expected_tags3[3] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(2)); - expected_tags3[4] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(2)); - expected_tags3[5] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(4)); - expected_tags3[6] = mp(pmt_from_uint64(40000), mp(str1.str()), mp("seq"), mp(3)); - expected_tags3[7] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(6)); + expected_tags3[0] = mp(pmt_from_uint64(0), mp(str1.str()), mp("seq"), mp(0)); + expected_tags3[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(0)); + expected_tags3[2] = mp(pmt_from_uint64(10000), mp(str1.str()), mp("seq"), mp(1)); + expected_tags3[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(2)); + expected_tags3[4] = mp(pmt_from_uint64(20000), mp(str1.str()), mp("seq"), mp(2)); + expected_tags3[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(4)); + expected_tags3[6] = mp(pmt_from_uint64(30000), mp(str1.str()), mp("seq"), mp(3)); + expected_tags3[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(6)); pmt_t expected_tags4[8]; - expected_tags4[0] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(0)); - expected_tags4[1] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(1)); - expected_tags4[2] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(1)); - expected_tags4[3] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(3)); - expected_tags4[4] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(2)); - expected_tags4[5] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(5)); - expected_tags4[6] = mp(pmt_from_uint64(40000), mp(str2.str()), mp("seq"), mp(3)); - expected_tags4[7] = mp(pmt_from_uint64(40000), mp(str0.str()), mp("seq"), mp(7)); + expected_tags4[0] = mp(pmt_from_uint64(0), mp(str2.str()), mp("seq"), mp(0)); + expected_tags4[1] = mp(pmt_from_uint64(0), mp(str0.str()), mp("seq"), mp(1)); + expected_tags4[2] = mp(pmt_from_uint64(10000), mp(str2.str()), mp("seq"), mp(1)); + expected_tags4[3] = mp(pmt_from_uint64(10000), mp(str0.str()), mp("seq"), mp(3)); + expected_tags4[4] = mp(pmt_from_uint64(20000), mp(str2.str()), mp("seq"), mp(2)); + expected_tags4[5] = mp(pmt_from_uint64(20000), mp(str0.str()), mp("seq"), mp(5)); + expected_tags4[6] = mp(pmt_from_uint64(30000), mp(str2.str()), mp("seq"), mp(3)); + expected_tags4[7] = mp(pmt_from_uint64(30000), mp(str0.str()), mp("seq"), mp(7)); std::vector<pmt::pmt_t> tags0 = ann0->data(); std::vector<pmt::pmt_t> tags3 = ann3->data(); @@ -303,6 +311,7 @@ qa_block_tags::t3 () CPPUNIT_ASSERT_EQUAL(tags0.size(), (size_t)0); // For annotator 3, we know it gets tags from ann0 and ann1, test this + CPPUNIT_ASSERT_EQUAL(tags3.size(), (size_t)8); for(size_t i = 0; i < tags3.size(); i++) { std::cout << "tags3[" << i << "] = " << tags3[i] << "\t\t" << expected_tags3[i] << std::endl; //pmt_equal(tags3[i], expected_tags3[i]) @@ -311,6 +320,7 @@ qa_block_tags::t3 () // For annotator 4, we know it gets tags from ann0 and ann2, test this std::cout << std::endl; + CPPUNIT_ASSERT_EQUAL(tags4.size(), (size_t)8); for(size_t i = 0; i < tags4.size(); i++) { std::cout << "tags4[" << i << "] = " << tags4[i] << "\t\t" << expected_tags4[i] << std::endl; CPPUNIT_ASSERT_EQUAL(pmt_write_string(tags4[i]), pmt_write_string(expected_tags4[i])); |