Summing across coarrays

Summing across coarrays

Colleagues:I'm upgrading some legacy engineering code to take advantage of Coarray Fortran. In the routine I've started with there is only one coarray. It executes correctly with eight images and generates the same values as before. I can see the basic speedup in all the work done until, at the very end, I need to sum across the coarray that each image has contributed to. The array is ~ 3000 x 400, with 8 images. The basic work in each image that manipulates the local copy of this array is done in < 1 sec. But the summation performed at the very end of the code (in only the 1st image) takes 10 seconds. sync allif( this_image() == 1 ) then do I = 2,num_images() flux = flux + flux[I] end doend ifIs coarray summing that inefficient? But I reserved the right to be doing this improperly! It is actually faster (by an order of magnitude) to have each image write out the local copy of the array, and have the 1st image read the files into local array(s) and perform the sum.Any suggestions? 

6 posts / 0 new
Last post
For more complete information about compiler optimizations, see our Optimization Notice.

David,

It's Jim by the way.

Untested code

i=2
do while(i .lt. num_images())
sync all
if(mod(ImageNum-1,i) .eq. 0) then
array = array + array[i]
endif
i = i * 2
end do

The idea is to double a stride each iteration with the summation performed by fewer and fewer images.

If you only have 2-8 systems then write it inline without the mod test as this will be clearer to the casual reader of the code.

Jim Dempsey

Even better. Thanks.(I guess I was thinking about the prize fighter!)D

When your code is working, please report the runtimes (before and after). This may help others decide the value of the efforts to finish up respectibly.

Jim Dempsey

David,

The last untested code is in error. I think the first while test should be .LE. not .LT.
Sorry about the error. I am slipping (two programming errors this week).

Jim

Leave a Comment

Please sign in to add a comment. Not a member? Join today