[Openmp-commits] [openmp] e6d2665 - [OpenMP] Let predefined allocator fallback to default instead of returning null

Nawrin Sultana via Openmp-commits openmp-commits at lists.llvm.org
Mon Dec 5 18:53:05 PST 2022


Author: Nawrin Sultana
Date: 2022-12-05T20:52:51-06:00
New Revision: e6d2665df35a0ab378e7525eee72309ff27a0d3b

URL: https://github.com/llvm/llvm-project/commit/e6d2665df35a0ab378e7525eee72309ff27a0d3b
DIFF: https://github.com/llvm/llvm-project/commit/e6d2665df35a0ab378e7525eee72309ff27a0d3b.diff

LOG: [OpenMP] Let predefined allocator fallback to default instead of returning null

Differential Revision: https://reviews.llvm.org/D139376

Added: 
    

Modified: 
    openmp/runtime/src/kmp_alloc.cpp

Removed: 
    


################################################################################
diff  --git a/openmp/runtime/src/kmp_alloc.cpp b/openmp/runtime/src/kmp_alloc.cpp
index fc806cdc554be..06c16eaa0fa9e 100644
--- a/openmp/runtime/src/kmp_alloc.cpp
+++ b/openmp/runtime/src/kmp_alloc.cpp
@@ -1561,6 +1561,9 @@ void *__kmp_alloc(int gtid, size_t algn, size_t size,
   desc.size_orig = size;
   desc.size_a = size + sz_desc + align;
 
+  // Use default allocator if libmemkind is not available
+  int use_default_allocator = (__kmp_memkind_available) ? false : true;
+
   if (__kmp_memkind_available) {
     if (allocator < kmp_max_mem_alloc) {
       // pre-defined allocator
@@ -1639,11 +1642,25 @@ void *__kmp_alloc(int gtid, size_t algn, size_t size,
 
     // pre-defined allocator
     if (allocator == omp_high_bw_mem_alloc) {
-      // ptr = NULL;
+      KMP_WARNING(OmpNoAllocator, "omp_high_bw_mem_alloc");
     } else if (allocator == omp_large_cap_mem_alloc) {
-      // warnings?
-    } else {
+      KMP_WARNING(OmpNoAllocator, "omp_large_cap_mem_alloc");
+    } else if (allocator == omp_const_mem_alloc) {
+      KMP_WARNING(OmpNoAllocator, "omp_const_mem_alloc");
+    } else if (allocator == omp_low_lat_mem_alloc) {
+      KMP_WARNING(OmpNoAllocator, "omp_low_lat_mem_alloc");
+    } else if (allocator == omp_cgroup_mem_alloc) {
+      KMP_WARNING(OmpNoAllocator, "omp_cgroup_mem_alloc");
+    } else if (allocator == omp_pteam_mem_alloc) {
+      KMP_WARNING(OmpNoAllocator, "omp_pteam_mem_alloc");
+    } else if (allocator == omp_thread_mem_alloc) {
+      KMP_WARNING(OmpNoAllocator, "omp_thread_mem_alloc");
+    } else { // default allocator requested
+      use_default_allocator = true;
+    }
+    if (use_default_allocator) {
       ptr = __kmp_thread_malloc(__kmp_thread_from_gtid(gtid), desc.size_a);
+      use_default_allocator = false;
     }
   } else if (KMP_IS_TARGET_MEM_SPACE(al->memspace)) {
     if (__kmp_target_mem_available) {


        


More information about the Openmp-commits mailing list