1. 5
  1.  

  2. 2

    I have to say, this OpenMP stuff is actually pretty cool, and actually works quite well, too.

    Where else have you seen a committee-derived spec that’s fully supported within a couple of years, and can be summarised on two sheets of A4?

    I was solving a programming puzzle recently, and was able to achieve excellent results by merely adding a single line of code to my programme (#pragma omp parallel for), and one single flag to the g++ compiler (-fopenmp). (For what it is worth, I did have to avoid using C++ iterators, convert a set into a vector, and iterate with a regular int i; i<n; i++, but it was still totally worth it, and very easy to grok and verify in the end.)

    I’ve tried using the goroutines in Go for the same task, which proved very ugly very fast compared to OpenMP (basically, you have to have two explicit extra loops to accommodate for explicit concurrency), plus for whichever reason the goroutines didn’t actually seem work in parallel in the end after all (cause unknown, but only 100% CPU would be used, compared to 385% w/ OpenMP w/ a single #pragma omp parallel for schedule(dynamic) num_threads(4)), and, IMHO, for parallel puzzle-style problems, OpenMP w/ C/C++ beats goroutines in Go any day!

    1. 1

      Did you set GOMAXPROCS to 4 as well?