pisa
pisa copied to clipboard
Single threaded execution requires"0" threads
This was introduced via #387 - The problem is that the documentation for TBB states that passing a parameter n to max_allowed_parallelism will result in n-1 worker threads operating: https://software.intel.com/en-us/node/589744
However, the rules state that passing n = 1 will result in serial processing. Our logic automatically increments the thread count by 1, meaning that serial processing is available but must be conducted by passing --threads 0 to each program. This seems confusing to users.
My solution would be to increment the passed value only if it exceeds 1. What do you guys think?
@elshize and @amallia
So just to clarify: in TBB, passing 1 makes it run sequentially, while passing 2 makes it run concurrently but with 1 worker, therefore kind of sequentially, too. Do I understand this right?
If so, then yeah, I would say if 1 then leave 1, and if > 1, then increase by 1. We should extract this logic to a function to have it only in one place. Maybe we can add another method to args::Threads called max_allowed_parallelism that will do that automatically. Then, we could use it like:
tbb::global_control control(
tbb::global_control::max_allowed_parallelism,
app.max_allowed_parallelism()
);
See, this is the confusing part. i believe that is correct, but I am not sure why they would allow n = 2 to run the same as n = 1 -- it's kinda unclear from the docs...
See, this is the confusing part. i believe that is correct, but I am not sure why they would allow
n = 2to run the same asn = 1-- it's kinda unclear from the docs...
It might not be the same. It could be that n = 2 just runs with 1 worker, while n = 1 runs a fully sequential implementation (special case) without spawning any additional threads. This kind of makes sense conceptually. n = 2 in fact would use 2 threads, but only one of them is the worker (so same as n > 2). It just makes no sense to actually run anything with n = 2 is all (although spawning an additional worker thread is negligible in most cases).
Then again, I can't be sure I'm interpreting it correctly.