-
Notifications
You must be signed in to change notification settings - Fork 115
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
[Dynamic Selection] Parallel tests for Dynamic Selection #1623
base: main
Are you sure you want to change the base?
Conversation
* Replace threads.push_back(std::thread(thread_func)); to threads.emplace_back(thread_func); Signed-off-by: Sergey Kopienko <[email protected]> * Fix includes order Signed-off-by: Sergey Kopienko <[email protected]> --------- Signed-off-by: Sergey Kopienko <[email protected]>
@AnuyaWelling2801 Could you please extract this two typical peace of code in your test into some functions? for(int i=0;i<n_threads;i++){
threads.emplace_back(thread_func);
} for(auto& thread : threads){
thread.join();
} There are a lot of this code... |
@AnuyaWelling2801 another question: if (!pass)
{
std::cout << "ERROR: did not select expected resources\n";
return 1;
} in the function The question: should we continue test is it's happen ( |
CI is red... |
|
||
class Barrier { | ||
public: | ||
explicit Barrier(std::size_t count) : threshold(count), count(count), generation(0) {} |
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.
I think we will have incorrect work here if count
== 0 or threshold
== 0.
I believe assert
may help to check this.
std::condition_variable condition; | ||
std::size_t threshold; | ||
std::size_t count; | ||
std::size_t generation; |
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.
std::size_t generation; | |
std::size_t generation = 0; |
|
||
class Barrier { | ||
public: | ||
explicit Barrier(std::size_t count) : threshold(count), count(count), generation(0) {} |
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.
explicit Barrier(std::size_t count) : threshold(count), count(count), generation(0) {} | |
explicit Barrier(std::size_t count) : threshold(count), count(count) {} |
void arrive_and_wait() { | ||
std::unique_lock<std::mutex> lock(mutex); | ||
auto gen = generation; | ||
if (--count == 0) { |
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.
What if count
== 0 ?
Added Parallel tests for
More to be added either in this PR or a separate PR