c++ - OpenMP vs C++11 threads -


Take approximately 50 seconds to execute C ++ 11 threads in the following example, but OMP threads only 5 seconds no idea Why? (I can assure you that if you are doing actual work instead of doNothing , or if you do it in another order, etc.) I am also on a 16 core machine. I < / P>

  #include & lt; Iostream & gt; # Include & lt; Omp.h & gt; # Include & lt; Chrono & gt; #include & lt; Vector & gt; #include & lt; Thread & gt; using namespace std; Zero doNothing () {} int run (int algorithm torran) {auto startTime = std :: chrono :: system_clock :: now (); For (Int j = 1; J & lt; 100000; ++ J) (if (Algorithm TORU == 1) {Vector  For Thread; (Int i = 0; I  Elapsed_seconds = endTime - startTime; return elseed_seconds.count ();} int main () {int cppt = run (1); int ompt = run (2); court & lt ; & lt; cppt     

Comments

Popular posts from this blog

Java - Error: no suitable method found for add(int, java.lang.String) -

java - JPA TypedQuery: Parameter value element did not match expected type -

c++ - static template member variable has internal linkage but is not defined -