1

I am trying to implement < a href="www.futurechips.org/tips-for-power-coders/writing-optimizing-parallel-programs-complete.html" > the histogram parallelization (www.futurechips.org/tips-for-power-coders/writing-optimizing-parallel-programs-complete.html) < /a > to one of my code using OpenMP. The snippet of my code is as follows:

#pragma omp parallel //shared(frame, f_end, chain) private(f, dt, d)
{
    int tid = omp_get_thread_num();
    __declspec(align(64))double p_acfRv[num_threads + 1][corr_length + 2];
    // memset(p_acfRv, 0, sizeof(double) * (corr_length + 2));

    #pragma omp for
    for(f = frame; f >= f_end; f--) {
        dt = abs(frame - f);
        for(d = 0; d < DIM; d++)
            p_acfRv[tid][dt] += (Rv[f][chain][d] * Rv[frame][chain][d]);
    }
    #pragma omp for
    for(f = frame; f >= f_end; f--) {
        dt = abs(frame - f);
        for(int t = 0; t < num_threads; t++) {
            acfRv[dt] += p_acfRv[t][dt];
        }
    }
}

When I try to compile the code, it shows the following error:

error: expected ‘;’ before ‘double’ error ‘p_acfRv’ undeclared (first use in this function)

Can anyone point out, how can I get rid of this error. I am very new to the OpenMP world.

Arun A S
  • 6,421
  • 4
  • 29
  • 43
chandan
  • 71
  • 1
  • I used gcc in linux. – chandan Feb 23 '15 at 13:31
  • 1
    You need to find the way to declare alignment for gcc, Microsoft __declspec doesn't work for gcc.Look at this question: http://stackoverflow.com/questions/7895869/cross-platform-alignx-macro – Alex F Feb 23 '15 at 13:34
  • Thanks @AlexFarber. I have replaced it with __attribute__((align(64))). It compiles now. – chandan Feb 23 '15 at 13:57
  • I am just confused which are the variables that can be classified as shared or private. Any insight would be very helpful. – chandan Feb 23 '15 at 14:23
  • Local variables declared in the scope of the omp parallel are implicitly private, everything else is implicitly shared (which can be overridden by naming it in the private() clause of the parallel). My preference is to declare private variables inside the parallel scope and not use the private clause, but then I like to declare variables in as small a scope as possible anyway :-) – Jim Cownie Feb 24 '15 at 10:13

0 Answers0