diff options
author | Paul-Antoine Arras <parras@baylibre.com> | 2025-01-13 12:57:15 +0100 |
---|---|---|
committer | Paul-Antoine Arras <parras@baylibre.com> | 2025-01-13 16:05:14 +0100 |
commit | 655a8a024dd49ddf73e745f3c7486596d68ae3e8 (patch) | |
tree | cd2d8b03ca226b9abd313b51d6b26bd770643424 | |
parent | 7cd4de65ffb3f34d6ba5af2f9570900fecd7bed0 (diff) | |
download | gcc-655a8a024dd49ddf73e745f3c7486596d68ae3e8.zip gcc-655a8a024dd49ddf73e745f3c7486596d68ae3e8.tar.gz gcc-655a8a024dd49ddf73e745f3c7486596d68ae3e8.tar.bz2 |
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.
-rw-r--r-- | libgomp/testsuite/libgomp.fortran/dispatch-1.f90 | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 b/libgomp/testsuite/libgomp.fortran/dispatch-1.f90 index 7b2f03f..f56477e 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 |