H
H
Hatemylifezxc2020-04-25 02:47:16
C++ / C#
Hatemylifezxc, 2020-04-25 02:47:16

Why do programs load multiple threads even if they don't contain multi-threaded code?

Here on this site https://benchmarksgame-team.pages.debian.net/bench... it is shown that the program, for example, loads all 4 threads at 100%, but if you look at the code itself, there is not a single line about multithreading , how is this possible ?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
N
ncpuma, 2020-04-25
@Hatemylifezxc

Link to multi-threaded program

#pragma omp parallel for
   for (i = 0; i < n; i++) {
      __m128d sum = _mm_setzero_pd();

      int j;
      for (j = 0; j < n; j += 2) {
         __m128d b = _mm_set_pd(v[j],v[j+1]);
         __m128d a = _mm_set_pd(A(i,j), A(i,j+1));
         sum = _mm_add_pd(sum, _mm_div_pd(b, a));
      }
      out[i] = sum[0] + sum[1];
   }
}

The #pragma omp parallel for directive is a multi-threaded OpenMP library, if I'm not mistaken

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question