From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from esa4.mentor.iphmx.com (esa4.mentor.iphmx.com [68.232.137.252]) by sourceware.org (Postfix) with ESMTPS id C9263396E869 for ; Thu, 8 Dec 2022 15:02:22 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org C9263396E869 Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=codesourcery.com Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=mentor.com X-IronPort-AV: E=Sophos;i="5.96,227,1665475200"; d="scan'208";a="88981814" Received: from orw-gwy-01-in.mentorg.com ([192.94.38.165]) by esa4.mentor.iphmx.com with ESMTP; 08 Dec 2022 07:02:22 -0800 IronPort-SDR: g4IA/1Ktn/iP6JqUZ1EDTPsBUaWkH3xzk0FkCs1NQDyemyDZox6xD7zNT6cyjFqtoboQexEXOD G3e2yqL1VuUP5O6Ux6r5Q6VClfy0h6mpmEzzznBUgcOGk30JYDqfpM0pB8d1s5taZudZapWomZ FMFbFonAF099PxLyer9PXqHnBke0zREMXnpA7578k47bv03HfcHrtSXLyINWO0N3YVrn2N1qs9 rZrC1StdBr+w7irNABYm93On7nkbAP7HnriHKYZhUuZrkShu9sh1jfoM5SvAYPkmnfeRXEhmqR 7SI= Message-ID: <265e852f-e31f-015a-1a3e-c6468f404c9b@codesourcery.com> Date: Thu, 8 Dec 2022 16:02:11 +0100 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:102.0) Gecko/20100101 Thunderbird/102.5.1 Subject: Re: [PATCH 02/17] libgomp: pinned memory Content-Language: en-US To: Andrew Stubbs , Jakub Jelinek , Thomas Schwinge CC: References: From: Tobias Burnus In-Reply-To: Content-Type: text/plain; charset="UTF-8"; format=flowed Content-Transfer-Encoding: quoted-printable X-Originating-IP: [137.202.0.90] X-ClientProxiedBy: svr-ies-mbx-14.mgc.mentorg.com (139.181.222.14) To svr-ies-mbx-12.mgc.mentorg.com (139.181.222.12) X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00,HEADER_FROM_DIFFERENT_DOMAINS,KAM_DMARC_STATUS,NICE_REPLY_A,SPF_HELO_PASS,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On 08.12.22 15:35, Andrew Stubbs wrote: > On 08/12/2022 14:02, Tobias Burnus wrote: >> With available, I assume that nvptx is an 'available device' (per OpenMP >> definition, finally added in TR11), i.e. there is an image for nvptx and >> - after omp_requires filtering - there remains at least one nvptx >> device. > > If plugin-nvptx has been loaded then the function will be available. > Do we need to get fancier than that? I think it does not really make sense to use CUDA if there is no single dev= ice. In terms of loading, the code does: gomp_target_init(void) { ... cur =3D OFFLOAD_PLUGINS; /* This is a comma-separated string with the s= upported plugins. */ ... if (gomp_load_plugin_for_device (¤t_device, plugin_name)) { int omp_req =3D omp_requires_mask & ~GOMP_REQUIRES_TARGET_USED= ; new_num_devs =3D current_device.get_num_devices_func (omp_req)= ; Thus, CUDA is loaded at the 'gomp_load_plugin_for_device' line and at the 'new_num_devs =3D' line, it has been filtered for OpenMP's 'requires' deman= ds.* Thus, 'new_num_devs' contains the number of 'accessible devices' (OpenMP de= finition), filtered for the 'requires'* (which part of the 'supported devices' require= ments). (* With some caveats related to late loading of offloading code from (share= d) libraries.) * * * Admittedly, this does not yet cover the last suggested feature: GOMP_offload_register_ver (...) { gomp_load_image_to_device (devicep, version, which is relevant for the first part of: 'supported devices' - '... supported by the implementation for execution of= target code ... requires directive are fulfilled'. (available =3D (intersection of 'accessible devices' and 'supported devices= ') possibly filtered + reordered via the OMP_AVAILABLE_DEVICES env var.) I am not sure how strictly it is required and when we know when the all off= load_register are over; I do note that OpenMP TR 11 has an over-engineered OMP_AVAILABLE_DEVI= CES environment variable which permits to filter the list of available devices =E2=80=93 wh= ich also requires early access to the initial 'available devices' list. But it might be sufficient = to rely on the device-is-accessible + requires filtering and ignore whether an actual imag= e is available. Tobias ----------------- Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstra=C3=9Fe 201= , 80634 M=C3=BCnchen; Gesellschaft mit beschr=C3=A4nkter Haftung; Gesch=C3= =A4ftsf=C3=BChrer: Thomas Heurung, Frank Th=C3=BCrauf; Sitz der Gesellschaf= t: M=C3=BCnchen; Registergericht M=C3=BCnchen, HRB 106955