Clang does not support OpenMP (yet), but it is possible to implement "parallel" with C ++ 11 is?
OpenMP version:
// parallelfor_gcc.cpp // g ++ -o2-valve -study = c ++ 11 -phipampump parallel FOR_gcc.cpp # include & lt; Semith & gt; # Include & lt; Vector & gt; Int main () {unsigned full size = 1e8; Std :: vector & lt; Double & gt; Vect (size); #pragma omp for parallel (unsigned int i = 0; i C + 11 version:
// parallelfor_clang.cpp // clang ++ -O4 -Wall -std = c ++ 11 -lpthread Parallelfor_clang .cpp #include & lt; Semith & gt; # Include & lt; Thread & gt; # Include & lt; Vector & gt; Parallel to zero (constant unsigned integer size, std :: function & void (const unscripted int)> func) {const unsigned int nbThreads = std :: thread :: hardware_concurrency (); Std :: vector & lt; Std :: thread & gt; Threads; For (unsigned int idThread = 0; idThread & lt; nbThreads; idThread ++) {auto threadFunc = [=, and thread] (for (for unsigned int i = idThread; i OpenMP clause (first private ...) can be implemented in the same way But this is a bit more work ...
No comments:
Post a Comment