Tuesday, 15 September 2015

Fortran performance when passing array slices as arguments -


I would like to point out the formulation of the FORTRON-slicing notation ( array (1: n) ) , But I wonder if I take a performance hit if I use them when it is not necessary.

For example, this simple sequential code (this works, but obviously it does not take care to choose a good axis):

  Recurring sub-templates quick-abstract (array, shape) real, dimension (:), intent (interval) :: array integer, intent (in) then p = partition ( Array, Size, 1) Call Quartort (array (1: P-1), P-1) Call QuickSource (array (P + 1: size), Size-P) End if end subset RinQuestost function segmentation (array, shape, pivotdex) result (P) real, dimension (:), intent: Inline :: array integer, intent (in) :: size, PowoteDex actual :: Smoke integer :: I Pivotdex call swap (array (pivotdex), array (size)) p = 1 do i = 1, size-1 if (array (i) & lt; pivot) th end call slap (array (p) , Array (size)) end function division subroutine swap (A, B) real, intention (call) swap (array (i), array (p)) p = p + 1 end in outline) :: A, B is the real :: temp Temp = aa = bb = temp end subroutine  

I can simply pass the whole array with the index of where recursive parts work But I like the code like this when I call quicksort (array (1: p-1), p-1) , even if it operates a temporary array Does it, or does it just have a shallow reference structure or something like that? Is this a sufficiently efficient solution?

It is related, but it seems that it creates temporary arrays due to triped slices and clear-shaped dummy variables, so I'm safe with that, right?

your subarray

  array (1: p-1)  

is narrow, provided the array is narrow.

In addition, you use an approximate size array dummy argument

  real, dimension (:), intent (interval) :: array  / Pre> 

No need for temporary. Just a descriptor of an approximate size array has been passed. And as you all are narrow, even with an eclipse shape or dummy logic of a clear size or size it will be cured with the closest attribute.


No comments:

Post a Comment