public inbox for gcc-cvs@sourceware.org
help / color / mirror / Atom feed
* [gcc/devel/omp/gcc-13] Add 'libgomp.c/alloc-ompx_host_mem_alloc-1.c'
@ 2023-05-19 16:54 Kwok Yeung
0 siblings, 0 replies; only message in thread
From: Kwok Yeung @ 2023-05-19 16:54 UTC (permalink / raw)
To: gcc-cvs
https://gcc.gnu.org/g:14daae29fa97514102193fb79da3c3b098d3929e
commit 14daae29fa97514102193fb79da3c3b098d3929e
Author: Thomas Schwinge <thomas@codesourcery.com>
Date: Wed Feb 15 11:27:55 2023 +0100
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.
Diff:
---
libgomp/ChangeLog.omp | 2 +
.../libgomp.c/alloc-ompx_host_mem_alloc-1.c | 77 ++++++++++++++++++++++
2 files changed, 79 insertions(+)
diff --git a/libgomp/ChangeLog.omp b/libgomp/ChangeLog.omp
index a03d5d2f291..ef88e0f4c0c 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;
+}
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2023-05-19 16:54 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2023-05-19 16:54 [gcc/devel/omp/gcc-13] Add 'libgomp.c/alloc-ompx_host_mem_alloc-1.c' Kwok Yeung
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).