From: Cesar Philippidis <cesar_philippidis@mentor.com>
To: Tom de Vries <tdevries@suse.de>,
"gcc-patches@gcc.gnu.org" <gcc-patches@gcc.gnu.org>
Subject: [PATCH,nvptx] Remove use of 'struct map' from plugin (nvptx)
Date: Tue, 31 Jul 2018 15:12:00 -0000 [thread overview]
Message-ID: <1f1721dd-e1e6-b169-e5e6-d62e5eada1cd@mentor.com> (raw)
[-- Attachment #1: Type: text/plain, Size: 295 bytes --]
This is an old patch which removes the struct map from the nvptx plugin.
I believe at one point this was supposed to be used to manage async data
mappings, but in practice that never worked out.
Is this OK for trunk? I bootstrapped and regtested on x86_64 with nvptx
offloading.
Thanks,
Cesar
[-- Attachment #2: 0001-Remove-use-of-struct-map-from-plugin-nvptx.patch --]
[-- Type: text/x-patch, Size: 4207 bytes --]
[PATCH] Remove use of 'struct map' from plugin (nvptx)
2018-XX-YY Cesar Philippidis <cesar@codesourcery.com>
James Norris <jnorris@codesourcery.com>
libgomp/
* plugin/plugin-nvptx.c (struct map): Removed.
(map_init, map_pop): Remove use of struct map. (map_push):
Likewise and change argument list.
* testsuite/libgomp.oacc-c-c++-common/mapping-1.c: New
(cherry picked from gomp-4_0-branch r231616)
---
libgomp/plugin/plugin-nvptx.c | 33 +++---------
.../libgomp.oacc-c-c++-common/mapping-1.c | 63 ++++++++++++++++++++++
2 files changed, 69 insertions(+), 27 deletions(-)
create mode 100644 libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c
diff --git a/libgomp/plugin/plugin-nvptx.c b/libgomp/plugin/plugin-nvptx.c
index a92f054..1237ea10 100644
--- a/libgomp/plugin/plugin-nvptx.c
+++ b/libgomp/plugin/plugin-nvptx.c
@@ -225,13 +225,6 @@ struct nvptx_thread
struct ptx_device *ptx_dev;
};
-struct map
-{
- int async;
- size_t size;
- char mappings[0];
-};
-
static bool
map_init (struct ptx_stream *s)
{
@@ -265,16 +258,12 @@ map_fini (struct ptx_stream *s)
static void
map_pop (struct ptx_stream *s)
{
- struct map *m;
-
assert (s != NULL);
assert (s->h_next);
assert (s->h_prev);
assert (s->h_tail);
- m = s->h_tail;
-
- s->h_tail += m->size;
+ s->h_tail = s->h_next;
if (s->h_tail >= s->h_end)
s->h_tail = s->h_begin + (int) (s->h_tail - s->h_end);
@@ -292,37 +281,27 @@ map_pop (struct ptx_stream *s)
}
static void
-map_push (struct ptx_stream *s, int async, size_t size, void **h, void **d)
+map_push (struct ptx_stream *s, size_t size, void **h, void **d)
{
int left;
int offset;
- struct map *m;
assert (s != NULL);
left = s->h_end - s->h_next;
- size += sizeof (struct map);
assert (s->h_prev);
assert (s->h_next);
if (size >= left)
{
- m = s->h_prev;
- m->size += left;
- s->h_next = s->h_begin;
-
- if (s->h_next + size > s->h_end)
- GOMP_PLUGIN_fatal ("unable to push map");
+ assert (s->h_next == s->h_prev);
+ s->h_next = s->h_prev = s->h_tail = s->h_begin;
}
assert (s->h_next);
- m = s->h_next;
- m->async = async;
- m->size = size;
-
- offset = (void *)&m->mappings[0] - s->h;
+ offset = s->h_next - s->h;
*d = (void *)(s->d + offset);
*h = (void *)(s->h + offset);
@@ -1291,7 +1270,7 @@ nvptx_exec (void (*fn), size_t mapnum, void **hostaddrs, void **devaddrs,
/* This reserves a chunk of a pre-allocated page of memory mapped on both
the host and the device. HP is a host pointer to the new chunk, and DP is
the corresponding device pointer. */
- map_push (dev_str, async, mapnum * sizeof (void *), &hp, &dp);
+ map_push (dev_str, mapnum * sizeof (void *), &hp, &dp);
GOMP_PLUGIN_debug (0, " %s: prepare mappings\n", __FUNCTION__);
diff --git a/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c b/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c
new file mode 100644
index 0000000..593e7d4
--- /dev/null
+++ b/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c
@@ -0,0 +1,63 @@
+/* { dg-do run } */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+
+/* Exercise the kernel launch argument mapping. */
+
+int
+main (int argc, char **argv)
+{
+ int a[256], b[256], c[256], d[256], e[256], f[256];
+ int i;
+ int n;
+
+ /* 48 is the size of the mappings for the first parallel construct. */
+ n = sysconf (_SC_PAGESIZE) / 48 - 1;
+
+ i = 0;
+
+ for (i = 0; i < n; i++)
+ {
+ #pragma acc parallel copy (a, b, c, d)
+ {
+ int j;
+
+ for (j = 0; j < 256; j++)
+ {
+ a[j] = j;
+ b[j] = j;
+ c[j] = j;
+ d[j] = j;
+ }
+ }
+ }
+
+#pragma acc parallel copy (a, b, c, d, e, f)
+ {
+ int j;
+
+ for (j = 0; j < 256; j++)
+ {
+ a[j] = j;
+ b[j] = j;
+ c[j] = j;
+ d[j] = j;
+ e[j] = j;
+ f[j] = j;
+ }
+ }
+
+ for (i = 0; i < 256; i++)
+ {
+ if (a[i] != i) abort();
+ if (b[i] != i) abort();
+ if (c[i] != i) abort();
+ if (d[i] != i) abort();
+ if (e[i] != i) abort();
+ if (f[i] != i) abort();
+ }
+
+ exit (0);
+}
--
2.7.4
next prev reply other threads:[~2018-07-31 15:12 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-12-14 13:46 [gomp4] Fix handling of kernel launch mappings James Norris
2015-12-16 20:36 ` [PATCH] Remove use of 'struct map' from plugin (nvptx) James Norris
2016-01-05 15:49 ` James Norris
2018-07-31 15:12 ` Cesar Philippidis [this message]
2018-08-01 11:01 ` [PATCH,nvptx] " Tom de Vries
2018-08-01 13:43 ` Cesar Philippidis
2018-08-01 13:44 ` Tom de Vries
2019-05-06 8:29 ` Thomas Schwinge
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=1f1721dd-e1e6-b169-e5e6-d62e5eada1cd@mentor.com \
--to=cesar_philippidis@mentor.com \
--cc=gcc-patches@gcc.gnu.org \
--cc=tdevries@suse.de \
/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).