Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
27105 Discussions

OpenMP bug when accessing host associated variable in Task construct

schiffmann__florian
203 Views

Hello,

 

I ran into a problem with the intel fortran compiler on windows.

Compiler Version:

Intel(R) Visual Fortran Intel(R) 64 Compiler for applications running on Intel(R) 64, Version 19.1.3.311 Build 20201010_000000

OS:

Windows 10.

 

Here is a small program that illustrates the problem (OMPBug.f90):

!=====================================================================
MODULE recTaskCall

CONTAINS

   SUBROUTINE rec_in (nlevels)
      INTEGER     :: nlevels

!$OMP PARALLEL SHARED(nlevels) DEFAULT(NONE) 
!$OMP SINGLE  
      CALL rec_low(0)
!$OMP END SINGLE    
!$OMP END PARALLEL

      CONTAINS      
         RECURSIVE SUBROUTINE rec_low(idepth)
            INTEGER        :: idepth

            IF (idepth== nlevels) RETURN
!$OMP TASK
            CALL rec_low(idepth+1)
!$OMP END TASK            

       END SUBROUTINE

    END SUBROUTINE

END MODULE

PROGRAM testme
    USE recTaskCall

    CALL rec_in(3)

END PROGRAM
!============================================================

 

After compiling the program with 

ifort OMPBug.f90 /traceback /Qopenmp /debug

 

and running the exe, I get an access violation when nlevels is accessed from the call to rec_in within the openmp task construct.

 

It worked with gfortran and I did not get a compile time error so I assume this is valid code,... I might be wrong. However, it seems that with the intel compiler the host association is lost within the openmp construct.

 

Is there an obvious solution I am missing? I am aware, that I can pass nlevels and the problem goes away. However, with the variables in my real code this strategy leads to a stackoverflow that is not easily fixed.

 

Best regards

Flo

 

0 Kudos
4 Replies
Barbara_P_Intel
Moderator
161 Views

Unfortunately, copy/paste isn't working for me to grab your code.

Does your small program work if you compile with /Qopenmp-stubs?  That turns your program into a sequential program.  It's a handy compiler option for debugging OpenMP applications.

 

Steve_Lionel
Black Belt Retired Employee
152 Views

Oh good grief, the forum changes broke that too. You can select the text but as soon as you try to copy it, the selection disappears.

schiffmann__florian
146 Views

Dear Barbara,

 

thanks for the reply, I tried with the Qopenmp-stubs flag and it ran through without an error. However, I don't quite see for this code how that option differs  to compiling without Qopenmp? I attached the source code as a file. I hope that download still works.

 

Flo

Barbara_P_Intel
Moderator
126 Views

When you compile without Qopenmp, the OpenMP directives are considered comments and ignored.  

When compiling with Qopenmp and the stubs library the OpenMP directives are processed and the stubs library is actually used and the app runs serially.  

 

Reply