This is the mail archive of the
gcc-patches@gcc.gnu.org
mailing list for the GCC project.
[PATCH] Remove use of 'struct map' from plugin (nvptx)
- From: James Norris <James_Norris at mentor dot com>
- To: GCC Patches <gcc-patches at gcc dot gnu dot org>, Jakub Jelinek <jakub at redhat dot com>
- Date: Wed, 16 Dec 2015 14:35:52 -0600
- Subject: [PATCH] Remove use of 'struct map' from plugin (nvptx)
- Authentication-results: sourceware.org; auth=none
Hi,
The attached patch removes the use of the map structure
(struct map) from the NVPTX plugin.
Regtested on x86_64-pc-linux-gnu
Ok for trunk?
Thanks!
Jim
ChangeLog
=========
2015-12-XX 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
Index: plugin/plugin-nvptx.c
===================================================================
diff --git a/trunk/libgomp/plugin/plugin-nvptx.c b/trunk/libgomp/plugin/plugin-nvptx.c
--- a/trunk/libgomp/plugin/plugin-nvptx.c (revision 231649)
+++ b/trunk/libgomp/plugin/plugin-nvptx.c (working copy)
@@ -91,13 +91,6 @@
struct ptx_device *ptx_dev;
};
-struct map
-{
- int async;
- size_t size;
- char mappings[0];
-};
-
static void
map_init (struct ptx_stream *s)
{
@@ -140,17 +133,13 @@
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 = s->h_next;
- s->h_tail += m->size;
-
if (s->h_tail >= s->h_end)
s->h_tail = s->h_begin + (int) (s->h_tail - s->h_end);
@@ -167,16 +156,14 @@
}
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);
@@ -183,22 +170,14 @@
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 = s->h_next - s->h;
- offset = (void *)&m->mappings[0] - s->h;
-
*d = (void *)(s->d + offset);
*h = (void *)(s->h + offset);
@@ -904,7 +883,7 @@
/* 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__);
Index: testsuite/libgomp.oacc-c-c++-common/mapping-1.c
===================================================================
diff --git a/trunk/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c b/trunk/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c
new file mode 10644
--- /dev/null (revision 0)
+++ b/trunk/libgomp/testsuite/libgomp.oacc-c-c++-common/mapping-1.c (working copy)
@@ -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);
+}