-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor workInternal #297
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -526,15 +526,14 @@ interpolation_decimation_test(const IntDecTestData &data, std::shared_ptr<gr::th | |
using scheduler = gr::scheduler::Simple<>; | ||
|
||
gr::Graph flow; | ||
auto &source = flow.emplaceBlock<gr::testing::TagSource<int>>({ { "n_samples_max", data.n_samples }, { "mark_tag", false } }); | ||
|
||
auto &int_dec_block = flow.emplaceBlock<IntDecBlock<int>>({ { "numerator", data.numerator }, { "denominator", data.denominator } }); | ||
auto &source = flow.emplaceBlock<gr::testing::TagSource<int, gr::testing::ProcessFunction::USE_PROCESS_BULK>>({ { "n_samples_max", data.n_samples }, { "mark_tag", false } }); | ||
auto &int_dec_block = flow.emplaceBlock<IntDecBlock<int>>({ { "numerator", data.numerator }, { "denominator", data.denominator } }); | ||
if (data.out_port_max >= 0) int_dec_block.out.max_samples = static_cast<size_t>(data.out_port_max); | ||
if (data.out_port_min >= 0) int_dec_block.out.min_samples = static_cast<size_t>(data.out_port_min); | ||
|
||
expect(eq(gr::ConnectionResult::SUCCESS, flow.connect<"out">(source).to<"in">(int_dec_block))); | ||
auto sched = scheduler(std::move(flow), thread_pool); | ||
sched.runAndWait(); | ||
auto sched = scheduler(std::move(flow), std::move(thread_pool)); | ||
expect(sched.runAndWait().has_value()); | ||
|
||
expect(eq(int_dec_block.status.process_counter, data.exp_counter)) << "processBulk invokes counter, parameters = " << data.to_string(); | ||
expect(eq(int_dec_block.status.n_inputs, data.exp_in)) << "last number of input samples, parameters = " << data.to_string(); | ||
|
@@ -557,8 +556,8 @@ stride_test(const StrideTestData &data, std::shared_ptr<gr::thread_pool::BasicTh | |
if (data.in_port_min >= 0) int_dec_block.in.min_samples = static_cast<size_t>(data.in_port_min); | ||
|
||
expect(eq(gr::ConnectionResult::SUCCESS, flow.connect<"out">(source).to<"in">(int_dec_block))); | ||
auto sched = scheduler(std::move(flow), thread_pool); | ||
sched.runAndWait(); | ||
auto sched = scheduler(std::move(flow), std::move(thread_pool)); | ||
expect(sched.runAndWait().has_value()); | ||
wirew0rm marked this conversation as resolved.
Show resolved
Hide resolved
|
||
|
||
expect(eq(int_dec_block.status.process_counter, data.exp_counter)) << "processBulk invokes counter, parameters = " << data.to_string(); | ||
expect(eq(int_dec_block.status.n_inputs, data.exp_in)) << "last number of input samples, parameters = " << data.to_string(); | ||
|
@@ -668,37 +667,36 @@ const boost::ut::suite _stride_tests = [] { | |
interpolation_decimation_test({ .n_samples = 549, .numerator = 1, .denominator = 50, .exp_in = 500, .exp_out = 10, .exp_counter = 1 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 100, .numerator = 3, .denominator = 7, .exp_in = 98, .exp_out = 42, .exp_counter = 1 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 100, .numerator = 100, .denominator = 100, .exp_in = 100, .exp_out = 100, .exp_counter = 1 }, thread_pool); | ||
|
||
interpolation_decimation_test({ .n_samples = 1000, .numerator = 10, .denominator = 1100, .exp_in = 0 , .exp_out = 0, .exp_counter = 0 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 1000, .numerator = 1, .denominator = 1001, .exp_in = 0 , .exp_out = 0, .exp_counter = 0 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 100, .numerator = 100000, .denominator = 1, .exp_in = 0 , .exp_out = 0, .exp_counter = 0 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 100, .numerator = 101, .denominator = 101, .exp_in = 0 , .exp_out = 0, .exp_counter = 0 }, thread_pool); | ||
|
||
interpolation_decimation_test({ .n_samples = 100, .numerator = 5, .denominator = 11, .out_port_min = 10 , .out_port_max = 41, .exp_in = 88, .exp_out = 40, .exp_counter = 1 }, thread_pool); | ||
// TODO: check with Semen if this test is possibly ill-defined and can never finish | ||
// interpolation_decimation_test({ .n_samples = 100, .numerator = 7, .denominator = 3, .out_port_min = 10 , .out_port_max = 10, .exp_in = 0, .exp_out = 0, .exp_counter = 0 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 80, .numerator = 2, .denominator = 4, .out_port_min = 20 , .out_port_max = 20, .exp_in = 40, .exp_out = 20, .exp_counter = 2 }, thread_pool); | ||
interpolation_decimation_test({ .n_samples = 100, .numerator = 7, .denominator = 3, .out_port_min = 10 , .out_port_max = 20, .exp_in = 6, .exp_out = 14, .exp_counter = 16 }, thread_pool); | ||
}; | ||
|
||
"Stride tests"_test = [&thread_pool] { | ||
stride_test( {.n_samples = 1024 , .stride = 0 , .in_port_max = 1024 , .exp_in = 1024 , .exp_out = 1024 , .exp_counter = 1 , .exp_total_in = 1024 , .exp_total_out = 1024 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .stride = 100 , .in_port_max = 50 , .exp_in = 50 , .exp_out = 50 , .exp_counter = 10 , .exp_total_in = 500 , .exp_total_out = 500 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .stride = 133 , .in_port_max = 50 , .exp_in = 50 , .exp_out = 50 , .exp_counter = 8 , .exp_total_in = 400 , .exp_total_out = 400 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .stride = 50 , .in_port_max = 100 , .exp_in = 50 , .exp_out = 50 , .exp_counter = 20 , .exp_total_in = 1950 , .exp_total_out = 1950 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .stride = 33 , .in_port_max = 100 , .exp_in = 10 , .exp_out = 10 , .exp_counter = 31 , .exp_total_in = 2929 , .exp_total_out = 2929 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 2 , .denominator = 4 , .stride = 50 , .in_port_max = 100 , .exp_in = 48 , .exp_out = 24 , .exp_counter = 20 , .exp_total_in = 1948 , .exp_total_out = 974 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 2 , .denominator = 4 , .stride = 50 , .in_port_max = 50 , .exp_in = 48 , .exp_out = 24 , .exp_counter = 20 , .exp_total_in = 960 , .exp_total_out = 480 }, thread_pool); | ||
|
||
std::vector<int> exp_v1 = {0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 12, 13, 14}; | ||
stride_test( {.n_samples = 15, .stride = 3, .in_port_max = 5, .exp_in = 3, .exp_out = 3, .exp_counter = 5, .exp_total_in = 23, .exp_total_out = 23, .exp_in_vector = exp_v1 }, thread_pool); | ||
|
||
stride_test( {.n_samples = 1000 , .numerator = 50 , .denominator = 50, .stride = 100 , .exp_in = 50 , .exp_out = 50 , .exp_counter = 10 , .exp_total_in = 500 , .exp_total_out = 500 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 50 , .denominator = 50, .stride = 133 , .exp_in = 50 , .exp_out = 50 , .exp_counter = 8 , .exp_total_in = 400 , .exp_total_out = 400 }, thread_pool); | ||
// the original test assumes that the incomplete chunk is also processed, currently we drop that. todo: switch to last sample update type incomplete | ||
//stride_test( {.n_samples = 1000 , .stride = 50 , .in_port_max = 100 , .exp_in = 50 , .exp_out = 50 , .exp_counter = 20 , .exp_total_in = 1950 , .exp_total_out = 1950 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 100 , .denominator = 100, .stride = 50 , .exp_in =100 , .exp_out = 100 , .exp_counter = 19 , .exp_total_in = 1900 , .exp_total_out = 1900 }, thread_pool); | ||
// this one is tricky, it assumes that there are multiple incomplete last chunks :/ not sure what to do here... | ||
//stride_test( {.n_samples = 1000 , .stride = 33 , .in_port_max = 100 , .exp_in = 10 , .exp_out = 10 , .exp_counter = 31 , .exp_total_in = 2929 , .exp_total_out = 2929 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 100 , .denominator = 100, .stride = 33 , .exp_in = 100 , .exp_out = 100 , .exp_counter = 28 , .exp_total_in = 2800 , .exp_total_out = 2800 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 50 , .denominator = 100 , .stride = 50, .exp_in = 100, .exp_out = 50 , .exp_counter = 19 , .exp_total_in = 1900 , .exp_total_out = 950 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 25 , .denominator = 50,.stride = 50 , .exp_in = 1000 , .exp_out = 500 , .exp_counter = 1 , .exp_total_in = 1000, .exp_total_out = 500 }, thread_pool); | ||
stride_test( {.n_samples = 1000 , .numerator = 24 , .denominator = 48,.stride = 50 , .exp_in = 48, .exp_out = 24, .exp_counter = 20 , .exp_total_in = 960, .exp_total_out = 480}, thread_pool); | ||
//std::vector<int> exp_v1 = {0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13, 12, 13, 14}; | ||
//stride_test( {.n_samples = 15, .stride = 3, .in_port_max = 5, .exp_in = 3, .exp_out = 3, .exp_counter = 5, .exp_total_in = 23, .exp_total_out = 23, .exp_in_vector = exp_v1 }, thread_pool); | ||
std::vector<int> exp_v1 = {0, 1, 2, 3, 4, 3, 4, 5, 6, 7, 6, 7, 8, 9, 10, 9, 10, 11, 12, 13}; | ||
stride_test( {.n_samples = 15, .numerator = 5, .denominator = 5, .stride = 3, .exp_in = 5, .exp_out = 5, .exp_counter = 4, .exp_total_in = 20, .exp_total_out = 20, .exp_in_vector = exp_v1 }, thread_pool); | ||
std::vector<int> exp_v2 = {0, 1, 2, 5, 6, 7, 10, 11, 12}; | ||
stride_test( {.n_samples = 15, .stride = 5, .in_port_max = 3, .exp_in = 3, .exp_out = 3, .exp_counter = 3, .exp_total_in = 9, .exp_total_out = 9, .exp_in_vector = exp_v2 }, thread_pool); | ||
|
||
stride_test( {.n_samples = 15, .numerator = 3, .denominator = 3, .stride = 5, .exp_in = 3, .exp_out = 3, .exp_counter = 3, .exp_total_in = 9, .exp_total_out = 9, .exp_in_vector = exp_v2 }, thread_pool); | ||
// assuming buffer size is approx 65k | ||
stride_test( {.n_samples = 1000000, .stride = 250000, .in_port_max = 100, .exp_in = 100, .exp_out = 100, .exp_counter = 4, .exp_total_in = 400, .exp_total_out = 400 }, thread_pool); | ||
stride_test( {.n_samples = 1000000, .stride = 249900, .in_port_max = 100, .exp_in = 100, .exp_out = 100, .exp_counter = 5, .exp_total_in = 500, .exp_total_out = 500 }, thread_pool); | ||
stride_test( {.n_samples = 1000000, .numerator = 100, .denominator = 100, .stride = 250000, .exp_in = 100, .exp_out = 100, .exp_counter = 4, .exp_total_in = 400, .exp_total_out = 400 }, thread_pool); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. TODO: as discussed, naming is hard: we need to find better descriptive names for 'numerator' and 'denominator'. This number pair does not describe the resampling ratio of the up- or down-conversion but also the default number of 'M' input samples that are converted into 'N' output samples ... Maybe our other SYS colleagues may have some suggestions since it's also them that should recognise/understand this complex ... the more intuitive the name the less we have to document the up-/downconversion. |
||
stride_test( {.n_samples = 1000000, .numerator = 100, .denominator = 100, .stride = 249900, .exp_in = 100, .exp_out = 100, .exp_counter = 5, .exp_total_in = 500, .exp_total_out = 500 }, thread_pool); | ||
}; | ||
// clang-format on | ||
|
||
|
@@ -716,9 +714,9 @@ const boost::ut::suite _stride_tests = [] { | |
expect(eq(ConnectionResult::SUCCESS, testGraph.connect<"out">(asyncBlock).to<"in">(sink))); | ||
|
||
scheduler::Simple sched{ std::move(testGraph) }; | ||
// TODO: temporary unavailable, one needs to understand how to deal with only Async inputs ports | ||
// sched.runAndWait(); | ||
// expect(eq(n_samples, static_cast<gr::Size_t>(sink.n_samples_produced))) << "Number of samples does not match"; | ||
expect(sched.runAndWait().has_value()); | ||
|
||
expect(eq(n_samples, static_cast<gr::Size_t>(sink.n_samples_produced))) << "Number of samples does not match"; | ||
}; | ||
|
||
"basic ports in arrays"_test = [] { | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why the drop of
tag.index < 0
? This used to indicate that a tag should be applied immediately regardless of other index constraints.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This predicate was and is used to get the next matching tag and the matching tag after that in
nSamplesUntilNextTag(port, offset=0)
, where offset is the default of 0 for getting the first tag and 1 for getting the Tag not at position 1. But sinceoffset
ends up inreadPosition
of the predicate tag index only, as soon a there is a tag with index < 0, it will also be return when looking for the second tag... I did not follow up more detailed how this worked previously, re-adding it makes qa_Block spin indefinitely.Tag propagation and setting _cachedTag is not influenced by this since there the
-1
condition is checked separately inPort::getTags(untilOffset)
.I'm not completely sure on whether this is the correct change, this is just the rationale for removing it. I tried to keep the changes outside of the workInternal (and its subfunctions) small, as i've been bitten sometimes by doing extensive changes thoughout the codebase at too many places at once.