0
votes

I'm new to OpenMP and I'm trying to paralellize an already existing serial code. The code has about 40000 lines, so I can't really post it here.

I'm trying to implement the following code (in C) in FORTRAN:

 my_pointer = listhead;
 #pragma omp parallel
 {
      #pragma omp single nowait
      {
      while(my_pointer) {
      #pragma omp task firstprivate(my_pointer)
      {
      (void) do_independent_work (my_pointer);
      }
 my_pointer = my_pointer->next ;
 }
 } // End of single - no implied barrier (nowait)
 } // End of parallel region - implied barrier

In my code:

  • my_pointer = zi ;
  • listhead = z%first ;
  • zi%kc(zi%np) is an array of of size zi%np ;
  • do_independent_work(my_pointer) = ALLOCATE(zi%kc(zi%np)) and initializes the vector to 0 ;

My code is the following:

!$OMP PARALLEL
        !$OMP SINGLE 
            DO WHILE(ASSOCIATED(zi))
                IF (zi%compt) THEN
                    !$OMP TASK
                         ALLOCATE(zi%kc(zi%np), STAT = AllocateStatus )
                         IF (AllocateStatus /= 0) STOP "*** zi%kc Allocate failed ***"
                         FORALL(i=1:zi%np)
                         zi%kc(i) = 0.0_SDP
                         END FORALL 
                     !$OMP END TASK
                ENDIF
                zi => zi%next
            ENDDO
        !$OMP END SINGLE NOWAIT
!$OMP END PARALLEL

The problem is: the serial version of this code runs without any problem, while the parallel version I implemented crashes for some reason.

I'm I doing something fundamentally wrong?

Also, if I put firstprivate(zi) next to "!$OMP TASK" I get "Error 1 error #7266: A F90 pointer is not permitted in an OpenMP* FIRSTPRIVATE, LASTPRIVATE or REDUCTION clause."

I'm using Parallel Studio XE 2011 with Visual Studio 2010.

1
Not that it is important, but instead of FORALL(i=1:zi%np) zi%kc(i) = 0.0_SDP END FORALL you can do just zi%kc = 0.Vladimir F
You are right, I'll change it. I'm still annalising the code I've been given.André Almeida

1 Answers

0
votes

Fortran pointers were allowed in OpenMP 3.1, you should update your compiler (2011 is old).