Run DCE after a LoopFlatten test to reduce spurious output [nfc]
[llvm-project.git] / openmp / libomptarget / test / offloading / fortran / basic_array.c
blob4daf1d4b0a998afec9c58812f32901058e40d43e
1 // Basic offloading test for function compiled with flang
2 // REQUIRES: flang, amdgcn-amd-amdhsa
4 // RUN: %flang -c -fopenmp -fopenmp-targets=amdgcn-amd-amdhsa \
5 // RUN: %S/../../Inputs/basic_array.f90 -o basic_array.o
6 // RUN: %libomptarget-compile-generic basic_array.o
7 // RUN: %t | %fcheck-generic
9 #include <stdio.h>
10 #define TEST_ARR_LEN 10
12 #pragma omp declare target
13 void increment_at(int i, int *array);
14 #pragma omp end declare target
16 void increment_array(int *b, int n) {
17 #pragma omp target map(tofrom : b [0:n])
18 for (int i = 0; i < n; i++) {
19 increment_at(i, b);
23 int main() {
24 int arr[TEST_ARR_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
26 increment_array(arr, TEST_ARR_LEN);
27 for (int i = 0; i < TEST_ARR_LEN; i++) {
28 printf("%d = %d\n", i, arr[i]);
31 return 0;
34 // CHECK: 0 = 1
35 // CHECK-NEXT: 1 = 2
36 // CHECK-NEXT: 2 = 3
37 // CHECK-NEXT: 3 = 4
38 // CHECK-NEXT: 4 = 5
39 // CHECK-NEXT: 5 = 6
40 // CHECK-NEXT: 6 = 7
41 // CHECK-NEXT: 7 = 8
42 // CHECK-NEXT: 8 = 9
43 // CHECK-NEXT: 9 = 10