Hi,
On 05.05.22 11:33, Jakub Jelinek via Gcc-patches wrote:
On Mon, Mar 14, 2022 at 04:42:14PM +0100, Marcel Vollweiler wrote:
+ interface
+ function omp_target_is_accessible (ptr, size, device_num) bind(c)
+ use, intrinsic :: iso_c_binding, only : c_ptr, c_size_t, c_int
+ integer(c_int) :: omp_target_is_accessible
The function returning integer(c_int) rather than logical seems like
a screw up in the standard, but too late to fix that :(.
I think the idea is that it can directly call the C function without
needing a wrapper. And as default-kind 'logical' != 'integer(c_int)' in
general, it cannot return logical. (In case of GCC, just claiming that
it is logical would work. But some Fortran compilers use -1 for .true.
and only flip a single bit for .not. For those,
"if(.not.omp_target_is_accessible(..)) will not work properly, if the C
function returns 1.
But I concur that requiring "/= 0" is ugly!
OT, tried to look how libomptarget implements it and they don't at least
on llvm-project trunk, but while looking at that, noticed that for
omp_target_is_present they do return false from omp_target_is_present
while we return true. It is unclear if NULL has corresponding storage
on the device (NULL always corresponds to NULL on the device) or not.
Regarding NULL: no idea what's the best semantic – we could ask
for clarification.
Regarding target:
I think "false" from on device makes more sense in general, especially
if the device number points to a different device. It might work in some
cases – but false simply plays save. Note that the spec states:
"When called from within a target region the effect is unspecified."
Thus, either behavior is fine.
Tobias
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634
München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas
Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht
München, HRB 106955