File: amdgcn_openmp_device_math.c

package info (click to toggle)
llvm-toolchain-14 1%3A14.0.6-20
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,496,436 kB
  • sloc: cpp: 5,593,990; ansic: 986,873; asm: 585,869; python: 184,223; objc: 72,530; lisp: 31,119; f90: 27,793; javascript: 9,780; pascal: 9,762; sh: 9,482; perl: 7,468; ml: 5,432; awk: 3,523; makefile: 2,547; xml: 953; cs: 573; fortran: 567
file content (51 lines) | stat: -rw-r--r-- 2,345 bytes parent folder | download | duplicates (6)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-C,CHECK
// RUN: %clang_cc1 -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm-bc %s -o %t-host.bc
// RUN: %clang_cc1 -internal-isystem %S/../../lib/Headers/openmp_wrappers -include __clang_openmp_device_functions.h -internal-isystem %S/../../lib/Headers/openmp_wrappers -internal-isystem %S/Inputs/include -x c++ -fopenmp -triple amdgcn-amd-amdhsa -aux-triple x86_64-unknown-unknown -fopenmp-targets=amdgcn-amd-amdhsa -emit-llvm %s -fopenmp-is-device -fopenmp-host-ir-file-path %t-host.bc -o - | FileCheck %s --check-prefixes=CHECK-CPP,CHECK

#ifdef __cplusplus
#include <cmath>
#else
#include <math.h>
#endif

void test_math_f64(double x) {
// CHECK-LABEL: define {{.*}}test_math_f64
#pragma omp target
  {
    // CHECK: call double @__ocml_sin_f64
    double l1 = sin(x);
    // CHECK: call double @__ocml_cos_f64
    double l2 = cos(x);
    // CHECK: call double @__ocml_fabs_f64
    double l3 = fabs(x);
  }
}

void test_math_f32(float x) {
// CHECK-LABEL: define {{.*}}test_math_f32
#pragma omp target
  {
    // CHECK-C: call double @__ocml_sin_f64
    // CHECK-CPP: call float @__ocml_sin_f32
    float l1 = sin(x);
    // CHECK-C: call double @__ocml_cos_f64
    // CHECK-CPP: call float @__ocml_cos_f32
    float l2 = cos(x);
    // CHECK-C: call double @__ocml_fabs_f64
    // CHECK-CPP: call float @__ocml_fabs_f32
    float l3 = fabs(x);
  }
}
void test_math_f32_suffix(float x) {
// CHECK-LABEL: define {{.*}}test_math_f32_suffix
#pragma omp target
  {
    // CHECK: call float @__ocml_sin_f32
    float l1 = sinf(x);
    // CHECK: call float @__ocml_cos_f32
    float l2 = cosf(x);
    // CHECK: call float @__ocml_fabs_f32
    float l3 = fabsf(x);
  }
}