return 0;
}
+int
+omp_get_initial_device (void)
+{
+ return GOMP_DEVICE_HOST_FALLBACK;
+}
+
int
omp_get_num_devices (void)
{
ialias (omp_set_default_device)
ialias (omp_get_default_device)
+ialias (omp_get_initial_device)
ialias (omp_get_num_devices)
ialias (omp_get_num_teams)
ialias (omp_get_team_num)
return 0;
}
+int
+omp_get_initial_device (void)
+{
+ return GOMP_DEVICE_HOST_FALLBACK;
+}
+
int
omp_get_num_devices (void)
{
ialias (omp_set_default_device)
ialias (omp_get_default_device)
+ialias (omp_get_initial_device)
ialias (omp_get_num_devices)
ialias (omp_is_initial_device)
return icv->default_device_var;
}
+int
+omp_get_initial_device (void)
+{
+ return gomp_get_num_devices ();
+}
+
int
omp_get_num_devices (void)
{
ialias (omp_set_default_device)
ialias (omp_get_default_device)
+ialias (omp_get_initial_device)
ialias (omp_get_num_devices)
ialias (omp_is_initial_device)
return icv->bind_var;
}
-int
-omp_get_initial_device (void)
-{
- return GOMP_DEVICE_HOST_FALLBACK;
-}
-
int
omp_get_num_places (void)
{
ialias (omp_get_supported_active_levels)
ialias (omp_get_cancellation)
ialias (omp_get_proc_bind)
-ialias (omp_get_initial_device)
ialias (omp_get_max_task_priority)
ialias (omp_get_num_places)
ialias (omp_get_place_num)
* omp_get_cancellation:: Whether cancellation support is enabled
* omp_get_default_device:: Get the default device for target regions
* omp_get_dynamic:: Dynamic teams setting
+* omp_get_initial_device:: Device number of host device
* omp_get_level:: Number of parallel regions
* omp_get_max_active_levels:: Current maximum number of active regions
* omp_get_max_task_priority:: Maximum task priority value that can be set
+@node omp_get_initial_device
+@section @code{omp_get_initial_device} -- Return device number of initial device
+@table @asis
+@item @emph{Description}:
+This function returns a device number that represents the host device.
+For OpenMP 5.1, this must be equal to the value returned by the
+@code{omp_get_num_devices} function.
+
+@item @emph{C/C++}
+@multitable @columnfractions .20 .80
+@item @emph{Prototype}: @tab @code{int omp_get_initial_device(void);}
+@end multitable
+
+@item @emph{Fortran}:
+@multitable @columnfractions .20 .80
+@item @emph{Interface}: @tab @code{integer function omp_get_initial_device()}
+@end multitable
+
+@item @emph{See also}:
+@ref{omp_get_num_devices}
+
+@item @emph{Reference}:
+@uref{https://www.openmp.org, OpenMP specification v4.5}, Section 3.2.35.
+@end table
+
+
+
@node omp_get_level
@section @code{omp_get_level} -- Obtain the current nesting level
@table @asis
if (device_id < 0 || device_id >= gomp_get_num_devices ())
{
if (gomp_target_offload_var == GOMP_TARGET_OFFLOAD_MANDATORY
- && device_id != GOMP_DEVICE_HOST_FALLBACK)
+ && device_id != GOMP_DEVICE_HOST_FALLBACK
+ && device_id != num_devices_openmp)
gomp_fatal ("OMP_TARGET_OFFLOAD is set to MANDATORY, "
"but device not found");
{
gomp_mutex_unlock (&devices[device_id].lock);
- if (gomp_target_offload_var == GOMP_TARGET_OFFLOAD_MANDATORY
- && device_id != GOMP_DEVICE_HOST_FALLBACK)
+ if (gomp_target_offload_var == GOMP_TARGET_OFFLOAD_MANDATORY)
gomp_fatal ("OMP_TARGET_OFFLOAD is set to MANDATORY, "
"but device is finalized");
void *
omp_target_alloc (size_t size, int device_num)
{
- if (device_num == GOMP_DEVICE_HOST_FALLBACK)
+ if (device_num == gomp_get_num_devices ())
return malloc (size);
if (device_num < 0)
if (device_ptr == NULL)
return;
- if (device_num == GOMP_DEVICE_HOST_FALLBACK)
+ if (device_num == gomp_get_num_devices ())
{
free (device_ptr);
return;
if (ptr == NULL)
return 1;
- if (device_num == GOMP_DEVICE_HOST_FALLBACK)
+ if (device_num == gomp_get_num_devices ())
return 1;
if (device_num < 0)
struct gomp_device_descr *dst_devicep = NULL, *src_devicep = NULL;
bool ret;
- if (dst_device_num != GOMP_DEVICE_HOST_FALLBACK)
+ if (dst_device_num != gomp_get_num_devices ())
{
if (dst_device_num < 0)
return EINVAL;
|| dst_devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
dst_devicep = NULL;
}
- if (src_device_num != GOMP_DEVICE_HOST_FALLBACK)
+ if (src_device_num != num_devices_openmp)
{
if (src_device_num < 0)
return EINVAL;
if (!dst && !src)
return INT_MAX;
- if (dst_device_num != GOMP_DEVICE_HOST_FALLBACK)
+ if (dst_device_num != gomp_get_num_devices ())
{
if (dst_device_num < 0)
return EINVAL;
|| dst_devicep->capabilities & GOMP_OFFLOAD_CAP_SHARED_MEM)
dst_devicep = NULL;
}
- if (src_device_num != GOMP_DEVICE_HOST_FALLBACK)
+ if (src_device_num != num_devices_openmp)
{
if (src_device_num < 0)
return EINVAL;
omp_target_associate_ptr (const void *host_ptr, const void *device_ptr,
size_t size, size_t device_offset, int device_num)
{
- if (device_num == GOMP_DEVICE_HOST_FALLBACK)
+ if (device_num == gomp_get_num_devices ())
return EINVAL;
if (device_num < 0)
int
omp_target_disassociate_ptr (const void *ptr, int device_num)
{
- if (device_num == GOMP_DEVICE_HOST_FALLBACK)
+ if (device_num == gomp_get_num_devices ())
return EINVAL;
if (device_num < 0)
omp_pause_resource (omp_pause_resource_t kind, int device_num)
{
(void) kind;
- if (device_num == GOMP_DEVICE_HOST_FALLBACK)
+ if (device_num == gomp_get_num_devices ())
return gomp_pause_host ();
- if (device_num < 0 || device_num >= gomp_get_num_devices ())
+ if (device_num < 0 || device_num >= num_devices_openmp)
return -1;
/* Do nothing for target devices for now. */
return 0;
--- /dev/null
+#include <omp.h>
+#include <stdlib.h>
+
+int
+main ()
+{
+ if (omp_get_initial_device () != omp_get_num_devices ())
+ abort ();
+ return 0;
+}