Skip to content

[flang][cuda] Add bind name for __ddiv_XX interfaces #153271

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 13, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -710,28 +710,28 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
end interface

interface __ddiv_rn
attributes(device) double precision function __ddiv_rn(x,y) bind(c)
attributes(device) double precision function __ddiv_rn(x,y) bind(c, name='__nv_ddiv_rn')
!dir$ ignore_tkr (d) x, (d) y
double precision, value :: x, y
end function
end interface

interface __ddiv_rz
attributes(device) double precision function __ddiv_rz(x,y) bind(c)
attributes(device) double precision function __ddiv_rz(x,y) bind(c, name='__nv_ddiv_rz')
!dir$ ignore_tkr (d) x, (d) y
double precision, value :: x, y
end function
end interface

interface __ddiv_ru
attributes(device) double precision function __ddiv_ru(x,y) bind(c)
attributes(device) double precision function __ddiv_ru(x,y) bind(c, name='__nv_ddiv_ru')
!dir$ ignore_tkr (d) x, (d) y
double precision, value :: x, y
end function
end interface

interface __ddiv_rd
attributes(device) double precision function __ddiv_rd(x,y) bind(c)
attributes(device) double precision function __ddiv_rd(x,y) bind(c, name='__nv_ddiv_rd')
!dir$ ignore_tkr (d) x, (d) y
double precision, value :: x, y
end function
Expand Down
9 changes: 9 additions & 0 deletions flang/test/Lower/CUDA/cuda-device-proc.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -61,9 +61,14 @@ attributes(global) subroutine devsub()
res = __clz(ai)
res = __clz(al)
af = __cosf(af)
ad = __ddiv_rn(ad, ad)
ad = __ddiv_rz(ad, ad)
ad = __ddiv_ru(ad, ad)
ad = __ddiv_rd(ad, ad)
ai = __mul24(ai, ai)
ai = __umul24(ai, ai)
af = __powf(af, af)

end

! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
Expand Down Expand Up @@ -113,6 +118,10 @@ end
! CHECK: %{{.*}} = fir.call @__nv_clz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_clzll(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> i32
! CHECK: %{{.*}} = fir.call @__nv_cosf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
! CHECK: %{{.*}} = fir.call @__nv_ddiv_rn(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
! CHECK: %{{.*}} = fir.call @__nv_ddiv_rz(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
! CHECK: %{{.*}} = fir.call @__nv_ddiv_ru(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
! CHECK: %{{.*}} = fir.call @__nv_ddiv_rd(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64, f64) -> f64
! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32
Expand Down