Search code examples
cmultithreadingopenmptrace

Why do my runtime images taken with eztrace not show the idleness of threads?


I was doing a college work parallelizing a code in C with OpenMP and then getting a runtime image with eztrace, converting and displaying on vite.

But it's not showing the idle time on threads. Visualização com vite
My code obviously has an idle thanks to the use of static clause

int prime_v2(int n)
{
  int i;
  int j;
  int prime;
  int total = 0;

  #pragma omp parallel for schedule(static) private(j,prime) shared(total)
  for (i = 2; i <= n; i++)
  {
    prime = 1;
    for (j = 2; j < i; j++)
    {
      if (i % j == 0)
      {
        prime = 0;
        break;
      }
    }
    #pragma omp atomic
    total = total + prime;
  }
  return total;
}

As can be seen, as i increases, increases the total number of inner loop iterations, requiring more time.

With the static division (for 4 threads for example), each thread gets a 'organized' range of iterations:

  • thread 0: 0 ~ n/4 - 1
  • thread 1: n/4 ~ n/2 - 1
  • thread 2: n/2 ~ 3n/4 -1
  • thread 3: 3n/4 ~ n

That is, the thread 3 caught iterations that require more time. But this idleness is not shown in the vite. Why?

Here how I performed, converted and exibit the vite:

eztrace -t omp ./programa
eztrace_convert -t PAJE /tmp/rafael_eztrace_log_rank_1
vite eztrace_output.trace

Solution

  • My problem was with the eztrace version of debian repository

    I downloaded an older version and its worked fine. (some with the binary eztrace.old)