From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [170.10.133.124]) by sourceware.org (Postfix) with ESMTPS id 09C773858C52 for ; Mon, 4 Jul 2022 08:31:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 09C773858C52 Received: from mimecast-mx02.redhat.com (mx3-rdu2.redhat.com [66.187.233.73]) by relay.mimecast.com with ESMTP with STARTTLS (version=TLSv1.2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id us-mta-282-qxC-EVZ5MJC-Ir960Uxa2Q-1; Mon, 04 Jul 2022 04:31:29 -0400 X-MC-Unique: qxC-EVZ5MJC-Ir960Uxa2Q-1 Received: from smtp.corp.redhat.com (int-mx05.intmail.prod.int.rdu2.redhat.com [10.11.54.5]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id 629B61C01B26; Mon, 4 Jul 2022 08:31:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.30]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 24D95111F5; Mon, 4 Jul 2022 08:31:28 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.17.1/8.17.1) with ESMTPS id 2648VQua1669385 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 4 Jul 2022 10:31:26 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 2648VPe41669384; Mon, 4 Jul 2022 10:31:25 +0200 Date: Mon, 4 Jul 2022 10:31:25 +0200 From: Jakub Jelinek To: Tobias Burnus Cc: gcc-patches Subject: Re: [Patch][v5] OpenMP: Move omp requires checks to libgomp Message-ID: Reply-To: Jakub Jelinek References: <5576fa00-0ddd-8046-17c1-d1cea82bdcf5@codesourcery.com> <77331328-4961-9dab-db58-b5b03daf218c@codesourcery.com> <16ca2aa4-7e73-cf9d-9482-dd59f5b0cdae@codesourcery.com> <4d42ab12-53bd-f564-25df-2e8c890f406a@codesourcery.com> MIME-Version: 1.0 In-Reply-To: <4d42ab12-53bd-f564-25df-2e8c890f406a@codesourcery.com> X-Scanned-By: MIMEDefang 2.79 on 10.11.54.5 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Type: text/plain; charset=us-ascii Content-Disposition: inline X-Spam-Status: No, score=-4.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_NONE, SPF_HELO_NONE, SPF_NONE, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: gcc-patches@gcc.gnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Gcc-patches mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Jul 2022 08:31:37 -0000 On Fri, Jul 01, 2022 at 11:08:16PM +0200, Tobias Burnus wrote: > gomp_mutex_lock (®ister_lock); > > + if (omp_requires_mask && omp_requires_mask != omp_req) I'd use if (omp_req && omp_requires_mask && omp_requires_mask != omp_req) e.g. for the case of mixing GCC <= 12 compiled code with GCC 13, treat omp_req 0 as "don't know" while GOMP_REQUIRES_TARGET_USED as "known and no requires uni*/rev* specified". > + { > + char buf1[sizeof ("unified_address, unified_shared_memory, " > + "reverse_offload")]; > + char buf2[sizeof ("unified_address, unified_shared_memory, " > + "reverse_offload")]; > + gomp_requires_to_name (buf2, sizeof (buf2), > + omp_req != GOMP_REQUIRES_TARGET_USED > + ? omp_req : omp_requires_mask); > + if (omp_req != GOMP_REQUIRES_TARGET_USED > + && omp_requires_mask != GOMP_REQUIRES_TARGET_USED) > + { > + gomp_requires_to_name (buf1, sizeof (buf1), omp_requires_mask); > + gomp_fatal ("OpenMP 'requires' directive with non-identical clauses " > + "in multiple compilation units: '%s' vs. '%s'", > + buf1, buf2); > + } > + else > + gomp_fatal ("OpenMP 'requires' directive with '%s' specified only in " > + "some compilation units", buf2); > + } > + omp_requires_mask = omp_req; > + > /* Load image to all initialized devices. */ > for (i = 0; i < num_devices; i++) > { > @@ -4125,8 +4173,30 @@ gomp_target_init (void) > > if (gomp_load_plugin_for_device (¤t_device, plugin_name)) > { > - new_num_devs = current_device.get_num_devices_func (); > - if (new_num_devs >= 1) > + int omp_req = omp_requires_mask & ~GOMP_REQUIRES_TARGET_USED; > + new_num_devs = current_device.get_num_devices_func (omp_req); > + if (new_num_devs < 0) Can this be if (gomp_debug && new_num_devs < 0) - i.e. be verbose only when the user asks for it? > + { > + bool found = false; > + int type = current_device.get_type_func (); > + for (int img = 0; img < num_offload_images; img++) > + if (type == offload_images[img].type) > + found = true; > + if (found) > + { > + char buf[sizeof ("unified_address, unified_shared_memory, " > + "reverse_offload")]; > + gomp_requires_to_name (buf, sizeof (buf), omp_req); > + char *name = (char *) malloc (cur_len + 1); > + memcpy (name, cur, cur_len); > + name[cur_len] = '\0'; > + GOMP_PLUGIN_error ("note: %s devices present but 'omp " > + "requires %s' cannot be fulfilled", > + name, buf); > + free (name); > + } > + } > + else if (new_num_devs >= 1) > { > /* Augment DEVICES and NUM_DEVICES. */ > Otherwise LGTM. Jakub