[Openmp-commits] [openmp] 7e4c6f6 - [OpenMP] Reduce the size of heap memory required by the test `malloc_parallel.c` (#75885)

via Openmp-commits openmp-commits at lists.llvm.org
Wed Dec 20 15:03:05 PST 2023


Author: Shilei Tian
Date: 2023-12-20T15:03:01-08:00
New Revision: 7e4c6f6cb2e17ee186c9525e59218de0b2277799

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

LOG: [OpenMP] Reduce the size of heap memory required by the test `malloc_parallel.c` (#75885)

This patch reduces the size of heap memory required by the test
`malloc_parallel.c` and `malloc.c`. The original size is too large such
that `malloc` returns `nullptr` on many threads, causing illegal
memory access.

Added: 
    

Modified: 
    openmp/libomptarget/test/offloading/malloc.c
    openmp/libomptarget/test/offloading/malloc_parallel.c

Removed: 
    


################################################################################
diff  --git a/openmp/libomptarget/test/offloading/malloc.c b/openmp/libomptarget/test/offloading/malloc.c
index ad49ace2006256..7b98e1f1110e5b 100644
--- a/openmp/libomptarget/test/offloading/malloc.c
+++ b/openmp/libomptarget/test/offloading/malloc.c
@@ -6,9 +6,9 @@
 
 int main() {
   long unsigned *DP = 0;
-  int N = 128;
-  int Threads = 128;
-  int Teams = 440;
+  int N = 32;
+  int Threads = 64;
+  int Teams = 10;
 
   // Allocate ~55MB on the device.
 #pragma omp target map(from : DP)
@@ -31,7 +31,7 @@ int main() {
     }
   }
 
-  // CHECK: Sum: 203458478080
+  // CHECK: Sum: 6860800
   printf("Sum: %li\n", s);
   return 0;
 }

diff  --git a/openmp/libomptarget/test/offloading/malloc_parallel.c b/openmp/libomptarget/test/offloading/malloc_parallel.c
index 4908e00694d99e..076a7ba397a3c6 100644
--- a/openmp/libomptarget/test/offloading/malloc_parallel.c
+++ b/openmp/libomptarget/test/offloading/malloc_parallel.c
@@ -7,9 +7,9 @@
 
 int main() {
   long unsigned **DP = 0;
-  int N = 128;
-  int Threads = 128;
-  int Teams = 440;
+  int N = 32;
+  int Threads = 64;
+  int Teams = 10;
 
 #pragma omp target map(from : DP)
   DP = (long unsigned **)malloc(sizeof(long unsigned *) * Threads * Teams);
@@ -36,7 +36,7 @@ int main() {
     }
   }
 
-  // CHECK: Sum: 203458478080
+  // CHECK: Sum: 6860800
   printf("Sum: %li\n", s);
   return 0;
 }


        


More information about the Openmp-commits mailing list