Skip to content

Commit 2ae4e95

Browse files
authored
[flang][cuda] Add bind name for __ddiv_XX interfaces (#153271)
1 parent 60170f9 commit 2ae4e95

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

flang/module/cudadevice.f90

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -710,28 +710,28 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
710710
end interface
711711

712712
interface __ddiv_rn
713-
attributes(device) double precision function __ddiv_rn(x,y) bind(c)
713+
attributes(device) double precision function __ddiv_rn(x,y) bind(c, name='__nv_ddiv_rn')
714714
!dir$ ignore_tkr (d) x, (d) y
715715
double precision, value :: x, y
716716
end function
717717
end interface
718718

719719
interface __ddiv_rz
720-
attributes(device) double precision function __ddiv_rz(x,y) bind(c)
720+
attributes(device) double precision function __ddiv_rz(x,y) bind(c, name='__nv_ddiv_rz')
721721
!dir$ ignore_tkr (d) x, (d) y
722722
double precision, value :: x, y
723723
end function
724724
end interface
725725

726726
interface __ddiv_ru
727-
attributes(device) double precision function __ddiv_ru(x,y) bind(c)
727+
attributes(device) double precision function __ddiv_ru(x,y) bind(c, name='__nv_ddiv_ru')
728728
!dir$ ignore_tkr (d) x, (d) y
729729
double precision, value :: x, y
730730
end function
731731
end interface
732732

733733
interface __ddiv_rd
734-
attributes(device) double precision function __ddiv_rd(x,y) bind(c)
734+
attributes(device) double precision function __ddiv_rd(x,y) bind(c, name='__nv_ddiv_rd')
735735
!dir$ ignore_tkr (d) x, (d) y
736736
double precision, value :: x, y
737737
end function

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -61,9 +61,14 @@ attributes(global) subroutine devsub()
6161
res = __clz(ai)
6262
res = __clz(al)
6363
af = __cosf(af)
64+
ad = __ddiv_rn(ad, ad)
65+
ad = __ddiv_rz(ad, ad)
66+
ad = __ddiv_ru(ad, ad)
67+
ad = __ddiv_rd(ad, ad)
6468
ai = __mul24(ai, ai)
6569
ai = __umul24(ai, ai)
6670
af = __powf(af, af)
71+
6772
end
6873

6974
! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -113,6 +118,10 @@ end
113118
! CHECK: %{{.*}} = fir.call @__nv_clz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
114119
! CHECK: %{{.*}} = fir.call @__nv_clzll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
115120
! CHECK: %{{.*}} = fir.call @__nv_cosf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
121+
! CHECK: %{{.*}} = fir.call @__nv_ddiv_rn(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
122+
! CHECK: %{{.*}} = fir.call @__nv_ddiv_rz(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
123+
! CHECK: %{{.*}} = fir.call @__nv_ddiv_ru(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
124+
! CHECK: %{{.*}} = fir.call @__nv_ddiv_rd(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
116125
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
117126
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
118127
! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32

0 commit comments

Comments
 (0)