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

Program with simple coarrays hangs

Arjen_Markus
Honored Contributor II
2,071 Views
Hello,

in my quest to find a solution for the problem I posted in the thread "Internal compiler error with lock/unlock", I stumbled upon another problem. Again using Intel Fortran 12.0.3.

Here is the program:

! checkscalar.f90 --

! Check some odd (erroneous) behaviour with scalar coarrays

!

program checkscalar

implicit none

logical, codimension

  • :: new_results
  • logical, codimension

  • :: ready
  • ready = .false.

    new_results = .true. ! Indicates the image has results available

    write(*,*) 'Image', this_image(), new_results

    sync all

    write(*,*) 'Image2', this_image(), new_results

    !

    ! Collect the found primes in image 1, create new tasks

    ! for all images

    !

    do while ( .not. ready )

    if ( this_image() == 1 ) then

    call collect_results

    endif

    call sleepqq(1)

    enddo

    contains

    !

    ! Subroutine to collect the results from all

    ! images (run by image 1)

    !

    subroutine collect_results

    integer :: i

    integer :: np

    integer :: maxindex

    do i = 1,num_images()

    write(*,*) 'Examine', i, new_results

    enddo

    do i = 1,num_images()

    ready = .true.

    enddo

    end subroutine collect_results

    end program checkscalar


    It does not do much: in image 1 I print the value of new_results and when the
    loop is finished I set the flag ready in all images so that they will stop. At least
    that is my intention.

    The output of one run with this program is:

    Image 6 T

    Image 1 T

    Image 3 T

    Image2 3 T

    Image 7 T

    Image2 7 T

    Image2 6 T

    Image 5 T

    Image 2 T

    Image2 2 T

    Image 4 T

    Image 8 T

    Image2 4 T

    Image2 1 T

    Examine 1 T

    Image2 8 T

    Image2 5 T

    (after a few seconds of no progress at all, I stopped the program)

    So, all 8 images start, image 1 is entering the loop, prints the value of new_results on that
    image, and then hangs - it does not get beyond this!

    Does anyone have any clues? Am I doing something wrong? (Possible, of course, but the
    program is so simple that I can not believe that.)

    Regards,

    Arjen

    0 Kudos
    25 Replies
    Steven_L_Intel1
    Employee
    324 Views
    It is not that sync all is broken, but for some reason a refernece to the local variable isn't getting the updated value. Issue ID is DPD200168369.

    0 Kudos
    jimdempseyatthecove
    Honored Contributor III
    324 Views
    It is not that sync all is broken, but for some reason a refernece to the local variable isn't getting the updated value. Issue ID is DPD200168369.

    ?? isn't that the purpose of sync all ??
    Jim

    0 Kudos
    Steven_L_Intel1
    Employee
    324 Views
    Well, no - it is also a barrier to continued execution until all images reach that point.
    0 Kudos
    jimdempseyatthecove
    Honored Contributor III
    324 Views
    (toung in cheek)

    Then it appears that one should always use YourCoArrayVariable[yourImageNumber] instead of YourCoArrayVariable whenever some other image could write to YourCoArrayVariable (because sync all, although reportedly not broken, does not update local image of YourCoArrayVariable).

    (toung back where it belongs)

    There may be a race condition in an optimization whereby you omit poling other processes if you "know" no updates to your shared variable(s) were made. (error in code relating to condition variables on Linux). Might be a place to look after you get a reproducer.

    Jim Dempsey
    0 Kudos
    Steven_L_Intel1
    Employee
    324 Views
    The problem in the initial post got fixed somewhere along the way - it works now in the current compiler, Composer XE 2011 Update 11.
    0 Kudos
    Reply