Skip to content

Commit

Permalink
Add threshold requirement for eh tests (#399)
Browse files Browse the repository at this point in the history
* Add threshold requirement for eeh tests

* typo error fix
  • Loading branch information
Iliamish authored May 18, 2021
1 parent c46e2aa commit 3e9e8c9
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions test/tbb/test_eh_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1146,8 +1146,9 @@ class ParForEachWorker {
template <class Iterator, class body_to_cancel>
void TestCancelation1_parallel_for_each () {
ResetGlobals( false );
// Threshold should leave more then max_threads tasks to test the cancellation. Set the threshold to iter_range_size()/4 since iter_range_size >= max_threads*2
// Threshold should leave more than max_threads tasks to test the cancellation. Set the threshold to iter_range_size()/4 since iter_range_size >= max_threads*2
intptr_t threshold = get_iter_range_size() / 4;
REQUIRE_MESSAGE(get_iter_range_size() - threshold > g_NumThreads, "Threshold should leave more than max_threads tasks to test the cancellation.");
tbb::task_group tg;
tbb::task_group_context ctx;
Cancellator cancellator(ctx, threshold);
Expand Down Expand Up @@ -1236,14 +1237,12 @@ class InputFilter {
mutable std::atomic<size_t> m_Item{};
mutable std::vector<size_t> m_Buffer;
public:
InputFilter() {
InputFilter() : m_Buffer(get_iter_range_size()) {
m_Item = 0;
m_Buffer.resize(get_iter_range_size());
for (size_t i = 0; i < get_iter_range_size(); ++i )
m_Buffer[i] = 1;
}
InputFilter(const InputFilter& other) : m_Item(other.m_Item.load()) {
m_Buffer.resize(get_iter_range_size());
InputFilter(const InputFilter& other) : m_Item(other.m_Item.load()), m_Buffer(get_iter_range_size()) {
for (size_t i = 0; i < get_iter_range_size(); ++i )
m_Buffer[i] = other.m_Buffer[i];
}
Expand Down Expand Up @@ -1623,8 +1622,9 @@ class PipelineLauncher {
void TestCancelation1_pipeline () {
ResetGlobals();
g_ThrowException = false;
// Threshold should leave more then max_threads tasks to test the cancellation. Set the threshold to iter_range_size()/4 since iter_range_size >= max_threads*2
// Threshold should leave more than max_threads tasks to test the cancellation. Set the threshold to iter_range_size()/4 since iter_range_size >= max_threads*2
intptr_t threshold = get_iter_range_size() / 4;
REQUIRE_MESSAGE(get_iter_range_size() - threshold > g_NumThreads, "Threshold should leave more than max_threads tasks to test the cancellation.");
RunCancellationTest<PipelineLauncher<FilterToCancel>, Cancellator>(threshold);
g_TGCCancelled.validate(g_NumThreads, "Too many tasks survived cancellation");
REQUIRE_MESSAGE (g_CurExecuted < g_ExecutedAtLastCatch + g_NumThreads, "Too many tasks were executed after cancellation");
Expand Down

0 comments on commit 3e9e8c9

Please sign in to comment.