Intel® Fortran Compiler
Build applications that can scale for the future with optimized code designed for Intel® Xeon® and compatible processors.
Announcements
This community is designed for sharing of public information. Please do not share Intel or third-party confidential information here.

Coarray SYNC ALL issue

OP1
New Contributor I
122 Views

The following code exhibits a different behavior depending on whether line 3 or 4 is commented out. It seems that the SYNC ALL behavior varies depending on which image 'finishes first'.

PROGRAM MAIN
IMPLICIT NONE
IF (THIS_IMAGE()==1) THEN   ! This works.
!IF (THIS_IMAGE()==2) THEN   ! Any image number > 1 causes the code to hang at the SYNC ALL below.
    CALL SLEEP(1)
    WRITE(*,*) 'Image ',THIS_IMAGE(),' is done!'
    GO TO 100
END IF
SYNC ALL
WRITE(*,*) 'Image ',THIS_IMAGE(),' is done!'
100 CONTINUE
END PROGRAM MAIN

 

0 Kudos
3 Replies
Steven_L_Intel1
Employee
122 Views

This program is malformed  - a SYNC ALL waits for all other images to execute a SYNC ALL the same number of times. If you skip over the SYNC ALL and let the program exit, the behavior is unspecified. What probably happens in the case image 1 skips it is that this image is "special" and it exiting causes all other images to exit.

OP1
New Contributor I
122 Views

Thanks Steve for the clarification. I think I got confused with the fact that when an image stops, its coarrays are still accessible (see code below). I thought that therefore a stopped image would not be considered in a SYNC ALL statement (only the images still running would wait for each other).

PROGRAM MAIN
IMPLICIT NONE
INTEGER :: I,J
  • IF (THIS_IMAGE()==1) THEN CALL SLEEP(1) DO I=1,NUM_IMAGES() J = I END DO SYNC MEMORY DO I=1,NUM_IMAGES() WRITE(*,*) J END DO END IF WRITE(*,*) 'Image ',THIS_IMAGE(),' is done!' END PROGRAM MAIN
  •  

    Steven_L_Intel1
    Employee
    122 Views

    Fortran 2008 doesn't take into account stopped or failed images - this is something being added for Fortran 2015. In F2015, if there are stopped or failed images in the current team (another F2015 thing), a SYNC ALL without a STAT= is an error and will cause termination.

    In Fortran 2008, it is assumed that all images are still active.

    Reply