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

assignment efficiency

lklawrie
Beginner
627 Views

Is it more efficient to assign via a Do loop:

do i=1,n

x(i)=someotherarray(i,1)

enddo

or

x(1:n)=someotherarray(1:n,1)

or does it matter?

Linda

0 Kudos
4 Replies
TimP
Honored Contributor III
627 Views
For a rank 1 assignment, it's not likely to make a difference.
0 Kudos
abhimodak
New Contributor I
626 Views

Hi Linda

If you are using Win64 and have large arrays you may want to take a quick look at : http://software.intel.com/en-us/forums/showthread.php?t=61077

The last post by Mr. Green indicates that Intel may need do a little bit of further analysis, but based on the response received in Premier Support, I think Intel has pulled the plug on it. (The outer "dead" loop pointed out by Mr. Green is not optimized-out in even in the latest release 11.1.060. But as far as I know this happens only on Win64.)

Also I recall that Steve Lionel had mentioned somewhere to use the whole array syntax instead of specifying the complete partition, if it is possible i.e. avoid A(1:N) = B(1:N) and use A = B if the array size is N. (I interprete this as compiler may think it has to do something extra when the partition is mentioned.)

Abhi

0 Kudos
abhimodak
New Contributor I
626 Views

Hi Tim

Does this mean for rank n with n>1 would have a bigger impact? Can you please illustrate this point with an example? It may be super-elementary but I think it is worth to "put it on the cap"; your advice deeply appreciated.

Sincerely

Abhi

0 Kudos
Steven_L_Intel1
Employee
627 Views
Is n the upper bound of array x? If so, then remove the (1:n).
0 Kudos
Reply