xref: /llvm-project/flang/test/Lower/OpenMP/math-amdgpu.f90 (revision 4290e34ebdddaa62210745c84ac3e6703cadfa34)
1!REQUIRES: amdgpu-registered-target
2!RUN: %flang_fc1 -triple amdgcn-amd-amdhsa -emit-llvm -fopenmp -fopenmp-is-target-device %s -o - | FileCheck %s
3
4subroutine omp_pow_f32(x, y)
5!$omp declare target
6  real :: x, y
7!CHECK: call float @__ocml_pow_f32(float {{.*}}, float {{.*}})
8  y = x ** x
9end subroutine omp_pow_f32
10
11subroutine omp_pow_f64(x, y)
12!$omp declare target
13  real(8) :: x, y
14!CHECK: call double @__ocml_pow_f64(double {{.*}}, double {{.*}})
15  y = x ** x
16end subroutine omp_pow_f64
17
18subroutine omp_sin_f32(x, y)
19!$omp declare target
20  real :: x, y
21!CHECK: call float @__ocml_sin_f32(float {{.*}})
22  y = sin(x)
23end subroutine omp_sin_f32
24
25subroutine omp_sin_f64(x, y)
26!$omp declare target
27  real(8) :: x, y
28!CHECK: call double @__ocml_sin_f64(double {{.*}})
29  y = sin(x)
30end subroutine omp_sin_f64
31
32subroutine omp_abs_f32(x, y)
33!$omp declare target
34  real :: x, y
35!CHECK: call contract float @llvm.fabs.f32(float {{.*}})
36  y = abs(x)
37end subroutine omp_abs_f32
38
39subroutine omp_abs_f64(x, y)
40!$omp declare target
41  real(8) :: x, y
42!CHECK: call contract double @llvm.fabs.f64(double {{.*}})
43  y = abs(x)
44end subroutine omp_abs_f64
45
46subroutine omp_atan_f32(x, y)
47!$omp declare target
48  real :: x, y
49!CHECK: call float @__ocml_atan_f32(float {{.*}})
50  y = atan(x)
51end subroutine omp_atan_f32
52
53subroutine omp_atan_f64(x, y)
54!$omp declare target
55  real(8) :: x, y
56!CHECK: call double @__ocml_atan_f64(double {{.*}})
57  y = atan(x)
58end subroutine omp_atan_f64
59
60subroutine omp_atan2_f32(x, y)
61!$omp declare target
62  real :: x, y
63!CHECK: call float @__ocml_atan2_f32(float {{.*}}, float {{.*}})
64  y = atan2(x, x)
65end subroutine omp_atan2_f32
66
67subroutine omp_atan2_f64(x, y)
68!$omp declare target
69  real(8) :: x, y
70!CHECK: call double @__ocml_atan2_f64(double {{.*}}, double {{.*}})
71  y = atan2(x ,x)
72end subroutine omp_atan2_f64
73
74subroutine omp_cos_f32(x, y)
75!$omp declare target
76  real :: x, y
77!CHECK: call float @__ocml_cos_f32(float {{.*}})
78  y = cos(x)
79end subroutine omp_cos_f32
80
81subroutine omp_cos_f64(x, y)
82!$omp declare target
83  real(8) :: x, y
84!CHECK: call double @__ocml_cos_f64(double {{.*}})
85  y = cos(x)
86end subroutine omp_cos_f64
87
88subroutine omp_erf_f32(x, y)
89!$omp declare target
90  real :: x, y
91!CHECK: call float @__ocml_erf_f32(float {{.*}})
92  y = erf(x)
93end subroutine omp_erf_f32
94
95subroutine omp_erf_f64(x, y)
96!$omp declare target
97  real(8) :: x, y
98!CHECK: call double @__ocml_erf_f64(double {{.*}})
99  y = erf(x)
100end subroutine omp_erf_f64
101
102subroutine omp_exp_f32(x, y)
103!$omp declare target
104  real :: x, y
105!CHECK: call contract float @llvm.exp.f32(float {{.*}})
106  y = exp(x)
107end subroutine omp_exp_f32
108
109subroutine omp_exp_f64(x, y)
110!$omp declare target
111  real(8) :: x, y
112!CHECK: call double @__ocml_exp_f64(double {{.*}})
113  y = exp(x)
114end subroutine omp_exp_f64
115
116subroutine omp_log_f32(x, y)
117!$omp declare target
118  real :: x, y
119!CHECK: call contract float @llvm.log.f32(float {{.*}})
120  y = log(x)
121end subroutine omp_log_f32
122
123subroutine omp_log_f64(x, y)
124!$omp declare target
125  real(8) :: x, y
126!CHECK: call double @__ocml_log_f64(double {{.*}})
127  y = log(x)
128end subroutine omp_log_f64
129
130subroutine omp_log10_f32(x, y)
131!$omp declare target
132  real :: x, y
133!CHECK: call float @__ocml_log10_f32(float {{.*}})
134  y = log10(x)
135end subroutine omp_log10_f32
136
137subroutine omp_log10_f64(x, y)
138!$omp declare target
139  real(8) :: x, y
140!CHECK: call double @__ocml_log10_f64(double {{.*}})
141  y = log10(x)
142end subroutine omp_log10_f64
143
144subroutine omp_sqrt_f32(x, y)
145!$omp declare target
146  real :: x, y
147!CHECK: call contract float @llvm.sqrt.f32(float {{.*}})
148  y = sqrt(x)
149end subroutine omp_sqrt_f32
150
151subroutine omp_sqrt_f64(x, y)
152!$omp declare target
153  real(8) :: x, y
154!CHECK: call contract double @llvm.sqrt.f64(double {{.*}})
155  y = sqrt(x)
156end subroutine omp_sqrt_f64
157
158subroutine omp_tan_f32(x, y)
159!$omp declare target
160  real :: x, y
161!CHECK: call float @__ocml_tan_f32(float {{.*}})
162  y = tan(x)
163end subroutine omp_tan_f32
164
165subroutine omp_tan_f64(x, y)
166!$omp declare target
167  real(8) :: x, y
168!CHECK: call double @__ocml_tan_f64(double {{.*}})
169  y = tan(x)
170end subroutine omp_tan_f64
171
172subroutine omp_tanh_f32(x, y)
173!$omp declare target
174  real :: x, y
175!CHECK: call float @__ocml_tanh_f32(float {{.*}})
176  y = tanh(x)
177end subroutine omp_tanh_f32
178
179subroutine omp_tanh_f64(x, y)
180!$omp declare target
181  real(8) :: x, y
182!CHECK: call double @__ocml_tanh_f64(double {{.*}})
183  y = tanh(x)
184end subroutine omp_tanh_f64
185