Block construct and sync all behavior

Anton Shterenlikht mexas@bris.ac.uk
Tue Oct 21 08:35:00 GMT 2014


>The program and output below seem to show that the
> "sync all<94> is not serving as a barrier.
>  I would have expected that b oth <93>Now image<85><94>
> lines would appear at the end of the output.
>  If however, I uncomment the shown <93>block<94>
> and <93>end block<94>, I get the behavior I expected.
>  Is this behavior correct?  Does it relate in some way to buffering?  
>
>FYI, I<92>m using GNU Fortran (GCC) 5.0.0 20140917 (experimental).
>
>Damian
>
>$ cat print-order.f90 
>  implicit none
>  integer :: i
> !block
>  do i=1,10
>    print *,"Image",this_image(),"is on loop iteration",i
>  end do
>  sync all
> !end block
>  print *,"Now image",this_image(),"is done looping.<94>
>end
>
>

The FDIS draft says:

*quote*
NOTE 9.15
Even though OUTPUT_UNIT is connected to a separate file
on each image, it is expected that the processor could
merge the sequences of records from these files into a
single sequence of records that is sent to the physical
device associated with this unit, such as the user's terminal.
*end quote*

The order is unpredictable.

MFE add, p. 349:

*quote*
If the order of writes from images is important,
synchronization and the flush statement are
required, since the image is permitted to hold
the data in a buffer and delay the transfers
until either it executes a flush statement for
the file of the file is closed.
*end quote*

I agree with Tobias that BLOCK constuct is
irrelevant here.

With ifort 15 I get the statements printed
in the order you prefer with BLOCK commented out,
as in your original example:

newblue2> cat z.f90 
  implicit none
  integer :: i
 !block
  do i=1,10
    print *,"Image",this_image(),"is on loop iteration",i
  end do
  sync all
 !end block
  print *,"Now image",this_image(),"is done looping"
end
newblue2> ifort -coarray z.f90
newblue2> setenv FOR_COARRAY_NUM_IMAGES 2
newblue2> ./a.out
 Image           2 is on loop iteration           1
 Image           2 is on loop iteration           2
 Image           2 is on loop iteration           3
 Image           2 is on loop iteration           4
 Image           1 is on loop iteration           1
 Image           1 is on loop iteration           2
 Image           1 is on loop iteration           3
 Image           1 is on loop iteration           4
 Image           1 is on loop iteration           5
 Image           1 is on loop iteration           6
 Image           1 is on loop iteration           7
 Image           1 is on loop iteration           8
 Image           1 is on loop iteration           9
 Image           2 is on loop iteration           5
 Image           2 is on loop iteration           6
 Image           2 is on loop iteration           7
 Image           2 is on loop iteration           8
 Image           2 is on loop iteration           9
 Image           2 is on loop iteration          10
 Image           1 is on loop iteration          10
 Now image           1 is done looping
 Now image           2 is done looping
newblue2> 

Anton



More information about the Fortran mailing list