2021-01-04 10:26:59 +01:00
|
|
|
/* Copyright (C) 2005-2021 Free Software Foundation, Inc.
|
2016-11-23 19:36:41 +01:00
|
|
|
Contributed by Richard Henderson <rth@redhat.com>.
|
|
|
|
|
|
|
|
This file is part of the GNU Offloading and Multi Processing Library
|
|
|
|
(libgomp).
|
|
|
|
|
|
|
|
Libgomp is free software; you can redistribute it and/or modify it
|
|
|
|
under the terms of the GNU General Public License as published by
|
|
|
|
the Free Software Foundation; either version 3, or (at your option)
|
|
|
|
any later version.
|
|
|
|
|
|
|
|
Libgomp is distributed in the hope that it will be useful, but WITHOUT ANY
|
|
|
|
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
|
|
FOR A PARTICULAR PURPOSE. See the GNU General Public License for
|
|
|
|
more details.
|
|
|
|
|
|
|
|
Under Section 7 of GPL version 3, you are granted additional
|
|
|
|
permissions described in the GCC Runtime Library Exception, version
|
|
|
|
3.1, as published by the Free Software Foundation.
|
|
|
|
|
|
|
|
You should have received a copy of the GNU General Public License and
|
|
|
|
a copy of the GCC Runtime Library Exception along with this program;
|
|
|
|
see the files COPYING3 and COPYING.RUNTIME respectively. If not, see
|
|
|
|
<http://www.gnu.org/licenses/>. */
|
|
|
|
|
|
|
|
/* This file defines OpenMP API entry points that accelerator targets are
|
|
|
|
expected to replace. */
|
|
|
|
|
|
|
|
#include "libgomp.h"
|
|
|
|
|
|
|
|
void
|
|
|
|
omp_set_default_device (int device_num)
|
|
|
|
{
|
|
|
|
struct gomp_task_icv *icv = gomp_icv (true);
|
|
|
|
icv->default_device_var = device_num >= 0 ? device_num : 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
omp_get_default_device (void)
|
|
|
|
{
|
|
|
|
struct gomp_task_icv *icv = gomp_icv (false);
|
|
|
|
return icv->default_device_var;
|
|
|
|
}
|
|
|
|
|
openmp: Change omp_get_initial_device () to match OpenMP 5.1 requirements
> Therefore, I think until omp_get_initial_device () value is changed, we
The following so far untested patch implements that change.
OpenMP 4.5 said for omp_get_initial_device:
The value of the device number is implementation defined. If it is between 0 and one less than
omp_get_num_devices() then it is valid for use with all device constructs and routines; if it is
outside that range, then it is only valid for use with the device memory routines and not in the
device clause.
and OpenMP 5.0 similarly, but OpenMP 5.1 says:
The value of the device number is the value returned by the omp_get_num_devices routine.
As the new value is compatible with what has been required earlier, I think
we can change it already now.
2020-10-22 Jakub Jelinek <jakub@redhat.com>
* icv.c (omp_get_initial_device): Remove including corresponding
ialias.
* icv-device.c (omp_get_initial_device): New function. Return
gomp_get_num_devices (). Add ialias.
* target.c (resolve_device): Don't fail with
OMP_TARGET_OFFLOAD=mandatory if device_id is equal to
gomp_get_num_devices ().
(omp_target_alloc, omp_target_free, omp_target_is_present,
omp_target_memcpy, omp_target_memcpy_rect, omp_target_associate_ptr,
omp_target_disassociate_ptr, omp_pause_resource): Use
gomp_get_num_devices () instead of GOMP_DEVICE_HOST_FALLBACK on the
first use in the functions, in uses dominated by the
gomp_get_num_devices call use num_devices_openmp instead.
* libgomp.texi (omp_get_initial_device): Document.
* config/gcn/icv-device.c (omp_get_initial_device): New function.
Add ialias.
* config/nvptx/icv-device.c (omp_get_initial_device): Likewise.
* testsuite/libgomp.c/target-40.c: New test.
2020-10-22 09:31:01 +02:00
|
|
|
int
|
|
|
|
omp_get_initial_device (void)
|
|
|
|
{
|
|
|
|
return gomp_get_num_devices ();
|
|
|
|
}
|
|
|
|
|
2016-11-23 19:36:41 +01:00
|
|
|
int
|
|
|
|
omp_get_num_devices (void)
|
|
|
|
{
|
|
|
|
return gomp_get_num_devices ();
|
|
|
|
}
|
|
|
|
|
|
|
|
int
|
|
|
|
omp_is_initial_device (void)
|
|
|
|
{
|
|
|
|
/* Hardcoded to 1 on host, should be 0 on MIC, HSAIL, PTX. */
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
ialias (omp_set_default_device)
|
|
|
|
ialias (omp_get_default_device)
|
openmp: Change omp_get_initial_device () to match OpenMP 5.1 requirements
> Therefore, I think until omp_get_initial_device () value is changed, we
The following so far untested patch implements that change.
OpenMP 4.5 said for omp_get_initial_device:
The value of the device number is implementation defined. If it is between 0 and one less than
omp_get_num_devices() then it is valid for use with all device constructs and routines; if it is
outside that range, then it is only valid for use with the device memory routines and not in the
device clause.
and OpenMP 5.0 similarly, but OpenMP 5.1 says:
The value of the device number is the value returned by the omp_get_num_devices routine.
As the new value is compatible with what has been required earlier, I think
we can change it already now.
2020-10-22 Jakub Jelinek <jakub@redhat.com>
* icv.c (omp_get_initial_device): Remove including corresponding
ialias.
* icv-device.c (omp_get_initial_device): New function. Return
gomp_get_num_devices (). Add ialias.
* target.c (resolve_device): Don't fail with
OMP_TARGET_OFFLOAD=mandatory if device_id is equal to
gomp_get_num_devices ().
(omp_target_alloc, omp_target_free, omp_target_is_present,
omp_target_memcpy, omp_target_memcpy_rect, omp_target_associate_ptr,
omp_target_disassociate_ptr, omp_pause_resource): Use
gomp_get_num_devices () instead of GOMP_DEVICE_HOST_FALLBACK on the
first use in the functions, in uses dominated by the
gomp_get_num_devices call use num_devices_openmp instead.
* libgomp.texi (omp_get_initial_device): Document.
* config/gcn/icv-device.c (omp_get_initial_device): New function.
Add ialias.
* config/nvptx/icv-device.c (omp_get_initial_device): Likewise.
* testsuite/libgomp.c/target-40.c: New test.
2020-10-22 09:31:01 +02:00
|
|
|
ialias (omp_get_initial_device)
|
2016-11-23 19:36:41 +01:00
|
|
|
ialias (omp_get_num_devices)
|
|
|
|
ialias (omp_is_initial_device)
|