gomp_fatal ("Cannot find reverse-offload function");
void (*host_fn)() = (void (*)()) n->k->host_start;
- if (devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
+ if ((devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) || mapnum == 0)
{
devaddrs = (uint64_t *) (uintptr_t) devaddrs_ptr;
sizes = (uint64_t *) (uintptr_t) sizes_ptr;
}
}
- if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM))
+ if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) && mapnum > 0)
{
size_t j, struct_cpy = 0;
splay_tree_key n2;
host_fn (devaddrs);
- if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM))
+ if (!(devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM) && mapnum > 0)
{
uint64_t struct_cpy = 0;
bool clean_struct = false;
clean_struct = true;
struct_cpy = sizes[i];
}
- else if (cdata[i].aligned)
+ else if (!cdata[i].present && cdata[i].aligned)
gomp_aligned_free ((void *) (uintptr_t) devaddrs[i]);
else if (!cdata[i].present)
free ((void *) (uintptr_t) devaddrs[i]);
--- /dev/null
+!
+! Ensure that a mapping with no argument works
+!
+
+module m
+ implicit none (type, external)
+ integer :: x = 32
+ integer :: dev_num2 = -1
+contains
+subroutine foo()
+ use omp_lib, only: omp_get_device_num
+ x = x + 10
+ dev_num2 = omp_get_device_num()
+end
+end module m
+
+use m
+use omp_lib
+!$omp requires reverse_offload
+implicit none (type, external)
+integer :: dev_num = -1
+!$omp target map(from:dev_num)
+ dev_num = omp_get_device_num()
+ ! This calls GOMP_target_ext with number of maps = 0
+ !$omp target device(ancestor:1)
+ call foo
+ !$omp end target
+!$omp end target
+
+if (omp_get_num_devices() > 0 .and. dev_num2 == dev_num) stop 1
+if (x /= 42) stop 2
+end