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

How to use reduciton clause as MAX, MIN in OpenMP

Chang_Lei
Beginner
919 Views

The samplecodes are:
!$omp parallel do private(k,j,i) reduction(MAX:p_residual)
do k=0,Nz+1
do j=0,Ny+1
do i=0,Nx+1
p_residual=max(p_residual,abs(p(i,j,k)-ff(i,j,k)
enddo
enddo
enddo

When I compile them using ifort -openmp ...", error information is given:
/tmp/ipo_ifort5rQYaj.o: In function `L_pressure_mkl__275__par_loop11_2.11':
/tmp/ipo_ifort5rQYaj.f:(.text+0x1a833): undefined reference to `__kmpc_atomic_float4_max'

It seems that the compiler cannot find the MAX clause. Could anyone help me? Thanks.
Changlei

0 Kudos
1 Solution
Ron_Green
Moderator
919 Views
Changlei,

The message above indicates that you are using -ipo or the -fast option (correct?) Try removing that option.

But I don't get the error even with -ipo. did you source ifortvar.sh? You know,

source /opt/intel/Compiler/11.1/073/bin/ifortvars.sh intel64

this sets up the library paths needed for the compiler to link correctly. This has to be done on every login OR you have to put that in your ~/.bashrc file.

this worked for me with 11.1.073:

[rwgreen@dpd22 78942]$ more repro.f90
program repro
real :: p_residual, p(10,10,10), ff(10,10,10)

!$omp parallel do private(k,j,i) reduction(MAX:p_residual)
do k=0,Nz+1
do j=0,Ny+1
do i=0,Nx+1
p_residual=max(p_residual,abs(p(i,j,k)-ff(i,j,k)))
enddo
enddo
enddo

end program repro
[rwgreen@dpd22 78942]$ ifort -openmp repro.f90
[rwgreen@dpd22 78942]$

View solution in original post

0 Kudos
2 Replies
Ron_Green
Moderator
920 Views
Changlei,

The message above indicates that you are using -ipo or the -fast option (correct?) Try removing that option.

But I don't get the error even with -ipo. did you source ifortvar.sh? You know,

source /opt/intel/Compiler/11.1/073/bin/ifortvars.sh intel64

this sets up the library paths needed for the compiler to link correctly. This has to be done on every login OR you have to put that in your ~/.bashrc file.

this worked for me with 11.1.073:

[rwgreen@dpd22 78942]$ more repro.f90
program repro
real :: p_residual, p(10,10,10), ff(10,10,10)

!$omp parallel do private(k,j,i) reduction(MAX:p_residual)
do k=0,Nz+1
do j=0,Ny+1
do i=0,Nx+1
p_residual=max(p_residual,abs(p(i,j,k)-ff(i,j,k)))
enddo
enddo
enddo

end program repro
[rwgreen@dpd22 78942]$ ifort -openmp repro.f90
[rwgreen@dpd22 78942]$

0 Kudos
Chang_Lei
Beginner
919 Views
Hi~
You are right. I used the -ipo -O3 option.
I found it works for 11.1.074, but for another (which is the default in my environment)version 10.1, it has the problem.
I have tried to put the source commad (source /opt/intel/Compiler/11.0/074/bin/ifortvars.sh intel64)to the .bashrc, in orderto have version 11.1 automaticly when login in. But it does not work for unknown reasons. The ~/.bashrc file is attached.
Could yougive me some suggestions?
With bestregards.
Changlei
0 Kudos
Reply