omp_target_is_accessible (GNU libgomp)

#### 3.7.4 `omp_target_is_accessible` – Check whether memory is device accessible ¶

Description:

  This routine tests whether memory, starting at the address given by ptr and extending size bytes, is accessibly on the device specified by device_num. If so, it returns a nonzero value and otherwise zero.

  The address given by ptr is interpreted to be in the address space of the device and size must be positive. NULL pointers and zero-length ranges always return zero.

  Note that GCC’s current implementation assumes that ptr is a valid host pointer. Therefore, all non-NULL addresses given by ptr are assumed to be accessible on the initial device. The address is only reported as accessible on non-host devices if this is known to be the case, or if the device reports that all memory is accessible (i.e. [unified] shared memory access). If the runtime is uncertain it may report accessible memory as inaccessible. For a memory range to be reported accessible, the whole range must be known to be accessible.

  Running this routine in a `target` region except on the initial device is not supported.

C/C++

  Prototype: | `int omp_target_is_accessible(const void *ptr,`
  | `size_t size,`
  | `int device_num)`

Fortran:

  Interface: | `integer(c_int) function omp_target_is_accessible(ptr, &`
  | `size, device_num) bind(C)`
  | `use, intrinsic :: iso_c_binding, only: c_ptr, c_size_t, c_int`
  | `type(c_ptr), value :: ptr`
  | `integer(c_size_t), value :: size`
  | `integer(c_int), value :: device_num`

See also:

  `omp_target_is_present` – Check whether storage is mapped

Reference:

  OpenMP specification v5.1, Section 3.8.4