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

ifort 2021.4.0 runtime failure using SYNC MEMORY in a coarray team

Michael_S_17
Novice
277 Views

The code example shows a subtle bug (at runtime) using SYNC MEMORY following an ALLOCATE statement (allocating a coarray component) in a coarray team (with a specific setup). The runtime failure does only occur with the specific setup of this code example.

! ifort runtime failure using SYNC MEMORY within a coarray team (subtle bug)

! ifort version 2021.4.0
! ifort -coarray -coarray-num-images=15 test.f90 -o a.out

! runtime output:
! nothing to do in team number           1
! nothing to do in team number           1
! nothing to do in team number           1
! nothing to do in team number           1
! nothing to do in team number           1
! nothing to do in team number           1
! nothing to do in team number           1

! Failure: there is no output from coarray team 2, the SYNC MEMORY statement does
!          suspend further execution in coarray team 2.



module a
use, intrinsic :: ISO_FORTRAN_ENV, only: team_type
implicit none
private

type, public :: a_type
  private
  integer, codimension[:], allocatable :: coarray_component
contains
  private
  procedure, public :: routine => a_routine
end type a_type

type (team_type), public :: a_team

contains

subroutine a_routine (this)
  class (a_type), intent (inout) :: this
  integer :: NumberOfTeams
  integer :: NumberOfImagesPerTeam
  integer :: TeamNumber

  NumberOfTeams = 2
  NumberOfImagesPerTeam = num_images() / NumberOfTeams
  if (this_image() <= NumberOfImagesPerTeam) then
    TeamNumber = 1
  else
    TeamNumber = 2
  end if

  form team (TeamNumber, a_team)
  change team (a_team)
    select case (team_number())
    ! the select case composition here is required to raise the sync memory failure below:
    case (2) ! must be case (2) for the sync memory failure to occur
      allocate (this % coarray_component [*]) ! allocate is also required for the sync memory failure to occur
      if (this_image() == 1) then
        sync memory ! this does fail/suspend execution with ifort
      else
        sync memory ! this does fail/suspend execution with ifort
      end if
      write(*,*)' no failure on image', this_image(), 'in team', team_number() ! this WRITE statement does not occur
    case (1)
      write(*,*) 'nothing to do in team number', team_number()
    end select
  end team

end subroutine a_routine
end module a

program Main
  use a
  implicit none
  type(a_type) :: test_object
  call test_object % routine
end program Main

 

0 Kudos
1 Reply
Michael_S_17
Novice
229 Views

Update:

The reason behind this failure must be the ALLOCATE statement. The test case here was derived from a working blocking queue and channel implementation using OpenCoarrays/gfortran. I just got it to run with ifort after allocating the coarray components above the team levels so that the coarray components are allocated for all teams.

Therefore the correct title of this issue should be : 'ifort 2021.4.0 failure allocating coarray components at the level of coarray teams'

 

Reply