Community
cancel
Showing results for 
Search instead for 
Did you mean: 
N_Netto
Beginner
300 Views

OpenMP reduction problem with custom defined operator

I've found a problem when trying to compile an OpenMP code with user defined type and operator. 

I've been successful in producing the following toy code for reproduction purposes:

    type mytype
        real(8)     :: a, b
        integer(4)  :: c, d
    end type
    interface operator(.max.)
        module procedure :: max_mytype
    end interface
!$omp declare reduction (.max. : mytype : omp_out = omp_out .max. omp_in ) initializer ( omp_priv = mytype(0.,0.,0,0) )

    function max_mytype ( op1, op2 ) result ( ans ) 
    class(mytype), intent(in)    :: op1, op2
    type(mytype)                :: ans
    
    if ( op2%a > op1%a ) then
        ans%a  = op2%a
        ans%b  = op2%b
        ans%c  = op2%c
        ans%d  = op2%d
    else
        ans%a  = op1%a
        ans%b  = op1%b
        ans%c  = op1%c
        ans%d  = op1%d
    endif
    end function

 When I'm trying to create a parallel instance with this reduction operator, the compiler yields an internal error:

!$OMP PARALLEL DO default(none) private(thread) reduction(.max.:ermx)
    do i =1, 1000
        thread = omp_get_thread_num()
        ermx = mytype(1.0*thread,2.0*thread,thread,2*thread)
    end do
!$OMP END PARALLEL DO

 

Compiling with Intel(R) Visual Fortran Compiler 19.0.5.281 [Intel(R) 64]...
ToyErroMax.f90
C:\Users\nicolasrln\source\repos\ToyErroMax\ToyErroMax\ToyErroMax.f90(85): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
!$OMP PARALLEL DO default(none) private(thread) reduction(.max.:ermx)
^
[ Aborting due to internal error. ]

I've tried with other clauses first as well, like shared, copyin, firstprivate etc... none was allowed. 

However, I've discovered that when the reduction clause is my first clause, the file compiles just fine:

!$OMP PARALLEL DO reduction(.max.:ermx) default(none) private(thread)
!!$OMP PARALLEL DO default(none) private(thread) reduction(.max.:ermx)! does not work
    do i =1, 1000
        thread = omp_get_thread_num()
        ermx = error_convergence(1.0*thread,2.0*thread,thread,2*thread)
    end do
!$OMP END PARALLEL DO

 

------ Build started: Project: ToyErroMax, Configuration: Debug|x64 ------

Compiling with Intel(R) Visual Fortran Compiler 19.0.5.281 [Intel(R) 64]...
ToyErroMax.f90

Build log written to  "file://C:\Users\nicolasrln\source\repos\ToyErroMax\ToyErroMax\x64\Debug\BuildLog.htm"
ToyErroMax - 0 error(s), 0 warning(s)

 

Aside from the internal error thing, I should be allowed to put my reduction clause in any position in the omp declartion? 


Thanks!

0 Kudos
4 Replies
Ron_Green
Moderator
273 Views

I'll take a look at this and get a bug report going if I can reproduce the error.

Ron_Green
Moderator
268 Views

you should not have to split the clauses across 2 lines.  That is a compiler error.  Any Internal Compiler Error is a bug.  But since this is the 19.0 branch I would encourage you to try the 2021.1 compiler in beta in the oneAPI HPC Toolkit or a 19.1 compiler.

 

 

N_Netto
Beginner
261 Views

 


@Ron_Green wrote:

you should not have to split the clauses across 2 lines.  That is a compiler error.  Any Internal Compiler Error is a bug.  But since this is the 19.0 branch I would encourage you to try the 2021.1 compiler in beta in the oneAPI HPC Toolkit or a 19.1 compiler.


I'm not, actually, splitting (One line is actually commented). The only difference is the position of the reduction clause. If I put any other clause before a custom reduction, the compiler crashes. 

I've tried with my 19.1.2 compiler as well (same results).

This code:

 

!$OMP PARALLEL DO reduction(.max.:ermx) default(none) private(thread)
!!$OMP PARALLEL DO default(none) private(thread) reduction(.max.:ermx)
    do i =1, 1000
        thread = omp_get_thread_num()
        ermx = mytype(1.0*thread,2.0*thread,thread,2*thread)
    end do
!$OMP END PARALLEL DO

 

 Leads to:

 

1>------ Build started: Project: ToyErroMax, Configuration: Debug x64 ------
1>Linking...
1>Embedding manifest...
1>
1>Build log written to  "file://C:\Users\nicolasrln\source\repos\ToyErroMax\ToyErroMax\x64\Debug\BuildLog.htm"
1>ToyErroMax - 0 error(s), 0 warning(s)
========== Build: 1 succeeded, 0 failed, 0 up-to-date, 0 skipped ==========

 


But this:

 

!!$OMP PARALLEL DO reduction(.max.:ermx) default(none) private(thread)
!$OMP PARALLEL DO default(none) private(thread) reduction(.max.:ermx)
    do i =1, 1000
        thread = omp_get_thread_num()
        ermx = mytype(1.0*thread,2.0*thread,thread,2*thread)
    end do
!$OMP END PARALLEL DO

 

Leads to this:

 

------ Build started: Project: ToyErroMax, Configuration: Debug|x64 ------

Compiling with Intel(R) Visual Fortran Compiler 19.1.2.254 [Intel(R) 64]...
ToyErroMax.f90
C:\Users\nicolasrln\source\repos\ToyErroMax\ToyErroMax\ToyErroMax.f90(85): internal error: Please visit 'http://www.intel.com/software/products/support' for assistance.
!$OMP PARALLEL DO default(none) private(thread) reduction(.max.:ermx)
^
[ Aborting due to internal error. ]
compilation aborted for C:\Users\nicolasrln\source\repos\ToyErroMax\ToyErroMax\ToyErroMax.f90 (code 1)

Build log written to  "file://C:\Users\nicolasrln\source\repos\ToyErroMax\ToyErroMax\x64\Debug\BuildLog.htm"
ToyErroMax - 1 error(s), 0 warning(s)

Thanks for your support!

 

Ron_Green
Moderator
237 Views

bug ID is CMPLRIL0-33295. It affects all newer versions of the compiler 19.1 and 2021.1Beta


Reply