c++ - Why is OpenMP outperforming threads? -
I'm calling it in OpenMP
#pragma for num_threads (totalThreads) Omp parallel) (unsigned i = 0; i; total threads; i ++) {workOnTheseEgeges (startIndex [i], and index [i]); } and it is in C ++ 11 std :: threads (I believe they are just pthreads)
vector & lt; Thread & gt; Threads; (Unsigned i = 0; i But, the OpenMP implementation speed is 2x - fast! I expected C ++ 11 threads to be sharp, because they are low levels Note: The above code is not being called once, but maybe 10,000 times in the loop, it may be that with some To do?
EDIT: For clarification, in practice, I have OpenMP or C + 11 version - not both. When I am using OpenMP code, it takes 45 seconds and when I am using C ++ 11, it takes 100 seconds.
Where total threads comes from your OpenMP version? I'm not sure this is startIndex.size () . OpenMP version totalThreads workers queue requests on thread. It seems that C ++ creates 11 versions, startIndex.size () threads, which contains ridiculous amount of overhead if it is a large number
Comments
Post a Comment