Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
FPGA community forums and blogs on community.intel.com are migrating to the new Altera Community and are read-only. For urgent support needs during this transition, please visit the FPGA Design Resources page or contact an Altera Authorized Distributor.
29280 Discussions

Problem with omp simd loop, ifx 2025.2

puipp
Beginner
668 Views

I experience the following problem with ifx (IFX) 2025.2.0 20250605

forrtl: severe (408): fort: (3): Subscript #2 of the array RES has value 0 which is less than the lower bound of 1

 which I could reproduce with the following test code

subroutine problem()

  integer, parameter :: np = 1000
  integer :: i, n, l, m, k, k_periodic, nk_stripped, j, lb, ub
  integer :: res(np, 1:4)
  nk_stripped = 4

  lb=-1
  ub=4
  !$omp parallel default(none) firstprivate(lb,ub) shared(nk_stripped, res) private(i, k, k_periodic)
  do n = 1,2
  do m = 1,10
  do l = 1,10
  do k = lb, ub
    !$omp do simd
    do i = 1, np
      k_periodic = modulo(k-1, nk_stripped) + 1
      if (k_periodic < 1 .or. k_periodic > nk_stripped) then
        print *, "ERROR: k_periodic out of bounds: ", k_periodic, " at k=", k, " i=", i
      end if
      res(i, k_periodic) = k
    end do
    !$omp end do simd
  end do
  end do
  end do
  end do
  !$omp end parallel

end subroutine

 produces

ERROR: k_periodic out of bounds:            0  at k=           0  i=         744
forrtl: severe (408): fort: (3): Subscript #2 of the array RES has value 0 which is less than the lower bound of 1

while I would expect k_periodic above to always be within 1 and 4.

I only encounter this with ifx in debug mode, not with gcc or ifort, and only when build in debug mode using the following flags

-g -fPIC -fpp -g -no-wrap-margin -traceback -fstack-security-check -fpe0 -O0 -warn all -check all,noarg_temp_created
 -debug inline-debug-info -ftrapv -Rno-debug-disables-optimization -fiopenmp

removing the simd from the code avoids the problem. Is this expected behaviour?

0 Kudos
1 Reply
jimdempseyatthecove
Honored Contributor III
629 Views
    !$omp do simd
    do i = 1, np

Implies (requires?) that an array in the body of the do loop is referenced in a manner suitable for simd instructions

The body of the loop contains:

      k_periodic = modulo(k-1, nk_stripped) + 1

Which might confuse the code generation for

      res(i, k_periodic) = k

I suggest you relocate that (and the error test) code to the do k loop and see what happens:

  !$omp parallel default(none) firstprivate(lb,ub) shared(nk_stripped, res) private(i, k, k_periodic)
  do n = 1,2
  do m = 1,10
  do l = 1,10
  do k = lb, ub
    k_periodic = modulo(k-1, nk_stripped) + 1
    if (k_periodic < 1 .or. k_periodic > nk_stripped) then
      print *, "ERROR: k_periodic out of bounds: ", k_periodic, " at k=", k, " i=", i
    end if
    !$omp do simd
    do i = 1, np
      res(i, k_periodic) = k
    end do
    !$omp end do simd
  end do
  end do
  end do
  end do
  !$omp end parallel

BTW, I suggest you use:

k_periodic = modulo(k-lb, nk_stripped) + 1

as it is clearer as to the intent.

Jim Dempsey

 

0 Kudos
Reply