+ 2
Parellelism in STL
Hi Please find attached code. Question is related to threads.... With execution strategies as par i.e. parellel, why thread id is not printed differently for each element access due to different different threads ? Thread id is same for this code which means no different threads are created ? https://code.sololearn.com/c6S4hojS3zm1/?ref=app
3 Answers
+ 2
Ketan Lalcheta afaik, execution policy is just a permission and not requirement, so it is quite possible for algorithm to execute sequentially even if you tell compiler to call parallel overload of the same.
+ 1
I confirmed that the id being printed is the same as the main thread id. Maybe I am missing something, but I don't see where the code starts any new threads. I expected to find a statement in the form of:
std::thread handle (process, params);
Side note: multithreading is not necessarily done in parallel. Parallel only occurs if threads get distributed across processors. Otherwise, it is done concurrently.
0
I thought par execution strategy will start new threads and hence increases speed