PSyclone
PSyclone copied to clipboard
[fparser2 frontend] Unbounded loops not correctly reproduced
Simon has reported:
"Apparently unbounded loops with a nested inner loop are incorrectly reproduced: the nested loops of
PROGRAM x
INTEGER :: y
DO
DO y=1,2
END DO
END DO
END PROGRAM x
are currently transformed into two nested loops with identical loop variables and parameters."
I would have expected the unbounded loop to result in a CodeBlock so I'm not sure what's going wrong here.
Victoria has also hit a related problem in NEMOVAR where there are similar unbound loops that then contain loops that we want to parallelise:
CBV_loop : DO
CALL soladj_cbv_main( &
& piom_ctl, &
& p_dif%fsol%fcbv, &
& p_dif%fsol%fcbv%cb_b, &
& p_dif%fsol%fcbv%cb_x, &
& i_nsolitmax, &
& p_dif%fsol%nsolit_k, &
& i_flag_rc, &
& z_arginp, &
& z_argout, &
& ld_gpu=ll_gpu_override )
SELECT CASE( i_flag_rc )
CASE ( jp_cbv_A_x0, jp_cbv_A_p )
! Point to output vector
CALL pointval_ctlvec( &
& piom_ctl, &
& p_dif%fgrid%fmpp, &
& 1, &
& z_ptr2, &
& z_argout )
!$ACC ENTER DATA IF(ll_transfer) ATTACH ( z_ptr2 )
! Retrieve input from the control vector
IF ( .NOT. ASSOCIATED( z_argout, z_arginp ) ) THEN
CALL getval_ctlvec( &
& piom_ctl, &
& p_dif%fgrid%fmpp, &
& 1, &
& z_ptr2(:,:,:), &
& z_arginp, &
& ld_gpu=ll_gpu_override )
END IF
IF ( p_dif%fsol%ldiaprc ) THEN
! Multiply by the square root of the diagonal preconditioner
IF(ll_gpu) THEN
!$ACC KERNELS
!$ACC LOOP COLLAPSE(3) GANG VECTOR INDEPENDENT
DO jk=1,p_dif%npk
DO jj=1,p_dif%npj
DO ji=1,p_dif%npi
z_ptr2(ji,jj,jk) = z_ptr2(ji,jj,jk) * p_dif%fsol%diaprciijj(ji,jj,jk,i_nbc)
END DO
END DO
END DO
!$ACC END KERNELS
ELSE
z_ptr2(:,:,:) = z_ptr2(:,:,:) * p_dif%fsol%diaprciijj(:,:,:,i_nbc)
END IF
END IF
...
END DO CBV_loop
Currently this whole loop is (correctly) put into a CodeBlock but obviously that prevents transformation of the loops nested within it.