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

Shilei Tian via Openmp-commits openmp-commits at lists.llvm.org
Mon Dec 18 18:14:42 PST 2023


https://github.com/shiltian created https://github.com/llvm/llvm-project/pull/75885

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


>From 49e1b8c3240214d8e144d25572797c25a8b37df8 Mon Sep 17 00:00:00 2001
From: Shilei Tian <i at tianshilei.me>
Date: Mon, 18 Dec 2023 21:14:23 -0500
Subject: [PATCH] [OpenMP] Reduce the size of heap memory required by the test
 `malloc_parallel.c`

This patch reduces the size of heap memory required by the test
`malloc_parallel.c`. The original size is too large such that `malloc` returns
`nullptr` on many threads, causing illegal memory access.
---
 openmp/libomptarget/test/offloading/malloc_parallel.c | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/openmp/libomptarget/test/offloading/malloc_parallel.c b/openmp/libomptarget/test/offloading/malloc_parallel.c
index 4908e00694d99e..cc767e12fa8db7 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 = 8;
 
 #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: 4440064
   printf("Sum: %li\n", s);
   return 0;
 }



More information about the Openmp-commits mailing list