summaryrefslogtreecommitdiffstats
path: root/openmp/runtime/test/api/omp_alloc_null_fb.c
diff options
context:
space:
mode:
authorJonathan Peyton <jonathan.l.peyton@intel.com>2019-04-08 17:59:28 +0000
committerJonathan Peyton <jonathan.l.peyton@intel.com>2019-04-08 17:59:28 +0000
commitebf1830bb1ddb7a49f3e037bca83b3ec4f60a05c (patch)
tree604d92859b26f1abd8050624c7d99df73a6ebc29 /openmp/runtime/test/api/omp_alloc_null_fb.c
parente7bd735bb03a7b8141e32f7d6cb98e8914d8799e (diff)
downloadbcm5719-llvm-ebf1830bb1ddb7a49f3e037bca83b3ec4f60a05c.tar.gz
bcm5719-llvm-ebf1830bb1ddb7a49f3e037bca83b3ec4f60a05c.zip
[OpenMP] Implement 5.0 memory management
* Replace HBWMALLOC API with more general MEMKIND API, new functions and variables added. * Have libmemkind.so loaded when accessible. * Redirect memspaces to default one except for high bandwidth which is processed separately. * Ignore some allocator traits e.g., sync_hint, access, pinned, while others are processed normally e.g., alignment, pool_size, fallback, fb_data, partition. * Add tests for memory management Patch by Andrey Churbanov Differential Revision: https://reviews.llvm.org/D59783 llvm-svn: 357929
Diffstat (limited to 'openmp/runtime/test/api/omp_alloc_null_fb.c')
-rw-r--r--openmp/runtime/test/api/omp_alloc_null_fb.c35
1 files changed, 35 insertions, 0 deletions
diff --git a/openmp/runtime/test/api/omp_alloc_null_fb.c b/openmp/runtime/test/api/omp_alloc_null_fb.c
new file mode 100644
index 00000000000..9528c46047a
--- /dev/null
+++ b/openmp/runtime/test/api/omp_alloc_null_fb.c
@@ -0,0 +1,35 @@
+// RUN: %libomp-compile-and-run
+
+#include <stdio.h>
+#include <omp.h>
+
+int main() {
+ omp_alloctrait_t at[2];
+ omp_allocator_handle_t a;
+ void *p[2];
+ at[0].key = OMP_ATK_POOL_SIZE;
+ at[0].value = 2 * 1024 * 1024;
+ at[1].key = OMP_ATK_FALLBACK;
+ at[1].value = OMP_ATV_NULL_FB;
+ a = omp_init_allocator(omp_large_cap_mem_space, 2, at);
+ printf("allocator large created: %p\n", a);
+ #pragma omp parallel num_threads(2)
+ {
+ int i = omp_get_thread_num();
+ #pragma omp barrier
+ p[i] = omp_alloc(1024 * 1024, a);
+ #pragma omp barrier
+ printf("th %d, ptr %p\n", i, p[i]);
+ omp_free(p[i], a);
+ }
+ // As an allocator has some small memory overhead
+ // exactly one of the two pointers should be NULL
+ // because of NULL fallback requested
+ if ((p[0] == NULL && p[1] != NULL) || (p[0] != NULL && p[1] == NULL)) {
+ printf("passed\n");
+ return 0;
+ } else {
+ printf("failed: pointers %p %p\n", p[0], p[1]);
+ return 1;
+ }
+}
OpenPOWER on IntegriCloud