https://gcc.gnu.org/bugzilla/show_bug.cgi?id=113216
Bug ID: 113216 Summary: [OpenMP] Improve omp_target_is_accessible Product: gcc Version: 14.0 Status: UNCONFIRMED Keywords: openmp Severity: normal Priority: P3 Component: libgomp Assignee: unassigned at gcc dot gnu.org Reporter: burnus at gcc dot gnu.org CC: jakub at gcc dot gnu.org Target Milestone: --- For omp_target_is_accessible + unified address: * it is not 100% correct to assume that any address is accessible on the host, it might be a device-only address (For handling NULL, see also PR 113213) Likewise for the nonhost device: * memory might be accessible even if only unified address * * * The host case is a bit trickier as no generic documentation seems to be available albeit some ranges like 0x7F...... seem to denote device addresses + a superset has to be formed. * * * For the device side, an API function might be available to check for it. * * In case of nvptx / CUDA, the following function seems to be suitable: CUresult cuMemGetAccess ( unsigned long long* flags, const CUmemLocation* location, CUdeviceptr ptr ) checking for flags == CU_MEM_ACCESS_FLAGS_PROT_READWRITE, if I understand it correctly. typedef enum CUmemAccess_flags_enum { CU_MEM_ACCESS_FLAGS_PROT_NONE = 0x0, /**< Default, make the address range not accessible */ CU_MEM_ACCESS_FLAGS_PROT_READ = 0x1, /**< Make the address range read accessible */ CU_MEM_ACCESS_FLAGS_PROT_READWRITE = 0x3, /**< Make the address range read-write accessible */ CU_MEM_ACCESS_FLAGS_PROT_MAX = 0x7FFFFFFF } CUmemAccess_flags; * * In case of HSA/ROCm, I bet there is also some function. For instance, hipPointerGetAttribute{,s} + hipDrvPointerGetAttributes permit to query some pointer data.