From: Paul-Antoine Arras Date: Mon, 13 Jan 2025 11:57:15 +0000 (+0100) Subject: Add missing target directive in OpenMP dispatch Fortran runtime test X-Git-Tag: basepoints/gcc-16~2684 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=655a8a024dd49ddf73e745f3c7486596d68ae3e8;p=thirdparty%2Fgcc.git Add missing target directive in OpenMP dispatch Fortran runtime test Without the target directive, the test would run on the host but still try to use device pointers, which causes a segfault. libgomp/ChangeLog: * testsuite/libgomp.fortran/dispatch-1.f90: Add missing target directive. --- diff --git a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 index 7b2f03f9d687..f56477e49722 100644 --- a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 +++ b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 @@ -48,16 +48,21 @@ module procedures integer :: res, n, i type(c_ptr) :: d_bv type(c_ptr) :: d_av - real(8), pointer :: fp_bv(:), fp_av(:) ! Fortran pointers for array access - ! Associate C pointers with Fortran pointers - call c_f_pointer(d_bv, fp_bv, [n]) - call c_f_pointer(d_av, fp_av, [n]) + !$omp target is_device_ptr(d_bv, d_av) + block + real(8), pointer :: fp_bv(:), fp_av(:) ! Fortran pointers for array access + + ! Associate C pointers with Fortran pointers + call c_f_pointer(d_bv, fp_bv, [n]) + call c_f_pointer(d_av, fp_av, [n]) + + ! Perform operations on target + do i = 1, n + fp_bv(i) = fp_av(i) * i + end do + end block - ! Perform operations on target - do i = 1, n - fp_bv(i) = fp_av(i) * i - end do res = -2 end function bar