From patchwork Tue Oct 28 13:19:18 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Julian Brown X-Patchwork-Id: 404228 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.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id C30E1140077 for ; Wed, 29 Oct 2014 00:19:42 +1100 (AEDT) DomainKey-Signature: a=rsa-sha1; c=nofws; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; q=dns; s= default; b=U/k0WLQir084bB1rcBtHIcm3ngrTVBIlj30bRNFVQAX+7Q0dmVK5y 8xZr1LstcDIs93IuRMHtxnSxckGQ3rD0u4NCVboKa0tOrAeb6aftj4orWBhoREQB OD0NMc0RTRtNAyNeZoCtSYuDBD4yh9lEcrCUnLaDSr7OS4PsfjyN28= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=gcc.gnu.org; h=list-id :list-unsubscribe:list-archive:list-post:list-help:sender:date :from:to:subject:message-id:mime-version:content-type; s= default; bh=31pW1Ngv+Byg52nQ1vKNGA9U6rE=; b=ORUzN44Lsjgc21uqI75+ VesxfwTvcrOqRvbNY8tV2Osd0eM6YudCx0xGfXEbLbnYkfZr4ZGrdk9vc05mGhVK X1xVAN/gTygTdYZMCuUseIGAUg2Wv4/Qmz8hwl6v3fu0R1Aqm64ziOIeBZpjupYV l1tQ5nzsGDVSxDPWeWnDF5s= Received: (qmail 10393 invoked by alias); 28 Oct 2014 13:19:35 -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 10374 invoked by uid 89); 28 Oct 2014 13:19:30 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-1.8 required=5.0 tests=AWL, BAYES_00, RCVD_IN_DNSWL_NONE autolearn=ham version=3.3.2 X-HELO: relay1.mentorg.com Received: from relay1.mentorg.com (HELO relay1.mentorg.com) (192.94.38.131) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Tue, 28 Oct 2014 13:19:29 +0000 Received: from nat-ies.mentorg.com ([192.94.31.2] helo=SVR-IES-FEM-02.mgc.mentorg.com) by relay1.mentorg.com with esmtp id 1Xj6gH-0002rh-Uq from Julian_Brown@mentor.com ; Tue, 28 Oct 2014 06:19:26 -0700 Received: from octopus (137.202.0.76) by SVR-IES-FEM-02.mgc.mentorg.com (137.202.0.106) with Microsoft SMTP Server id 14.3.181.6; Tue, 28 Oct 2014 13:19:24 +0000 Date: Tue, 28 Oct 2014 13:19:18 +0000 From: Julian Brown To: , Thomas Schwinge , Jakub Jelinek Subject: [gomp4] Remove goacc_parse_device_num Message-ID: <20141028131918.65ae08c5@octopus> MIME-Version: 1.0 X-IsSubscribed: yes Hi, This patch removes the goacc_parse_device_num function in libgomp's env.c since it is redundant with parse_int. I also added some bounds checking for the device number in oacc-init.c (the behaviour is left as "implementation defined" in the OpenACC 2.0 spec, so I chose to raise an error for an out-of-range device number). OK for gomp4 branch? Thanks, Julian ChangeLog libgomp/ * env.c (goacc_parse_device_num): Remove. (initialize_env): Use parse_int instead of goacc_parse_device_num. * oacc-init.c (lazy_open): Add bounds check for device number. commit 1dacb833b33d179553723faecf4b32e89efc69a9 Author: Julian Brown Date: Tue Oct 28 06:03:47 2014 -0700 ACC_DEVICE_NUM tweaks diff --git a/libgomp/env.c b/libgomp/env.c index 8b22e6f..02bce0c 100644 --- a/libgomp/env.c +++ b/libgomp/env.c @@ -1016,27 +1016,6 @@ parse_affinity (bool ignore) return false; } - -static void -goacc_parse_device_num (void) -{ - const char *env = getenv ("ACC_DEVICE_NUM"); - int default_num = -1; - - if (env && *env != '\0') - { - char *end; - default_num = strtol (env, &end, 0); - - if (*end || default_num < 0) - default_num = 0; - } - else - default_num = 0; - - goacc_device_num = default_num; -} - static void goacc_parse_device_type (void) { @@ -1310,7 +1289,9 @@ initialize_env (void) handle_omp_display_env (stacksize, wait_policy); /* Look for OpenACC-specific environment variables. */ - goacc_parse_device_num (); + if (!parse_int ("ACC_DEVICE_NUM", &goacc_device_num, true)) + goacc_device_num = 0; + goacc_parse_device_type (); /* Initialize OpenACC-specific internal state. */ diff --git a/libgomp/oacc-init.c b/libgomp/oacc-init.c index 489ac14..24e911b 100644 --- a/libgomp/oacc-init.c +++ b/libgomp/oacc-init.c @@ -249,6 +249,9 @@ lazy_open (int ord) if (ord < 0) ord = goacc_device_num; + if (ord >= base_dev->get_num_devices_func ()) + gomp_fatal ("device %u does not exist", ord); + if (!thr) thr = goacc_new_thread ();