]> git.ipfire.org Git - thirdparty/gcc.git/commitdiff
Add missing target directive in OpenMP dispatch Fortran runtime test
authorPaul-Antoine Arras <parras@baylibre.com>
Mon, 13 Jan 2025 11:57:15 +0000 (12:57 +0100)
committerPaul-Antoine Arras <parras@baylibre.com>
Mon, 13 Jan 2025 15:05:14 +0000 (16:05 +0100)
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.

libgomp/testsuite/libgomp.fortran/dispatch-1.f90

index 7b2f03f9d687dbbea88d60fabd44b511eed6006a..f56477e49722607fe7181b72e621e02e7679e820 100644 (file)
@@ -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