aboutsummaryrefslogtreecommitdiff
path: root/libgomp/testsuite/libgomp.fortran/target-memcpy-async-1.f90
blob: 4679fd2b94a6b2567742467b179cdad947e4f1b6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
! Test for omp_target_memcpy_async without considering dependence objects.

program main
  use omp_lib
  use iso_c_binding
  implicit none (external, type)
  integer :: d, id, i, j
  integer, target :: q(0:127), q2(0:127)
  type(c_ptr) :: p
  integer(omp_depend_kind) :: obj(1:0)

  d = omp_get_default_device ()
  id = omp_get_initial_device ()

  if (d < 0 .or. d >= omp_get_num_devices ()) &
    d = id

  p = omp_target_alloc (130 * c_sizeof (q), d)
  if (.not. c_associated (p)) &
    stop 0  ! okay

  q = [(i, i = 0, 127)]
  if (omp_target_memcpy_async (p, c_loc (q), 128 * sizeof (q(0)), 0_c_size_t, &
      0_c_size_t, d, id, 0, obj) /= 0) &
    stop 1

  !$omp taskwait

  q2 = [(0, i = 0, 127)]
  if (omp_target_memcpy_async (c_loc (q2), p, 128 * sizeof (q2(0)), 0_c_size_t,&
      0_c_size_t, id, d, 0, obj) /= 0) &
    stop 2

  !$omp taskwait

  do j = 0, 127
    if (q(j) /= q2(j)) &
      stop 3
  end do

  call omp_target_free (p, d)
end program main