Hi Tobias!
On 2024-02-13T18:31:02+0100, Tobias Burnus <[email protected]> wrote:
> --- a/gcc/fortran/openmp.cc
> +++ b/gcc/fortran/openmp.cc
> + /* Device number must be conforming, which includes
> + omp_initial_device (-1) and omp_invalid_device (-4). */
> + if (property_kind == OMP_TRAIT_PROPERTY_DEV_NUM_EXPR
> + && otp->expr->expr_type == EXPR_CONSTANT
> + && mpz_sgn (otp->expr->value.integer) < 0
> + && mpz_cmp_si (otp->expr->value.integer, -1) != 0
> + && mpz_cmp_si (otp->expr->value.integer, -4) != 0)
> + {
> + gfc_error ("property must be a conforming device number "
> + "at %C");
Instead of magic numbers, shouldn't this use 'include/gomp-constants.h':
/* We have a compatibility issue. OpenMP 5.2 introduced
omp_initial_device with value of -1 which clashes with our
GOMP_DEVICE_ICV, so we need to remap user supplied device
ids, -1 (aka omp_initial_device) to GOMP_DEVICE_HOST_FALLBACK,
and -2 (one of many non-conforming device numbers, but with
OMP_TARGET_OFFLOAD=mandatory needs to be treated a
omp_invalid_device) to -3 (so that for dev_num >= -2U we can
subtract 1). -4 is then what we use for omp_invalid_device,
which unlike the other non-conforming device numbers results
in fatal error regardless of OMP_TARGET_OFFLOAD. */
#define GOMP_DEVICE_ICV -1
#define GOMP_DEVICE_HOST_FALLBACK -2
#define GOMP_DEVICE_INVALID -4
Grüße
Thomas