1

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
648trindade
  • 689
  • 2
  • 5
  • 21

2 Answers2

1

You need to compile your application with eztrace_cc: instead of compiling it with

$ gcc -o programa programa.c -fopenmp

use

$ eztrace_cc gcc -o programa programa.c -fopenmp

A simple way to do this is to modify your makefile and set

CC=eztrace_cc gcc

You can take a look at the OpenMP tutorial on the EZTrace webpage: http://eztrace.gforge.inria.fr/tutorials/tutorial_openmp/

0

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)

648trindade
  • 689
  • 2
  • 5
  • 21