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.129.124]) by sourceware.org (Postfix) with ESMTPS id 904D63857B9D for ; Mon, 6 Jun 2022 17:59:49 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org 904D63857B9D 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-373-7k8K6aMaNTqakb9JdDZQvA-1; Mon, 06 Jun 2022 13:59:48 -0400 X-MC-Unique: 7k8K6aMaNTqakb9JdDZQvA-1 Received: from smtp.corp.redhat.com (int-mx10.intmail.prod.int.rdu2.redhat.com [10.11.54.10]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx02.redhat.com (Postfix) with ESMTPS id C71DC398CA68; Mon, 6 Jun 2022 17:59:47 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.192.11]) by smtp.corp.redhat.com (Postfix) with ESMTPS id 44AD6492C3B; Mon, 6 Jun 2022 17:59:47 +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 256HxiWO192749 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Mon, 6 Jun 2022 19:59:44 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.17.1/8.17.1/Submit) id 256HxcNF192748; Mon, 6 Jun 2022 19:59:38 +0200 Date: Mon, 6 Jun 2022 19:59:38 +0200 From: Jakub Jelinek To: Mohamed Atef Cc: Mohamed Sayed , gcc-patches@gcc.gnu.org Subject: Re: [PATCH]: libgompd add parallel handle functions Message-ID: Reply-To: Jakub Jelinek References: MIME-Version: 1.0 In-Reply-To: X-Scanned-By: MIMEDefang 2.85 on 10.11.54.10 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.8 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, 06 Jun 2022 17:59:52 -0000 On Mon, Jun 06, 2022 at 07:32:31PM +0200, Mohamed Atef wrote: > So for both cases one should read the value of *team and if it's NULL, the > function returns some error state (eg. ompd_rc_unavailable) No, I think for team NULL it should simply push something different to ompd_parallel_handle_t, something that would mean for uses of the handle that it is not a normal explicit parallel, but the implicit parallel and handle those cases differently. E.g. if one has int main () { #pragma omp parallel sleep (1024); } then when you get the explicit parallel's handle, there is struct gomp_team one can store and work with, but its enclosing parallel isn't non-existent, it is an implicit parallel, only its enclosing parallel doesn't exist. Unfortunately, it isn't that easy. We sometimes do create struct gomp_team even for the implicit parallel. See libgomp/target.c (GOMP_target_ext) which is there for cases like int main () { #pragma omp target nowait something; something_else; #pragma omp taskwait } where we want the asynchronous target to be really asynchronous with something_else; and need struct gomp_team for that. But in the case of artificial struct gomp_team for this case thr->ts.level will be 0 rather than > 0. > > ompd_get_task_parallel_handle when you'll have struct gomp_task * > > and want the struct gomp_team it is in. > > I'm afraid the library doesn't track this, it doesn't need it for anything. > > One possibility to resolve this is perhaps if all functions that > > allocate ompd_task_handle_t can't know the corresponding struct gomp_thread > > too, then you could store in the private structure or ompd_task_handle_t > > both struct gomp_task * and struct gomp_thread *. > > > I will ask the guys to try this if it's impossible then we delay this > function. Perhaps the function can be added but could just error unconditionally until some solution is found. BTW, when looking at the patch, I found I've missed some things in the first already committed patch. + #define gompd_init_access(t, m) \ + gompd_access_##t##_##m = (__UINT64_TYPE__) & (((struct t *) NULL)->m); This is UB, should be using offsetof (struct t, m) instead. Also, using __UINT64_TYPE__ for those offsets or sizes seems to be very excessive, on x86_64-linux the largest struct from looking at debug info is struct gomp_team right now with 1344 bytes. So for the time being, I think using __UINT16_TYPE__ for all those sizes and offsets should be 4 times as compact. And, it would be nice to initialize those at least when possible at compile time, not in gompd_load, offsetof of a non-VLA type is a constant expression, similarly sizeof, so making all those const and initialized directly would mean they don't waste a writable section (so all processes can share those). Probably it would be nice to stick them at least for ELF into a names section so that they'd be together and not needing to be ever touched unless OMPD is enabled. Of course, I don't rule out the possibility of some values needing to be initialized at runtime, they'd simply just not be const like the rest. Jakub