From patchwork Tue Mar 19 18:05:12 2013 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Tobias Burnus X-Patchwork-Id: 229170 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (Client CN "localhost", Issuer "www.qmailtoaster.com" (not verified)) by ozlabs.org (Postfix) with ESMTPS id 5482A2C0136 for ; Wed, 20 Mar 2013 05:05:35 +1100 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; q=dns; s=dkim1; b=A2Ook+kjhM6RbRKwd0O hrDNhZNLwTUobRdPWvbAhJXN93OWNkLljVKjndjUGlma99AgJOjysosQbettAPyg mvUlese2L0boDKRg0sd0fca1n/wfIGNp4lNCHVgbZocgZ6knjb7PN0j5UOsKfYLn CxthzIcUT9CBM4BrSs/oWGPw= DKIM-Signature: v=1; a=rsa-sha1; c=simple; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender :message-id:date:from:mime-version:to:cc:subject:references :in-reply-to:content-type; s=dkim1; bh=ue3qs1j/yYyr3XovACkHJB6fE hc=; b=c8hz7d4da8S0lDzG+kb2KyMvF/+/2E3W3zDpjmAJEqrEENrChKuI/DdFf ULg3MJDRvNU73FEwsxPwTj5SfgTG5LyC4XkRWBkicJNzcVGA3Q33jypLOpyuc4tm f+O/dL3eIL586TdVXmtqJNmgkYnwbVKHvOs4Bwu8ezQAyDvAxI= Received: (qmail 31835 invoked by alias); 19 Mar 2013 18:05:30 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Delivered-To: mailing list gcc-patches@gcc.gnu.org Received: (qmail 31760 invoked by uid 89); 19 Mar 2013 18:05:21 -0000 X-Spam-Sware-Status: No, score=-2.2 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.1 Received: from mx01.qsc.de (HELO mx01.qsc.de) (213.148.129.14) by sourceware.org (qpsmtpd/0.84/v0.84-167-ge50287c) with ESMTP; Tue, 19 Mar 2013 18:05:15 +0000 Received: from archimedes.net-b.de (port-92-195-211-180.dynamic.qsc.de [92.195.211.180]) by mx01.qsc.de (Postfix) with ESMTP id 8C9EF3CADA; Tue, 19 Mar 2013 19:05:12 +0100 (CET) Message-ID: <5148A8D8.1090103@net-b.de> Date: Tue, 19 Mar 2013 19:05:12 +0100 From: Tobias Burnus User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:17.0) Gecko/20130215 Thunderbird/17.0.3 MIME-Version: 1.0 To: Jakub Jelinek CC: gcc patches Subject: Re: [gomp 4.0] Handle OMP_DISPLAY_ENV References: <51488314.6090308@net-b.de> <20130319165008.GG12913@tucnak.redhat.com> In-Reply-To: <20130319165008.GG12913@tucnak.redhat.com> Jakub Jelinek wrote: >> +#include >> +#include /* For PRIu64. */ > > stdio.h is fine, but inttypes.h needs to be > #ifdef HAVE_INTTYPES_H > # include > #endif > for portability (libgomp/configure already checks for that). Good point. Attached the updated patch. I assume, you will create the gomp-4_0-branch when gcc.gnu.org is fully operational. Additionally, I presume, the change-log information should go to the file ChangeLog.gomp and not to ChangeLog. Tobias 2013-03-19 Tobias Burnus * env.c (handle_omp_display_env): New function. (initialize_env): Use it. diff --git a/libgomp/env.c b/libgomp/env.c index 65cbba8..5cd1164 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -29,6 +29,10 @@ #include "libgomp_f.h" #include #include +#include +#ifdef HAVE_INTTYPES_H +# include /* For PRIu64. */ +#endif #ifdef STRING_WITH_STRINGS # include # include @@ -565,6 +569,122 @@ parse_affinity (void) return false; } + +static void +handle_omp_display_env (bool proc_bind, unsigned long stacksize, + int wait_policy) +{ + 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) + { + 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 = '201107'\n", stderr); + fprintf (stderr, " OMP_DYNAMIC = '%s'\n", + gomp_global_icv.dyn_var ? "TRUE" : "FALSE"); + fprintf (stderr, " OMP_NESTED = '%s'\n", + gomp_global_icv.nest_var ? "TRUE" : "FALSE"); + + fprintf (stderr, " OMP_NUM_THREADS = '%lu", gomp_global_icv.nthreads_var); + for (i = 1; i < gomp_nthreads_var_list_len; i++) + fprintf (stderr, ",%lu", gomp_nthreads_var_list[i]); + fputs ("'\n", stderr); + + fprintf (stderr, " OMP_SCHEDULE = '"); + switch (gomp_global_icv.run_sched_var) + { + case GFS_RUNTIME: + fputs ("RUNTIME", stderr); + break; + case GFS_STATIC: + fputs ("STATIC", stderr); + break; + case GFS_DYNAMIC: + fputs ("DYNAMIC", stderr); + break; + case GFS_GUIDED: + fputs ("GUIDED", stderr); + break; + case GFS_AUTO: + fputs ("AUTO", stderr); + break; + } + fputs ("'\n", stderr); + + fprintf (stderr, " OMP_PROC_BIND = '%s'\n", + proc_bind ? "TRUE" : "FALSE"); + fprintf (stderr, " OMP_STACKSIZE = '%lu'\n", stacksize); + + /* GOMP's default value is actually neither active nor passive. */ + fprintf (stderr, " OMP_WAIT_POLICY = '%s'\n", + wait_policy > 0 ? "ACTIVE" : "PASSIVE"); + fprintf (stderr, " OMP_THREAD_LIMIT = '%lu'\n", + gomp_thread_limit_var); + fprintf (stderr, " OMP_MAX_ACTIVE_LEVELS = '%lu'\n", + gomp_max_active_levels_var); + +/* FIXME: Unimplemented OpenMP 4.0 environment variables. + fprintf (stderr, " OMP_PLACES = ''\n"); + fprintf (stderr, " OMP_CANCELLATION = ''\n"); + fprintf (stderr, " OMP_DEFAULT_DEVICE = ''\n"); */ + + if (verbose) + { + fputs (" GOMP_CPU_AFFINITY = '", stderr); + if (gomp_cpu_affinity_len) + { + fprintf (stderr, "%d", gomp_cpu_affinity[0]); + for (i = 1; i < gomp_cpu_affinity_len; i++) + fprintf (stderr, " %d", gomp_cpu_affinity[i]); + } + fputs ("'\n", stderr); + fprintf (stderr, " GOMP_STACKSIZE = '%lu'\n", stacksize); +#ifdef HAVE_INTTYPES_H + fprintf (stderr, " GOMP_SPINCOUNT = '%"PRIu64"'\n", + (uint64_t) gomp_spin_count_var); +#else + fprintf (stderr, " GOMP_SPINCOUNT = '%lu'\n", + (unsigned long) gomp_spin_count_var); +#endif + } + + fputs ("OPENMP DISPLAY ENVIRONMENT END\n", stderr); +} + + static void __attribute__((constructor)) initialize_env (void) { @@ -645,6 +765,8 @@ initialize_env (void) if (err != 0) gomp_error ("Stack size change failed: %s", strerror (err)); } + + handle_omp_display_env (bind_var, stacksize, wait_policy); }