From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: by sourceware.org (Postfix, from userid 48) id A2040385842B; Wed, 3 Jan 2024 12:00:20 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org A2040385842B DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1704283220; bh=Utk3m+qPZQtMRdLUnKl8q1OQ3TPBWmTZ5LRaV9vfTYI=; h=From:To:Subject:Date:From; b=W+hFVyUYRF24C95cRd0Esji6EQSplRljMY5iIZzLfqFcPcvT+lSOUX+ECjgzqJR2j mZKdbP0RN6Gc5LFb+ZHAqM+Nmu7jQxcpqtHywPXLidh/oGCCCzKYOGB1XgM8x4+Gn1 ZIuwOt2ciLniONyhPynbdAYvBKWHuG5b9UtxzfIs= From: "burnus at gcc dot gnu.org" To: gcc-bugs@gcc.gnu.org Subject: [Bug libgomp/113216] New: [OpenMP] Improve omp_target_is_accessible Date: Wed, 03 Jan 2024 12:00:18 +0000 X-Bugzilla-Reason: CC X-Bugzilla-Type: new X-Bugzilla-Watch-Reason: None X-Bugzilla-Product: gcc X-Bugzilla-Component: libgomp X-Bugzilla-Version: 14.0 X-Bugzilla-Keywords: openmp X-Bugzilla-Severity: normal X-Bugzilla-Who: burnus at gcc dot gnu.org X-Bugzilla-Status: UNCONFIRMED X-Bugzilla-Resolution: X-Bugzilla-Priority: P3 X-Bugzilla-Assigned-To: unassigned at gcc dot gnu.org X-Bugzilla-Target-Milestone: --- X-Bugzilla-Flags: X-Bugzilla-Changed-Fields: bug_id short_desc product version bug_status keywords bug_severity priority component assigned_to reporter cc target_milestone Message-ID: Content-Type: text/plain; charset="UTF-8" Content-Transfer-Encoding: quoted-printable X-Bugzilla-URL: http://gcc.gnu.org/bugzilla/ Auto-Submitted: auto-generated MIME-Version: 1.0 List-Id: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=3D113216 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 ho= st, 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 addresse= s + a superset has to be formed. * * * For the device side, an API function might be available to check for it. * *=20 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 =3D=3D CU_MEM_ACCESS_FLAGS_PROT_READWRITE, if I understa= nd it correctly. typedef enum CUmemAccess_flags_enum { CU_MEM_ACCESS_FLAGS_PROT_NONE =3D 0x0, /**< Default, make the address r= ange not accessible */ CU_MEM_ACCESS_FLAGS_PROT_READ =3D 0x1, /**< Make the address range read accessible */ CU_MEM_ACCESS_FLAGS_PROT_READWRITE =3D 0x3, /**< Make the address range read-write accessible */ CU_MEM_ACCESS_FLAGS_PROT_MAX =3D 0x7FFFFFFF } CUmemAccess_flags; * * In case of HSA/ROCm, I bet there is also some function. For instance, hipPointerGetAttribute{,s} + hipDrvPointerGetAttributes permi= t to query some pointer data.=