1// Basic offloading test for function compiled with flang
2// REQUIRES: flang, amdgcn-amd-amdhsa
3
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
8
9#include <stdio.h>
10#define TEST_ARR_LEN 10
11
12#pragma omp declare target
13void increment_at(int i, int *array);
14#pragma omp end declare target
15
16void 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, array: b);
20 }
21}
22
23int main() {
24 int arr[TEST_ARR_LEN] = {0, 1, 2, 3, 4, 5, 6, 7, 8, 9};
25
26 increment_array(b: arr, TEST_ARR_LEN);
27 for (int i = 0; i < TEST_ARR_LEN; i++) {
28 printf(format: "%d = %d\n", i, arr[i]);
29 }
30
31 return 0;
32}
33
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
44

source code of offload/test/offloading/fortran/basic_array.c