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

OpenMP loop directives on implied loops

ereisch
New Contributor II
761 Views

I'm not sure if the verbiage on my title is correct, but is there a way to use !$OMP SIMD on "implied" loops in Fortran?  By implied, I mean:

REAL*4   ZED(512), DEL(512), GAIN
[...]
!$OMP SIMD
ZED = DEL * GAIN

In this case, I receive a compile error that the statement on line 4 is not correct following the given OpenMP directive.  However, if I deconstruct it into an explicit DO loop, it is considered acceptable.

 

Doing the deconstruction seems simple enough, but when you have a more complicated vector assignment, the one-liner doesn't always break down as cleanly as above (over-simplified example):

REAL*4    ZED(START:STOP), DEL(1:NPTS), GAIN
[...]
ZED(START:STOP) = DEL(1:NPTS) * GAIN

 P.S. -- What's the "correct" term for this instruction?  "Implied" DO loop?  "Implicit" DO loop?  Vector loop?

0 Kudos
4 Replies
jimdempseyatthecove
Honored Contributor III
753 Views

If you look at the Release build disassembly (either VTune or Debugger) and see that you are not getting SIMD instructions (...ps), then you can try using the Intel Fortran directives

!dir $ vector

or

!dir$ vector always

 

Pay attention to the caution.  Test with and without directives, and test again when you force unalignment of arrays.

IOW you want to assure that the forcing of vectorization does not generate a GP fault (from using aligned load/store on unaligned data). Note, the newer CPU's (current), have little to no overhead in using unaligned load/store verses aligned load/store. As such, code generated targeted to newer CPUs will use unaligned load/store instructions (even when alignment is known to be aligned). Older CPU's had substantial overhead when using unaligned load/store on data known to be aligned verses using aligned load/store.

 

In particular, testing on a new CPU, using its instruction set (/QxHost) is no assurance that you will not experience problems with running on an older CPU using (/QxAVX). 

 

Jim Dempsey

0 Kudos
Barbara_P_Intel
Employee
672 Views

My resident Fortran expert calls your use an "array assignment". 

Sorry, no OpenMP SIMD directives on array assignments, regardless if they are whole array assignments or involve array sections. It is only allowed on explicit DO loops.

 

0 Kudos
JohnNichols
Valued Contributor III
659 Views

@Barbara_P_Intel , your comment on the My resident Fortran expert bought a smile, it is a classic statement, as you and Jim and the others are my resident Fortran expert.  

In the 1979s and 1980s, as computer technology started to impact the industrial world, a lot of the big management firms made a lot of money essentially telling people to - buy computers, sack the typing pool and etc....  I once was interviewed as a customer, by experts from Sydney Energy, on how to improve Shortland Energy that they had just taken over.  I got short shrift when I said Shortland was small and highly efficient and Sydney was not and I hoped they did not ruin it, as they did. 

I read one famous story about the IBM Lab -- Watson??, had a review, the people went through and had all the facts, and then sat down with the manager and said, we understand how it all works except for this guy in the corner office, he never seems to be to busy. 

The story as I remember it is the manager said when our people cannot solve a problem, he solves it and saves us a lot of money each year, leave him alone.  

99% of the grunt work is done by average humans, 100% of the really good essential steps forward is done by a small group, say 10%. The 90% average do not really understand the 10%, which is why the NET has allowed those people to congregate, like a small Methodist Church in England in the 1600s.  

This is a safe church.  

 

0 Kudos
Reply