diff options
author | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2019-04-08 17:59:28 +0000 |
---|---|---|
committer | Jonathan Peyton <jonathan.l.peyton@intel.com> | 2019-04-08 17:59:28 +0000 |
commit | ebf1830bb1ddb7a49f3e037bca83b3ec4f60a05c (patch) | |
tree | 604d92859b26f1abd8050624c7d99df73a6ebc29 /openmp/runtime/test/api/omp_alloc.c | |
parent | e7bd735bb03a7b8141e32f7d6cb98e8914d8799e (diff) | |
download | bcm5719-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.c')
-rw-r--r-- | openmp/runtime/test/api/omp_alloc.c | 81 |
1 files changed, 0 insertions, 81 deletions
diff --git a/openmp/runtime/test/api/omp_alloc.c b/openmp/runtime/test/api/omp_alloc.c deleted file mode 100644 index 2002adbec57..00000000000 --- a/openmp/runtime/test/api/omp_alloc.c +++ /dev/null @@ -1,81 +0,0 @@ -// RUN: %libomp-compile-and-run - -// REQUIRES: openmp-5.0 - -#include <stdio.h> -#include <stdint.h> -#include <omp.h> -#include "omp_testsuite.h" - -#define ARRAY_SIZE 10000 - -int test_omp_alloc() { - int err; - int i, j; - int *shared_array; - const omp_allocator_t *allocator; - const omp_allocator_t *test_allocator; - // Currently, only default memory allocator is implemented - const omp_allocator_t *allocators[] = { - omp_default_mem_alloc, - }; - - err = 0; - for (i = 0; i < sizeof(allocators) / sizeof(allocators[0]); ++i) { - allocator = allocators[i]; - printf("Using %p allocator\n", test_allocator); - omp_set_default_allocator(allocator); - test_allocator = omp_get_default_allocator(); - if (test_allocator != allocator) { - printf("error: omp_set|get_default_allocator() not working\n"); - return 0; - } - shared_array = (int *)omp_alloc(sizeof(int) * ARRAY_SIZE, test_allocator); - if (shared_array == NULL) { - printf("error: shared_array is NULL\n"); - return 0; - } - for (j = 0; j < ARRAY_SIZE; ++j) { - shared_array[j] = j; - } - #pragma omp parallel shared(shared_array) - { - int i; - int tid = omp_get_thread_num(); - int *private_array = - (int *)omp_alloc(sizeof(int) * ARRAY_SIZE, omp_default_mem_alloc); - if (private_array == NULL) { - printf("error: thread %d private_array is NULL\n", tid); - #pragma omp atomic - err++; - } - for (i = 0; i < ARRAY_SIZE; ++i) { - private_array[i] = shared_array[i] + tid; - } - for (i = 0; i < ARRAY_SIZE; ++i) { - if (private_array[i] != i + tid) { - printf("error: thread %d element %d is %d instead of %d\n", tid, i, - private_array[i], i + tid); - #pragma omp atomic - err++; - } - } - omp_free(private_array, omp_default_mem_alloc); - } /* end of parallel */ - omp_free(shared_array, test_allocator); - } - - return !err; -} - -int main() { - int i; - int num_failed = 0; - - for (i = 0; i < REPETITIONS; i++) { - if (!test_omp_alloc()) { - num_failed++; - } - } - return num_failed; -} |