From: Thomas Schwinge <thomas@codesourcery.com>
To: <gcc-patches@gcc.gnu.org>
Cc: Andrew Stubbs <ams@codesourcery.com>
Subject: [og12] Add 'libgomp.c/alloc-ompx_host_mem_alloc-1.c'
Date: Fri, 24 Mar 2023 17:35:15 +0100 [thread overview]
Message-ID: <87zg8285vg.fsf@euler.schwinge.homeip.net> (raw)
[-- Attachment #1: Type: text/plain, Size: 510 bytes --]
Hi!
This had fallen out of some earlier work of mine; I've now pushed to
devel/omp/gcc-12 branch commit ae2dca26602678f8b70e22da1bce8302c0751b75
"Add 'libgomp.c/alloc-ompx_host_mem_alloc-1.c'", see attached.
Grüße
Thomas
-----------------
Siemens Electronic Design Automation GmbH; Anschrift: Arnulfstraße 201, 80634 München; Gesellschaft mit beschränkter Haftung; Geschäftsführer: Thomas Heurung, Frank Thürauf; Sitz der Gesellschaft: München; Registergericht München, HRB 106955
[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Add-libgomp.c-alloc-ompx_host_mem_alloc-1.c.patch --]
[-- Type: text/x-diff, Size: 3239 bytes --]
From ae2dca26602678f8b70e22da1bce8302c0751b75 Mon Sep 17 00:00:00 2001
From: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed, 15 Feb 2023 11:27:55 +0100
Subject: [PATCH] Add 'libgomp.c/alloc-ompx_host_mem_alloc-1.c'
OpenMP 'ompx_host_mem_alloc' is available for host and nvptx offloading as of
og12 commit 84914e197d91a67b3d27db0e4c69a433462983a5
"openmp, nvptx: ompx_unified_shared_mem_alloc", and for GCN offloading as of
og12 commit c77c45a641fedc3fe770e909cc010fb1735bdbbd
"amdgcn, libgomp: low-latency allocator".
libgomp/
* testsuite/libgomp.c/alloc-ompx_host_mem_alloc-1.c: New.
---
libgomp/ChangeLog.omp | 2 +
.../libgomp.c/alloc-ompx_host_mem_alloc-1.c | 77 +++++++++++++++++++
2 files changed, 79 insertions(+)
create mode 100644 libgomp/testsuite/libgomp.c/alloc-ompx_host_mem_alloc-1.c
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index ef957e3d2d8..6b816e46cd2 100644
--- a/libgomp/ChangeLog.omp
+++ b/libgomp/ChangeLog.omp
@@ -1,5 +1,7 @@
2023-03-24 Thomas Schwinge <thomas@codesourcery.com>
+ * testsuite/libgomp.c/alloc-ompx_host_mem_alloc-1.c: New.
+
* config/gcn/allocator.c (gcn_memspace_free): Explicitly handle
'memspace == ompx_host_mem_space'.
diff --git a/libgomp/testsuite/libgomp.c/alloc-ompx_host_mem_alloc-1.c b/libgomp/testsuite/libgomp.c/alloc-ompx_host_mem_alloc-1.c
new file mode 100644
index 00000000000..683b7aff3d4
--- /dev/null
+++ b/libgomp/testsuite/libgomp.c/alloc-ompx_host_mem_alloc-1.c
@@ -0,0 +1,77 @@
+/* Verify that on the host we can but on a device we cannot allocate 'ompx_host_mem_alloc' memory. */
+
+/* { dg-additional-options -DOFFLOAD_DEVICE { target offload_device } } */
+
+#include <omp.h>
+
+#pragma omp requires dynamic_allocators
+
+int main()
+{
+#pragma omp target
+ {
+ char *c, *c_;
+
+ c = omp_alloc(1, ompx_host_mem_alloc);
+#ifdef OFFLOAD_DEVICE
+ if (c)
+ __builtin_abort ();
+#else
+ if (!c)
+ __builtin_abort ();
+#endif
+ omp_free(c, ompx_host_mem_alloc);
+
+ c = omp_aligned_alloc(128, 256, ompx_host_mem_alloc);
+#ifdef OFFLOAD_DEVICE
+ if (c)
+ __builtin_abort ();
+#else
+ if (!c)
+ __builtin_abort ();
+#endif
+ omp_free(c, omp_null_allocator);
+
+ c = omp_calloc(1, 1, ompx_host_mem_alloc);
+#ifdef OFFLOAD_DEVICE
+ if (c)
+ __builtin_abort ();
+#else
+ if (!c)
+ __builtin_abort ();
+#endif
+ c_ = omp_realloc(c, 2, ompx_host_mem_alloc, ompx_host_mem_alloc);
+#ifdef OFFLOAD_DEVICE
+ if (c_)
+ __builtin_abort ();
+#else
+ if (!c_)
+ __builtin_abort ();
+#endif
+ c = omp_realloc(c_, 0, ompx_host_mem_alloc, ompx_host_mem_alloc);
+ if (c)
+ __builtin_abort ();
+
+ c = omp_aligned_calloc(64, 1, 512, ompx_host_mem_alloc);
+#ifdef OFFLOAD_DEVICE
+ if (c)
+ __builtin_abort ();
+#else
+ if (!c)
+ __builtin_abort ();
+#endif
+ c_ = omp_realloc(c, 2, c ? omp_null_allocator : ompx_host_mem_alloc, omp_null_allocator);
+#ifdef OFFLOAD_DEVICE
+ if (c_)
+ __builtin_abort ();
+#else
+ if (!c_)
+ __builtin_abort ();
+#endif
+ c = omp_realloc(c_, 0, omp_null_allocator, omp_null_allocator);
+ if (c)
+ __builtin_abort ();
+ }
+
+ return 0;
+}
--
2.25.1
reply other threads:[~2023-03-24 16:35 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
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=87zg8285vg.fsf@euler.schwinge.homeip.net \
--to=thomas@codesourcery.com \
--cc=ams@codesourcery.com \
--cc=gcc-patches@gcc.gnu.org \
/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).