From patchwork Fri Oct 15 14:48:25 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Jakub Jelinek X-Patchwork-Id: 46279 Return-Path: X-Original-To: patchwork@sourceware.org Delivered-To: patchwork@sourceware.org Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 930D23857C76 for ; Fri, 15 Oct 2021 14:49:03 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 930D23857C76 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1634309343; bh=BzPgquFU8jAi0kWQmf0kb0O8q6TWHa3o3WR/V/TYTGA=; h=Date:To:Subject:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:Cc:From; b=HnWOLWp7YURHVFf4vGF4XyDVCdVZYG+eWcmpENyg53joTZ/isikywpWGMqZRP7iNR Zz87jO/7E2wyXxkQImTTkP8aQVuRTe4uan30omIlEMmt8xNwshns6pN/dMDS2Rutrw cAOL3L14qbyeSLPtc6IZ7M0hsZoAalc3ePHoCX7w= X-Original-To: gcc-patches@gcc.gnu.org Delivered-To: gcc-patches@gcc.gnu.org Received: from us-smtp-delivery-124.mimecast.com (us-smtp-delivery-124.mimecast.com [216.205.24.124]) by sourceware.org (Postfix) with ESMTP id CB66E3857C6B for ; Fri, 15 Oct 2021 14:48:33 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org CB66E3857C6B Received: from mimecast-mx01.redhat.com (mimecast-mx01.redhat.com [209.132.183.4]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-321-ARjH_665PfKITF_kpSdVEw-1; Fri, 15 Oct 2021 10:48:30 -0400 X-MC-Unique: ARjH_665PfKITF_kpSdVEw-1 Received: from smtp.corp.redhat.com (int-mx03.intmail.prod.int.phx2.redhat.com [10.5.11.13]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by mimecast-mx01.redhat.com (Postfix) with ESMTPS id 26317801AA7; Fri, 15 Oct 2021 14:48:29 +0000 (UTC) Received: from tucnak.zalov.cz (unknown [10.39.193.172]) by smtp.corp.redhat.com (Postfix) with ESMTPS id C99D070951; Fri, 15 Oct 2021 14:48:28 +0000 (UTC) Received: from tucnak.zalov.cz (localhost [127.0.0.1]) by tucnak.zalov.cz (8.16.1/8.16.1) with ESMTPS id 19FEmQl6424975 (version=TLSv1.3 cipher=TLS_AES_256_GCM_SHA384 bits=256 verify=NOT); Fri, 15 Oct 2021 16:48:26 +0200 Received: (from jakub@localhost) by tucnak.zalov.cz (8.16.1/8.16.1/Submit) id 19FEmPHC424974; Fri, 15 Oct 2021 16:48:25 +0200 Date: Fri, 15 Oct 2021 16:48:25 +0200 To: gcc-patches@gcc.gnu.org Subject: [committed] openmp: Handle OpenMP 5.1 simplified OMP_PLACES syntax Message-ID: <20211015144825.GG304296@tucnak> MIME-Version: 1.0 X-Scanned-By: MIMEDefang 2.79 on 10.5.11.13 X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com Content-Disposition: inline X-Spam-Status: No, score=-5.5 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H2, SPF_HELO_NONE, SPF_NONE, TXREP autolearn=ham autolearn_force=no version=3.4.4 X-Spam-Checker-Version: SpamAssassin 3.4.4 (2020-01-24) 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-Patchwork-Original-From: Jakub Jelinek via Gcc-patches From: Jakub Jelinek Reply-To: Jakub Jelinek Cc: Tobias Burnus Errors-To: gcc-patches-bounces+patchwork=sourceware.org@gcc.gnu.org Sender: "Gcc-patches" Hi! In addition to adding ll_caches and numa_domain abstract names to OMP_PLACES syntax, OpenMP 5.1 also added one syntax simplification: https://github.com/OpenMP/spec/issues/2080 https://github.com/OpenMP/spec/pull/2081 in particular that in the grammar place non-terminal is now not only { res-list } but also res (i.e. a non-negative integer), which stands as a shortcut for { res } So, one can specify OMP_PLACES=0,4,8,12 with the meaning OMP_PLACES={0},{4},{8},{12} or OMP_PLACES=0:4 instead of OMP_PLACES={0}:4 or OMP_PLACES={0},{1},{2},{3} etc. This patch implements that. Regtested on x86_64-linux and i686-linux, commited to trunk. 2021-10-15 Jakub Jelinek * env.c (parse_one_place): Handle non-negative-number the same as { non-negative-number }. Reject even !number:1 and !number:1:stride or !place:1 or !place:1:stride instead of just length other than 1. * libgomp.texi (OpenMP 5.1): Document OMP_PLACES syntax extensions and OMP_NUM_TEAMS/OMP_TEAMS_THREAD_LIMIT and omp_{set_num,get_max}_teams/omp_{s,g}et_teams_thread_limit features as implemented. * testsuite/libgomp.c/affinity-1.c: Add a test for the 5.1 place simplified syntax. Jakub --- libgomp/env.c.jj 2021-10-15 14:07:07.464919497 +0200 +++ libgomp/env.c 2021-10-15 15:29:33.051521024 +0200 @@ -546,6 +546,7 @@ parse_one_place (char **envp, bool *nega long stride = 1; int pass; bool any_negate = false; + bool has_braces = true; *negatep = false; while (isspace ((unsigned char) *env)) ++env; @@ -557,12 +558,28 @@ parse_one_place (char **envp, bool *nega ++env; } if (*env != '{') - return false; - ++env; - while (isspace ((unsigned char) *env)) - ++env; + { + char *end; + unsigned long this_num; + + errno = 0; + this_num = strtoul (env, &end, 10); + if (errno || end == env) + return false; + env = end - 1; + has_braces = false; + if (gomp_places_list + && !gomp_affinity_add_cpus (p, this_num, 1, 1, false)) + return false; + } + else + { + ++env; + while (isspace ((unsigned char) *env)) + ++env; + } start = env; - for (pass = 0; pass < (any_negate ? 2 : 1); pass++) + for (pass = 0; pass < (any_negate ? 2 : has_braces); pass++) { env = start; do @@ -590,6 +607,8 @@ parse_one_place (char **envp, bool *nega if (*env == ':') { ++env; + if (this_negate) + return false; while (isspace ((unsigned char) *env)) ++env; errno = 0; @@ -612,8 +631,6 @@ parse_one_place (char **envp, bool *nega ++env; } } - if (this_negate && this_len != 1) - return false; if (gomp_places_list && pass == this_negate) { if (this_negate) @@ -640,6 +657,8 @@ parse_one_place (char **envp, bool *nega if (*env == ':') { char *end; + if (*negatep) + return false; ++env; while (isspace ((unsigned char) *env)) ++env; @@ -663,8 +682,6 @@ parse_one_place (char **envp, bool *nega ++env; } } - if (*negatep && len != 1) - return false; *envp = env; *lenp = len; *stridep = stride; --- libgomp/libgomp.texi.jj 2021-10-14 22:03:52.007889926 +0200 +++ libgomp/libgomp.texi 2021-10-15 15:47:33.791920057 +0200 @@ -309,7 +309,7 @@ The OpenMP 4.5 specification is fully su @item @code{present} argument to @code{defaultmap} clause @tab N @tab @item @code{omp_set_num_teams}, @code{omp_set_teams_thread_limit}, @code{omp_get_max_teams}, @code{omp_get_teams_thread_limit} runtime - routines @tab N @tab + routines @tab Y @tab @item @code{omp_target_is_accessible} runtime routine @tab N @tab @item @code{omp_target_memcpy_async} and @code{omp_target_memcpy_rect_async} runtime routines @tab N @tab @@ -328,9 +328,9 @@ The OpenMP 4.5 specification is fully su @code{ompt_callback_target_emi_t}, @code{ompt_callback_target_map_emi_t} and @code{ompt_callback_target_submit_emi_t} @tab N @tab @item @code{ompt_callback_error_t} type @tab N @tab -@item @code{OMP_PLACES} syntax was extension @tab N @tab +@item @code{OMP_PLACES} syntax extensions @tab Y @tab @item @code{OMP_NUM_TEAMS} and @code{OMP_TEAMS_THREAD_LIMIT} environment - variables @tab N @tab + variables @tab Y @tab @end multitable @unnumberedsubsec Other new OpenMP 5.1 features --- libgomp/testsuite/libgomp.c/affinity-1.c.jj 2021-08-12 20:37:12.702473673 +0200 +++ libgomp/testsuite/libgomp.c/affinity-1.c 2021-10-15 15:13:06.712762372 +0200 @@ -48,7 +48,7 @@ struct place }; struct places { - char name[40]; + char name[50]; int count; struct place places[8]; } places_array[] = { @@ -62,7 +62,9 @@ struct places { { 1, 1 }, { 2, 1 }, { 3, 1 }, { 4, 1 }, { 5, 1 }, { 6, 1 }, { 7, 1 } } }, { "{0,1},{3,2,4},{6,5,!6},{6},{7:2:-1,!6}", 5, - { { 0, 2 }, { 2, 3 }, { 5, 1 }, { 6, 1 }, { 7, 1 } } } + { { 0, 2 }, { 2, 3 }, { 5, 1 }, { 6, 1 }, { 7, 1 } } }, + { "1,2,{2,3,!2},3,3,!3,!{5:3:-1,!4,!5},{4},5,!4,!5", 3, + { { 1, 1 }, { 2, 1 }, { 3, 1 } } } }; unsigned long contig_cpucount;