Skip to content

Commit b989c7c

Browse files
authored
[flang][cuda] Add interfaces for __drcp_rX (#153681)
1 parent 4e63d70 commit b989c7c

File tree

2 files changed

+45
-0
lines changed

2 files changed

+45
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -779,6 +779,34 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
779779
end function
780780
end interface
781781

782+
interface __drcp_rd
783+
attributes(device) double precision function __drcp_rd(x) bind(c, name='__nv_drcp_rd')
784+
!dir$ ignore_tkr (d) x
785+
double precision, value :: x
786+
end function
787+
end interface
788+
789+
interface __drcp_rn
790+
attributes(device) double precision function __drcp_rn(x) bind(c, name='__nv_drcp_rn')
791+
!dir$ ignore_tkr (d) x
792+
double precision, value :: x
793+
end function
794+
end interface
795+
796+
interface __drcp_ru
797+
attributes(device) double precision function __drcp_ru(x) bind(c, name='__nv_drcp_ru')
798+
!dir$ ignore_tkr (d) x
799+
double precision, value :: x
800+
end function
801+
end interface
802+
803+
interface __drcp_rz
804+
attributes(device) double precision function __drcp_rz(x) bind(c, name='__nv_drcp_rz')
805+
!dir$ ignore_tkr (d) x
806+
double precision, value :: x
807+
end function
808+
end interface
809+
782810
interface __dsqrt_rd
783811
attributes(device) double precision function __dsqrt_rd(x) bind(c, name='__nv_dsqrt_rd')
784812
!dir$ ignore_tkr (d) x

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

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,22 @@ end subroutine
116116
! CHECK: %{{.*}} = fir.call @__nv_double2ll_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
117117
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
118118

119+
120+
attributes(global) subroutine test_drcp_rX()
121+
double precision :: res
122+
double precision :: r
123+
res = __drcp_rd(r)
124+
res = __drcp_rn(r)
125+
res = __drcp_ru(r)
126+
res = __drcp_rz(r)
127+
end subroutine
128+
129+
! CHECK-LABEL: _QPtest_drcp_rx
130+
! CHECK: %{{.*}} = fir.call @__nv_drcp_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
131+
! CHECK: %{{.*}} = fir.call @__nv_drcp_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
132+
! CHECK: %{{.*}} = fir.call @__nv_drcp_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
133+
! CHECK: %{{.*}} = fir.call @__nv_drcp_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
134+
119135
attributes(global) subroutine test_double2ull_rX()
120136
integer(8) :: res
121137
double precision :: r
@@ -130,3 +146,4 @@ end subroutine
130146
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
131147
! CHECK: %{{.*}} = fir.call @__nv_double2ull_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
132148
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
149+

0 commit comments

Comments
 (0)