[Openmp-commits] [PATCH] D107181: [openmp] Do not use shared memory on Android

Pirama Arumuga Nainar via Phabricator via Openmp-commits openmp-commits at lists.llvm.org
Fri Jul 30 10:10:09 PDT 2021


pirama created this revision.
pirama added reviewers: AndreyChurbanov, srhines.
Herald added subscribers: danielkiss, guansong, krytarowski, yaxunl.
pirama requested review of this revision.
Herald added a reviewer: jdoerfert.
Herald added subscribers: openmp-commits, sstefan1.
Herald added a project: OpenMP.

Android provides ashmem/ASharedMemory support on newer releases, which
we can use if requested by openmp users on Android.


Repository:
  rG LLVM Github Monorepo

https://reviews.llvm.org/D107181

Files:
  openmp/runtime/src/kmp_runtime.cpp


Index: openmp/runtime/src/kmp_runtime.cpp
===================================================================
--- openmp/runtime/src/kmp_runtime.cpp
+++ openmp/runtime/src/kmp_runtime.cpp
@@ -6595,7 +6595,8 @@
 
     char *value = NULL; // Actual value of the environment variable.
 
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+#if KMP_OS_UNIX && KMP_DYNAMIC_LIB &&                                          \
+    !__ANDROID__ // shared memory is with dynamic library
     char *shm_name = __kmp_str_format("/%s", name);
     int shm_preexist = 0;
     char *data1;
@@ -6700,7 +6701,8 @@
       } break;
       case 2: { // Neighbor is dead.
 
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+#if KMP_OS_UNIX && KMP_DYNAMIC_LIB &&                                          \
+    !__ANDROID__ // shared memory is with dynamic library
         // close shared memory.
         shm_unlink(shm_name); // this removes file in /dev/shm
 #else
@@ -6714,7 +6716,8 @@
       }
     }
     KMP_INTERNAL_FREE((void *)value);
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+#if KMP_OS_UNIX && KMP_DYNAMIC_LIB &&                                          \
+    !__ANDROID__ // shared memory is with dynamic library
     KMP_INTERNAL_FREE((void *)shm_name);
 #endif
   } // while
@@ -6727,7 +6730,8 @@
   char *name = __kmp_reg_status_name();
   char *value = NULL;
 
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+#if KMP_OS_UNIX && KMP_DYNAMIC_LIB &&                                          \
+    !__ANDROID__ // shared memory is with dynamic library
   char *shm_name = __kmp_str_format("/%s", name);
   int fd1 = shm_open(shm_name, O_RDONLY, 0666);
   if (fd1 == -1) {
@@ -6748,14 +6752,16 @@
   KMP_DEBUG_ASSERT(__kmp_registration_str != NULL);
   if (value != NULL && strcmp(value, __kmp_registration_str) == 0) {
 //  Ok, this is our variable. Delete it.
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+#if KMP_OS_UNIX && KMP_DYNAMIC_LIB &&                                          \
+    !__ANDROID__ // shared memory is with dynamic library
     shm_unlink(shm_name); // this removes file in /dev/shm
 #else
     __kmp_env_unset(name);
 #endif
   }
 
-#if KMP_OS_UNIX && KMP_DYNAMIC_LIB // shared memory is with dynamic library
+#if KMP_OS_UNIX && KMP_DYNAMIC_LIB &&                                          \
+    !__ANDROID__ // shared memory is with dynamic library
   KMP_INTERNAL_FREE(shm_name);
 #endif
 


-------------- next part --------------
A non-text attachment was scrubbed...
Name: D107181.363133.patch
Type: text/x-patch
Size: 2562 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/openmp-commits/attachments/20210730/5f3fcdf3/attachment-0001.bin>


More information about the Openmp-commits mailing list