brintos

brintos / llvm-project-archived public Read only

0
0
Text · 882 B · a400349 Raw
38 lines · c
1// RUN: %libomptarget-compile-generic -fopenmp-version=512// RUN: %libomptarget-run-generic | %fcheck-generic3// RUN: %libomptarget-compileopt-generic -fopenmp-version=514// RUN: %libomptarget-run-generic | %fcheck-generic5 6#include <stdio.h>7 8int square(int x) { return x * x; }9#pragma omp declare target indirect to(square)10 11typedef int (*fp_t)(int);12 13int main() {14  int i = 17, r;15 16  fp_t fp = &square;17  // CHECK: host: &square =18  printf("host: &square = %p\n", fp);19 20#pragma omp target map(from : fp)21  fp = &square;22  // CHECK: device: &square = [[DEV_FP:.*]]23  printf("device: &square = %p\n", fp);24 25  fp_t fp1 = square;26  fp_t fp2 = 0;27#pragma omp target map(from : fp2)28  fp2 = fp1;29  // CHECK: device: fp2 = [[DEV_FP]]30  printf("device: fp2 = %p\n", fp2);31 32#pragma omp target map(from : r)33  { r = fp1(i); }34 35  // CHECK: 17*17 = 28936  printf("%i*%i = %i\n", i, i, r);37}38