Skip to content

Commit 5c40133

Browse files
authored
[flang][cuda] Add bind name for __dsqrt_rd and __dsqrt_ru interfaces (#153290)
1 parent 059e49c commit 5c40133

File tree

2 files changed

+8
-4
lines changed

2 files changed

+8
-4
lines changed

flang/module/cudadevice.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -695,15 +695,15 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
695695
end function
696696
end interface
697697

698-
interface __dsqrt_ru
699-
attributes(device) double precision function __dsqrt_ru(x) bind(c)
698+
interface __dsqrt_rd
699+
attributes(device) double precision function __dsqrt_rd(x) bind(c, name='__nv_dsqrt_rd')
700700
!dir$ ignore_tkr (d) x
701701
double precision, value :: x
702702
end function
703703
end interface
704704

705-
interface __dsqrt_rd
706-
attributes(device) double precision function __dsqrt_rd(x) bind(c)
705+
interface __dsqrt_ru
706+
attributes(device) double precision function __dsqrt_ru(x) bind(c, name='__nv_dsqrt_ru')
707707
!dir$ ignore_tkr (d) x
708708
double precision, value :: x
709709
end function

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,8 @@ attributes(global) subroutine devsub()
7777
ai = __mul24(ai, ai)
7878
ai = __umul24(ai, ai)
7979
af = __powf(af, af)
80+
ad = __dsqrt_rd(ad)
81+
ad = __dsqrt_ru(ad)
8082
end
8183

8284
! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -141,6 +143,8 @@ end
141143
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
142144
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
143145
! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32
146+
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
147+
! CHECK: %{{.*}} = fir.call @__nv_dsqrt_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
144148

145149
subroutine host1()
146150
integer, device :: a(32)

0 commit comments

Comments
 (0)