From: Tom de Vries <tdevries@suse.de>
To: "gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Cc: Thomas Schwinge <thomas@codesourcery.com>,
Jakub Jelinek <jakub@redhat.com>,
Cesar Philippidis <cesar@codesourcery.com>
Subject: [libgomp, nvptx, committed] Calculate default dims per device
Date: Mon, 30 Jul 2018 10:19:00 -0000 [thread overview]
Message-ID: <c8dc02db-67fd-b7a2-5c17-2aa66fef8794@suse.de> (raw)
[-- Attachment #1: Type: text/plain, Size: 96 bytes --]
Hi,
Build and reg-tested on x86_64 with nvptx accelerator.
Committed to trunk.
Thanks,
- Tom
[-- Attachment #2: 0002-libgomp-nvptx-Calculate-default-dims-per-device.patch --]
[-- Type: text/x-patch, Size: 2828 bytes --]
[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 <tdevries@suse.de>
* 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
next reply other threads:[~2018-07-30 10:19 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2018-07-30 10:19 Tom de Vries [this message]
2018-07-30 14:26 ` Cesar Philippidis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=c8dc02db-67fd-b7a2-5c17-2aa66fef8794@suse.de \
--to=tdevries@suse.de \
--cc=cesar@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=jakub@redhat.com \
--cc=thomas@codesourcery.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).