[Openmp-commits] [PATCH] D139376: [OpenMP] Let predefined allocator fallback to default instead of returning null

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


This revision was automatically updated to reflect the committed changes.
Closed by commit rGe6d2665df35a: [OpenMP] Let predefined allocator fallback to default instead of returning null (authored by Nawrin).

Changed prior to commit:
  https://reviews.llvm.org/D139376?vs=480270&id=480313#toc

Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D139376/new/

https://reviews.llvm.org/D139376

Files:
  openmp/runtime/src/kmp_alloc.cpp


Index: openmp/runtime/src/kmp_alloc.cpp
===================================================================
--- openmp/runtime/src/kmp_alloc.cpp
+++ openmp/runtime/src/kmp_alloc.cpp
@@ -1561,6 +1561,9 @@
   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 @@
 
     // 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) {


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D139376.480313.patch
Type: text/x-patch
Size: 1756 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20221206/d105fb28/attachment.bin>


More information about the Openmp-commits mailing list