Skip to content

Commit

Permalink
[OpenMP] Reduce the size of heap memory required by the test `malloc_…
Browse files Browse the repository at this point in the history
…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.
  • Loading branch information
shiltian committed Dec 20, 2023
1 parent 39f09ec commit 7e4c6f6
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
8 changes: 4 additions & 4 deletions openmp/libomptarget/test/offloading/malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -31,7 +31,7 @@ int main() {
}
}

// CHECK: Sum: 203458478080
// CHECK: Sum: 6860800
printf("Sum: %li\n", s);
return 0;
}
8 changes: 4 additions & 4 deletions openmp/libomptarget/test/offloading/malloc_parallel.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -36,7 +36,7 @@ int main() {
}
}

// CHECK: Sum: 203458478080
// CHECK: Sum: 6860800
printf("Sum: %li\n", s);
return 0;
}

0 comments on commit 7e4c6f6

Please sign in to comment.