Skip to content

Commit df15c0d

Browse files
authored
[flang][cuda] Add interfaces for __dsqrt_rn and __dsqrt_rz (#153624)
1 parent cb2f0d0 commit df15c0d

File tree

3 files changed

+29
-5
lines changed

3 files changed

+29
-5
lines changed

flang/module/cudadevice.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -814,13 +814,27 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
814814
end function
815815
end interface
816816

817+
interface __dsqrt_rn
818+
attributes(device) double precision function __dsqrt_rn(x) bind(c, name='__nv_dsqrt_rn')
819+
!dir$ ignore_tkr (d) x
820+
double precision, value :: x
821+
end function
822+
end interface
823+
817824
interface __dsqrt_ru
818825
attributes(device) double precision function __dsqrt_ru(x) bind(c, name='__nv_dsqrt_ru')
819826
!dir$ ignore_tkr (d) x
820827
double precision, value :: x
821828
end function
822829
end interface
823830

831+
interface __dsqrt_rz
832+
attributes(device) double precision function __dsqrt_rz(x) bind(c, name='__nv_dsqrt_rz')
833+
!dir$ ignore_tkr (d) x
834+
double precision, value :: x
835+
end function
836+
end interface
837+
824838
interface __ddiv_rn
825839
attributes(device) double precision function __ddiv_rn(x,y) bind(c, name='__nv_ddiv_rn')
826840
!dir$ ignore_tkr (d) x, (d) y

flang/test/Lower/CUDA/cuda-device-proc.cuf

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,8 +82,6 @@ attributes(global) subroutine devsub()
8282
ai = __mul24(ai, ai)
8383
ai = __umul24(ai, ai)
8484
af = __powf(af, af)
85-
ad = __dsqrt_rd(ad)
86-
ad = __dsqrt_ru(ad)
8785
ad = __ull2double_rd(al)
8886
ad = __ull2double_rn(al)
8987
ad = __ull2double_ru(al)
@@ -162,8 +160,6 @@ end
162160
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
163161
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
164162
! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32
165-
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
166-
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
167163
! CHECK: %{{.*}} = fir.call @__nv_ull2double_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f64
168164
! CHECK: %{{.*}} = fir.call @__nv_ull2double_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f64
169165
! CHECK: %{{.*}} = fir.call @__nv_ull2double_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f64

flang/test/Lower/CUDA/cuda-libdevice.cuf

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,21 @@ end subroutine
2020
! CHECK-LABEL: _QPtest_usad
2121
! CHECK: %{{.*}} = fir.call @__nv_usad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32, i32) -> i32
2222

23+
attributes(global) subroutine test_dsqrt_rX()
24+
double precision :: res
25+
double precision :: p
26+
res = __dsqrt_rd(p)
27+
res = __dsqrt_rn(p)
28+
res = __dsqrt_ru(p)
29+
res = __dsqrt_rz(p)
30+
end subroutine
31+
32+
! CHECK-LABEL: _QPtest_dsqrt_rx
33+
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
34+
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
35+
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
36+
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
37+
2338
attributes(global) subroutine test_uint2float_rX()
2439
real :: res
2540
integer :: i
@@ -146,4 +161,3 @@ end subroutine
146161
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
147162
! CHECK: %{{.*}} = fir.call @__nv_double2ull_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
148163
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
149-

0 commit comments

Comments
 (0)