Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / test / offloading / malloc_parallel.c
blob4908e00694d99e0a3c41e264aa72d114565c059e
1 // RUN: %libomptarget-compile-run-and-check-generic
2 // RUN: %libomptarget-compileopt-run-and-check-generic
4 #include <omp.h>
5 #include <stdio.h>
6 #include <stdlib.h>
8 int main() {
9 long unsigned **DP = 0;
10 int N = 128;
11 int Threads = 128;
12 int Teams = 440;
14 #pragma omp target map(from : DP)
15 DP = (long unsigned **)malloc(sizeof(long unsigned *) * Threads * Teams);
17 #pragma omp target teams distribute parallel for num_teams(Teams) \
18 thread_limit(Threads)
19 for (int i = 0; i < Threads * Teams; ++i)
20 DP[i] = (long unsigned *)malloc(sizeof(long unsigned) * N);
22 #pragma omp target teams distribute parallel for num_teams(Teams) \
23 thread_limit(Threads)
24 for (int i = 0; i < Threads * Teams; ++i) {
25 for (int j = 0; j < N; ++j) {
26 DP[i][j] = i + j;
30 long unsigned s = 0;
31 #pragma omp target teams distribute parallel for num_teams(Teams) \
32 thread_limit(Threads) reduction(+ : s)
33 for (int i = 0; i < Threads * Teams; ++i) {
34 for (int j = 0; j < N; ++j) {
35 s += DP[i][j];
39 // CHECK: Sum: 203458478080
40 printf("Sum: %li\n", s);
41 return 0;