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

Question on optimization directive IVDEP

Harald
Beginner
513 Views

Hello,

consider the code:

module ifc_ivdep_test
contains
  subroutine sub1 (z, x, y)
    real, intent(out) :: z(:)
    real, intent(in)  :: x(:)
    real, intent(in)  :: y(:)
!dir$ ivdep
    z = x * y           ! OK
  end subroutine sub1
  subroutine sub2 (z, x, y)
    real, intent(out) :: z(:,:)
    real, intent(in)  :: x(:,:)
    real, intent(in)  :: y(:,:)
!dir$ ivdep
    z = x * y           ! Warning
  end subroutine sub2
end module ifc_ivdep_test

Compiling this code gives a warning:

% ifort -V -c ifc_ivdep_test.f90 
Intel(R) Fortran Compiler XE for applications running on IA-32, Version 15.0.5.223 Build 20150805
Copyright (C) 1985-2015 Intel Corporation.  All rights reserved.
FOR NON-COMMERCIAL USE ONLY

 Intel(R) Fortran 15.0-1818
ifc_ivdep_test.f90(14): warning #7866: The statement following this DEC loop optimization directive must be an iterative do-stmt, a vector assignment, an OMP do-directive or a parallel-do-directive, or an OMP simd-directive or a do-simd-directive.
!dir$ ivdep
------^

I am contemplating the restrictions I read from this warning.  The rank-1 array expression in sub1 appears fine.  Is there a reason to reject the rank-2 expression in sub2?  Assuming that only the innermost implicit loop is eligible for vectorization, it would be natural to assume the directive to apply to that loop.

Just wondering,

Harald

 

0 Kudos
2 Replies
TimP
Honored Contributor III
513 Views

IVDEP shouldn't make any difference to those array assignments, unless you have set -assume dummy_aliases.

0 Kudos
Harald
Beginner
513 Views

I probably simplified too much from the original intention that I had, and forgot the aliasing rules of Fortran.

In my original idea I had derived types with pointer components in mind, which were used in the expression (lhs and rhs).  The purpose of the directive was to assert the compiler that no dependencies exist.  Apparently I was either confused or too pessimistic...

Good to know about the "-assume dummy_aliases" option.  Will probably never want to use it.  :-)

 

0 Kudos
Reply