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.

Forall and Do Concurrent

psantos
Beginner
2,261 Views
Hello to everyone!

Yesterday I was looking at the new F2008 standards and I noticed a new type of loop, the DO CONCURRENT. I discovered it is now implemented in Fortran Composer XE 2011. I red its description and I think it is very similar (perhaps equal) to the forall statement. Is this new statement replacing the forall? Or there are some differences between these statements? Thank you very much for all the answers.
0 Kudos
7 Replies
Steven_L_Intel1
Employee
2,261 Views
Yes, DO CONCURRENT is "FORALL done right". The problem with FORALL was its semantics as a series of array assignments that had to be executed one after the other. Many people thought of FORALL as a "parallel DO", which it was not, and it was difficult to parallelize effectively. DO CONCURRENT is much simpler and specifies that each "instance" of the DO body can be executed in any order. The Intel compiler will try to parallelize DO CONCURRENT when /parallel is specified.
0 Kudos
psantos
Beginner
2,261 Views
Steve, thank you very much for your quick answer. I must admit that I'm a little shocked because I always admitted that the compiler could easily parallelize the forall statement, since it also specifies that each iteration of the loop could be executed in any order. Personally, I thought that the forall statement was created precisely to allow an easy parallelization of the code. One more question, if inside the DO CONCURRENT exists more than one code statement, they are serially executed, like in the forall? Thank you.

Pedro
0 Kudos
Steven_L_Intel1
Employee
2,261 Views
The statements within the DO CONCURRENT are executed in order, in each "iteration", but there is no dependence on other iterations. FORALL could have array assignments only, but each assignment needed to be completed by all iterations before the next one executed, effectively creating a "wait for all" after each assignment. Yes, the idea of FORALL was to help with parallelization, but like a lot of High-Performance Fortran, the obsolete variant from which FORALL comes, it was not well thought through and parallelization was much more difficult than it seemed it would.
0 Kudos
psantos
Beginner
2,261 Views
Thank you Steve. Now I really understand the differences between the forall and the do concurrent. I must admit that I am surprised with your "revelations". I have one side question to make: when will be implemented the block construct? It's one of the F2008 features that I find very useful. Thank again for your help.
0 Kudos
Steven_L_Intel1
Employee
2,261 Views
I can't tell you at this time when BLOCK will appear in our compiler.
0 Kudos
psantos
Beginner
2,261 Views
Ok. I will keep an eye on Intel Fortran releases. I understand that implement all the 2008 features will take some time. Tank you very much for your help.
0 Kudos
TimP
Honored Contributor III
2,261 Views
I just noticed that DO CONCURRENT accepts the !DIR$ VECTOR ..... directives where FORALL did not.
gfortran 4.7 (getting close to release) supports DO CONCURRENT.
0 Kudos
Reply