From patchwork Tue Jul 27 14:26:22 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ulrich Drepper X-Patchwork-Id: 1510516 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=gcc.gnu.org (client-ip=2620:52:3:1:0:246e:9693:128c; helo=sourceware.org; envelope-from=gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org; receiver=) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=gcc.gnu.org header.i=@gcc.gnu.org header.a=rsa-sha256 header.s=default header.b=Cj82Z4Lp; dkim-atps=neutral Received: from sourceware.org (server2.sourceware.org [IPv6:2620:52:3:1:0:246e:9693:128c]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 4GYzdN0CmBz9sWl for ; Wed, 28 Jul 2021 00:27:03 +1000 (AEST) Received: from server2.sourceware.org (localhost [IPv6:::1]) by sourceware.org (Postfix) with ESMTP id 051653857436 for ; Tue, 27 Jul 2021 14:26:59 +0000 (GMT) DKIM-Filter: OpenDKIM Filter v2.11.0 sourceware.org 051653857436 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gcc.gnu.org; s=default; t=1627396019; bh=qNlKE8n3Pzi9sByi7zL5ntd/EcKCz9jIa3NPzDfPlsE=; h=Date:Subject:To:List-Id:List-Unsubscribe:List-Archive:List-Post: List-Help:List-Subscribe:From:Reply-To:From; b=Cj82Z4Lpab51rsB9dizd8LGMXf8STv0sQs+QK+dwhO7NUCge/GBFaJXQkmj2T6fFl YChoN4qMT0p7t73bTsKEAuCUmbG3XMl52eBceK5j2NKAEX8yoLlf0v82vvEMa652ot VlkwT3ytHNCsCtIDbd1S0h3qPwHGL8RqmxxsCdUg= 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 [170.10.133.124]) by sourceware.org (Postfix) with ESMTP id DFB933858002 for ; Tue, 27 Jul 2021 14:26:36 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org DFB933858002 Received: from mail-ot1-f72.google.com (mail-ot1-f72.google.com [209.85.210.72]) (Using TLS) by relay.mimecast.com with ESMTP id us-mta-364-oUBguFXhMt2T9kGOw4mAWQ-1; Tue, 27 Jul 2021 10:26:34 -0400 X-MC-Unique: oUBguFXhMt2T9kGOw4mAWQ-1 Received: by mail-ot1-f72.google.com with SMTP id i18-20020a9d62520000b02904ccb7285c38so7399145otk.14 for ; Tue, 27 Jul 2021 07:26:34 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:mime-version:from:date:message-id:subject:to; bh=RQLxiQ0HRY4QStVoLRZtsNAPbmYvLmmc2dEs61766N8=; b=VWZWXzbMGPUwWj+gkkpbMLX4YZMkAnwvK5JiOpKVfDn4xqYC6ut+3MK5JIKPzMDyp8 O67zZlrZH5LbGj88m/Erh/CxZMkuNo7EH7JUeix+fpJF4mCkJC8cqrfvqO+mDtGtnQYj ineux7Euuu7AA9KDYHNb0IPNDupJcX9mLYkvDrcHpXi/IsvDfUp64LvUQhKDTIAj3lAe 5ebPr4+TAptvY2/Gzq/Bhmj2Awcj0GLv11GZsYx1iaOXq0EUpZ/e7LkHTJcgCZUyMEm0 ypYJZYFvrVVH3Ytxqs3t5y9w3s2ogOlYLggw6ZzDV+gikY6T5vyAX+mPBeTYpIg7yoKC c93w== X-Gm-Message-State: AOAM530lfgGybad88VHs7fSnmlfllvfa9KoFK/yMUnjXypigy7Oi0/gU T+ASa6FGiapdtw6sLr/+7Dp6NPEaDB8gI48xBzc4cKQi/BqD4E9vj4wAE4DiYsl91c57msaa4hc kMBonmYp14q7z2wqSn9wUzzvb7mjlhE1dqQ== X-Received: by 2002:a9d:6851:: with SMTP id c17mr16080853oto.89.1627395993590; Tue, 27 Jul 2021 07:26:33 -0700 (PDT) X-Google-Smtp-Source: ABdhPJwlcALRhtzkCX/P9CBvwfIM9cxtJ2cjrbx8P8u4Mw5BiFj0sV3xMLsKF9AA+JV5NXSbhkTSuMlsaPlRGa0PNLs= X-Received: by 2002:a9d:6851:: with SMTP id c17mr16080831oto.89.1627395993282; Tue, 27 Jul 2021 07:26:33 -0700 (PDT) MIME-Version: 1.0 Date: Tue, 27 Jul 2021 16:26:22 +0200 Message-ID: Subject: OpenMP 5.1: omp_display_env To: gcc-patches@gcc.gnu.org X-Mimecast-Spam-Score: 0 X-Mimecast-Originator: redhat.com X-Spam-Status: No, score=-12.3 required=5.0 tests=BAYES_00, DKIMWL_WL_HIGH, DKIM_SIGNED, DKIM_VALID, DKIM_VALID_AU, DKIM_VALID_EF, GIT_PATCH_0, HTML_MESSAGE, RCVD_IN_DNSWL_LOW, RCVD_IN_MSPIKE_H4, RCVD_IN_MSPIKE_WL, 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-Content-Filtered-By: Mailman/MimeDel 2.1.29 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: Ulrich Drepper via Gcc-patches From: Ulrich Drepper Reply-To: Ulrich Drepper Errors-To: gcc-patches-bounces+incoming=patchwork.ozlabs.org@gcc.gnu.org Sender: "Gcc-patches" I know OpenMP 5.1 is not really a focus yet but adding this new interface should not be problematic. I stumbled across this part of the spec and the functionality is really already mostly there in the form of OMP_DISPLAY_ENV=verbose etc. This is just a function interface to the same functionality. Aside from the busywork to add a new interface (headers, map file) the only real question was how to deal with the two parameters which are passed to handle_omp_display_env in the current implementation. The omp_display_env interface is supposed to show the information of the initial values and therefore I think the right implementation is to store the values determined in the constructor in two global, static variables and reuse them. The rest should be completely boring and therefore not distracting anyone from OpenMP 5.0 work. OK to commit? diff --git a/libgomp/env.c b/libgomp/env.c index a24deabcd58..84038eb4683 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -99,6 +99,9 @@ int goacc_default_dims[GOMP_DIM_MAX]; #ifndef LIBGOMP_OFFLOADED_ONLY +static int wait_policy; +static unsigned long stacksize = GOMP_DEFAULT_STACKSIZE; + /* Parse the OMP_SCHEDULE environment variable. */ static void @@ -1210,46 +1213,11 @@ parse_gomp_openacc_dim (void) } } -static void -handle_omp_display_env (unsigned long stacksize, int wait_policy) +void +omp_display_env (int verbose) { - const char *env; - bool display = false; - bool verbose = false; int i; - env = getenv ("OMP_DISPLAY_ENV"); - if (env == NULL) - return; - - while (isspace ((unsigned char) *env)) - ++env; - if (strncasecmp (env, "true", 4) == 0) - { - display = true; - env += 4; - } - else if (strncasecmp (env, "false", 5) == 0) - { - display = false; - env += 5; - } - else if (strncasecmp (env, "verbose", 7) == 0) - { - display = true; - verbose = true; - env += 7; - } - else - env = "X"; - while (isspace ((unsigned char) *env)) - ++env; - if (*env != '\0') - gomp_error ("Invalid value for environment variable OMP_DISPLAY_ENV"); - - if (!display) - return; - fputs ("\nOPENMP DISPLAY ENVIRONMENT BEGIN\n", stderr); fputs (" _OPENMP = '201511'\n", stderr); @@ -1409,13 +1377,52 @@ handle_omp_display_env (unsigned long stacksize, int wait_policy) fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr); } +static void +handle_omp_display_env (void) +{ + const char *env; + bool display = false; + bool verbose = false; + + env = getenv ("OMP_DISPLAY_ENV"); + if (env == NULL) + return; + + while (isspace ((unsigned char) *env)) + ++env; + if (strncasecmp (env, "true", 4) == 0) + { + display = true; + env += 4; + } + else if (strncasecmp (env, "false", 5) == 0) + { + display = false; + env += 5; + } + else if (strncasecmp (env, "verbose", 7) == 0) + { + display = true; + verbose = true; + env += 7; + } + else + env = "X"; + while (isspace ((unsigned char) *env)) + ++env; + if (*env != '\0') + gomp_error ("Invalid value for environment variable OMP_DISPLAY_ENV"); + + if (display) + omp_display_env (verbose); +} + static void __attribute__((constructor)) initialize_env (void) { - unsigned long thread_limit_var, stacksize = GOMP_DEFAULT_STACKSIZE; + unsigned long thread_limit_var; unsigned long max_active_levels_var; - int wait_policy; /* Do a compile time check that mkomp_h.pl did good job. */ omp_check_defines (); @@ -1546,7 +1553,7 @@ initialize_env (void) gomp_error ("Stack size change failed: %s", strerror (err)); } - handle_omp_display_env (stacksize, wait_policy); + handle_omp_display_env (); /* OpenACC. */ diff --git a/libgomp/fortran.c b/libgomp/fortran.c index 4ec39c4e61b..2f36e326624 100644 --- a/libgomp/fortran.c +++ b/libgomp/fortran.c @@ -736,3 +736,9 @@ omp_get_default_allocator_ () { return (intptr_t) omp_get_default_allocator (); } + +void +omp_display_env_ (const int32_t *verbose) +{ + omp_display_env (*verbose); +} diff --git a/libgomp/libgomp.map b/libgomp/libgomp.map index 8ea27b5565f..fe51d3dbd46 100644 --- a/libgomp/libgomp.map +++ b/libgomp/libgomp.map @@ -199,6 +199,12 @@ OMP_5.0.1 { omp_fulfill_event_; } OMP_5.0; +OMP_5.1 { + global: + omp_display_env; + omp_display_env_; +} OMP_5.0.1; + GOMP_1.0 { global: GOMP_atomic_end; diff --git a/libgomp/omp.h.in b/libgomp/omp.h.in index 69f96f09124..c93db968d2e 100644 --- a/libgomp/omp.h.in +++ b/libgomp/omp.h.in @@ -293,6 +293,8 @@ extern void omp_free (void *, omp_allocator_handle_t __GOMP_DEFAULT_NULL_ALLOCATOR) __GOMP_NOTHROW; +extern void omp_display_env (int) __GOMP_NOTHROW; + #ifdef __cplusplus } #endif diff --git a/libgomp/omp_lib.f90.in b/libgomp/omp_lib.f90.in index 851f85f5316..4939bfd9751 100644 --- a/libgomp/omp_lib.f90.in +++ b/libgomp/omp_lib.f90.in @@ -653,6 +653,12 @@ end function end interface + interface + subroutine omp_display_env (verbose) + logical,intent(in) :: verbose + end subroutine + end interface + #if _OPENMP >= 201811 !GCC$ ATTRIBUTES DEPRECATED :: omp_get_nested, omp_set_nested #endif diff --git a/libgomp/omp_lib.h.in b/libgomp/omp_lib.h.in index 06d17b5fcdc..9873cea9ac1 100644 --- a/libgomp/omp_lib.h.in +++ b/libgomp/omp_lib.h.in @@ -264,3 +264,5 @@ external omp_set_default_allocator external omp_get_default_allocator integer (omp_allocator_handle_kind) omp_get_default_allocator + + external omp_display_env