From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: (qmail 67308 invoked by alias); 30 Jul 2018 10:19:02 -0000 Mailing-List: contact gcc-patches-help@gcc.gnu.org; run by ezmlm Precedence: bulk List-Id: List-Archive: List-Post: List-Help: Sender: gcc-patches-owner@gcc.gnu.org Received: (qmail 67294 invoked by uid 89); 30 Jul 2018 10:19:02 -0000 Authentication-Results: sourceware.org; auth=none X-Spam-SWARE-Status: No, score=-26.9 required=5.0 tests=BAYES_00,GIT_PATCH_0,GIT_PATCH_1,GIT_PATCH_2,GIT_PATCH_3,SPF_PASS autolearn=ham version=3.3.2 spammy=Images, images X-HELO: mx1.suse.de Received: from mx2.suse.de (HELO mx1.suse.de) (195.135.220.15) by sourceware.org (qpsmtpd/0.93/v0.84-503-g423c35a) with ESMTP; Mon, 30 Jul 2018 10:19:00 +0000 Received: from relay2.suse.de (unknown [195.135.220.254]) by mx1.suse.de (Postfix) with ESMTP id 2AC84ADC2; Mon, 30 Jul 2018 10:18:58 +0000 (UTC) To: "gcc-patches@gcc.gnu.org" Cc: Thomas Schwinge , Jakub Jelinek , Cesar Philippidis From: Tom de Vries Subject: [libgomp, nvptx, committed] Calculate default dims per device Message-ID: Date: Mon, 30 Jul 2018 10:19:00 -0000 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="------------C34FA12DCE19DB5FDEF930CF" X-IsSubscribed: yes X-SW-Source: 2018-07/txt/msg01816.txt.bz2 This is a multi-part message in MIME format. --------------C34FA12DCE19DB5FDEF930CF Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 7bit Content-length: 96 Hi, Build and reg-tested on x86_64 with nvptx accelerator. Committed to trunk. Thanks, - Tom --------------C34FA12DCE19DB5FDEF930CF Content-Type: text/x-patch; name="0002-libgomp-nvptx-Calculate-default-dims-per-device.patch" Content-Transfer-Encoding: 7bit Content-Disposition: inline; filename*0="0002-libgomp-nvptx-Calculate-default-dims-per-device.patch" Content-length: 2828 [libgomp, nvptx] Calculate default dims per device The default dimensions are calculated using per-device properties, but initialized once and used on all devices. This patch fixes this problem by introducing per-device default dimensions. 2018-07-27 Tom de Vries * plugin/plugin-nvptx.c (struct ptx_device): Add default_dims field. (nvptx_open_device): Init default_dims for device. (nvptx_exec): Use default_dims from device. --- libgomp/plugin/plugin-nvptx.c | 28 +++++++++++++++++++++------- 1 file changed, 21 insertions(+), 7 deletions(-) diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c index 3a4077a1315..5c522aaf281 100644 --- a/libgomp/plugin/plugin-nvptx.c +++ b/libgomp/plugin/plugin-nvptx.c @@ -417,6 +417,7 @@ struct ptx_device int warp_size; int max_threads_per_block; int max_threads_per_multiprocessor; + int default_dims[GOMP_DIM_MAX]; struct ptx_image_data *images; /* Images loaded on device. */ pthread_mutex_t image_lock; /* Lock for above list. */ @@ -818,6 +819,9 @@ nvptx_open_device (int n) if (r != CUDA_SUCCESS) async_engines = 1; + for (int i = 0; i != GOMP_DIM_MAX; i++) + ptx_dev->default_dims[i] = 0; + ptx_dev->images = NULL; pthread_mutex_init (&ptx_dev->image_lock, NULL); @@ -1152,15 +1156,22 @@ nvptx_exec (void (*fn), size_t mapnum, void **hostaddrs, void **devaddrs, if (seen_zero) { - /* See if the user provided GOMP_OPENACC_DIM environment - variable to specify runtime defaults. */ - static int default_dims[GOMP_DIM_MAX]; - pthread_mutex_lock (&ptx_dev_lock); - if (!default_dims[0]) + + static int gomp_openacc_dims[GOMP_DIM_MAX]; + if (!gomp_openacc_dims[0]) + { + /* See if the user provided GOMP_OPENACC_DIM environment + variable to specify runtime defaults. */ + for (int i = 0; i < GOMP_DIM_MAX; ++i) + gomp_openacc_dims[i] = GOMP_PLUGIN_acc_default_dim (i); + } + + if (!nvthd->ptx_dev->default_dims[0]) { + int default_dims[GOMP_DIM_MAX]; for (int i = 0; i < GOMP_DIM_MAX; ++i) - default_dims[i] = GOMP_PLUGIN_acc_default_dim (i); + default_dims[i] = gomp_openacc_dims[i]; int gang, worker, vector; { @@ -1196,12 +1207,15 @@ nvptx_exec (void (*fn), size_t mapnum, void **hostaddrs, void **devaddrs, default_dims[GOMP_DIM_GANG], default_dims[GOMP_DIM_WORKER], default_dims[GOMP_DIM_VECTOR]); + + for (i = 0; i != GOMP_DIM_MAX; i++) + nvthd->ptx_dev->default_dims[i] = default_dims[i]; } pthread_mutex_unlock (&ptx_dev_lock); for (i = 0; i != GOMP_DIM_MAX; i++) if (!dims[i]) - dims[i] = default_dims[i]; + dims[i] = nvthd->ptx_dev->default_dims[i]; } /* Check if the accelerator has sufficient hardware resources to --------------C34FA12DCE19DB5FDEF930CF--