]> git.ipfire.org Git - thirdparty/gcc.git/commit
Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device
authorTobias Burnus <tburnus@baylibre.com>
Sun, 13 Oct 2024 08:18:31 +0000 (10:18 +0200)
committerTobias Burnus <tburnus@baylibre.com>
Sun, 13 Oct 2024 08:18:31 +0000 (10:18 +0200)
commit3269a722b7a03613e9c4e2862bc5088c4a17cc11
tree82e582c6bcd47b0f8dc67f3d0d056f6c2a7bb663
parentc38385ddbcce9fbeeaa788b6a4f50bd0653b0271
Fortran: Use OpenACC's acc_on_device builtin, fix OpenMP' __builtin_is_initial_device

It turned out that 'if (omp_is_initial_device() .eqv. true)' gave an ICE
due to comparing 'int' with 'logical(4)'. When digging deeper, it also
turned out that when the procedure pointer is needed, the builtin cannot
be used, either.  (Follow up to r15-2799-gf1bfba3a9b3f31 )

Extend the code to also use the builtin acc_on_device with OpenACC,
which was previously only used in C/C++.  Additionally, fix folding
when offloading is not enabled.

Fixes additionally the BT_BOOL data type, which was 'char'/integer(1)
instead of bool, backing the booleaness; use bool_type_node as the rest
of GCC.

gcc/fortran/ChangeLog:

* gfortran.h (gfc_option_t): Add disable_acc_on_device.
* options.cc (gfc_handle_option): Handle -fno-builtin-acc_on_device.
* trans-decl.cc (gfc_get_extern_function_decl): Move
__builtin_omp_is_initial_device handling to ...
* trans-expr.cc (get_builtin_fn): ... this new function.
(conv_function_val): Call it.
(update_builtin_function): New.
(gfc_conv_procedure_call): Call it.
* types.def (BT_BOOL): Fix type by using bool_type_node.

gcc/ChangeLog:

* gimple-fold.cc (gimple_fold_builtin_acc_on_device): Also fold
when offloading is not configured.

libgomp/ChangeLog:

* libgomp.texi (TR13): Fix minor typos.
(omp_is_initial_device): Improve wording.
(acc_on_device): Note how to disable the builtin.
* testsuite/libgomp.oacc-fortran/acc_on_device-1-1.f90: Remove TODO.
* testsuite/libgomp.oacc-fortran/acc_on_device-1-2.f: Likewise.
Add -fno-builtin-acc_on_device.
* testsuite/libgomp.oacc-fortran/acc_on_device-1-3.f: Likewise.
* testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c: Update
dg- as !offloading_enabled now compile-time expands acc_on_device.
* testsuite/libgomp.fortran/target-is-initial-device-3.f90: New test.
* testsuite/libgomp.oacc-fortran/acc_on_device-2.f90: New test.
13 files changed:
gcc/fortran/gfortran.h
gcc/fortran/options.cc
gcc/fortran/trans-decl.cc
gcc/fortran/trans-expr.cc
gcc/fortran/types.def
gcc/gimple-fold.cc
libgomp/libgomp.texi
libgomp/testsuite/libgomp.fortran/target-is-initial-device-3.f90 [new file with mode: 0644]
libgomp/testsuite/libgomp.oacc-c-c++-common/routine-nohost-1.c
libgomp/testsuite/libgomp.oacc-fortran/acc_on_device-1-1.f90
libgomp/testsuite/libgomp.oacc-fortran/acc_on_device-1-2.f
libgomp/testsuite/libgomp.oacc-fortran/acc_on_device-1-3.f
libgomp/testsuite/libgomp.oacc-fortran/acc_on_device-2.f90 [new file with mode: 0644]