Skip to content

[flang][cuda] Add bind name for __double2float_XX interfaces #153275

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 3 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 @@ -507,28 +507,28 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
end interface

interface __double2float_rn
attributes(device) real function __double2float_rn(r) bind(c)
attributes(device) real function __double2float_rn(r) bind(c, name='__nv_double2float_rn')
!dir$ ignore_tkr (d) r
double precision, value :: r
end function
end interface

interface __double2float_rz
attributes(device) real function __double2float_rz(r) bind(c)
attributes(device) real function __double2float_rz(r) bind(c, name='__nv_double2float_rz')
!dir$ ignore_tkr (d) r
double precision, value :: r
end function
end interface

interface __double2float_ru
attributes(device) real function __double2float_ru(r) bind(c)
attributes(device) real function __double2float_ru(r) bind(c, name='__nv_double2float_ru')
!dir$ ignore_tkr (d) r
double precision, value :: r
end function
end interface

interface __double2float_rd
attributes(device) real function __double2float_rd(r) bind(c)
attributes(device) real function __double2float_rd(r) bind(c, name='__nv_double2float_rd')
!dir$ ignore_tkr (d) r
double precision, value :: r
end function
Expand Down
9 changes: 8 additions & 1 deletion flang/test/Lower/CUDA/cuda-device-proc.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,13 @@ attributes(global) subroutine devsub()
ad = __ddiv_rz(ad, ad)
ad = __ddiv_ru(ad, ad)
ad = __ddiv_rd(ad, ad)
af = __double2float_rn(ad)
af = __double2float_rz(ad)
af = __double2float_ru(ad)
af = __double2float_rd(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 @@ -122,6 +125,10 @@ end
! 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_double2float_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f32
! CHECK: %{{.*}} = fir.call @__nv_double2float_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f32
! CHECK: %{{.*}} = fir.call @__nv_double2float_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f32
! CHECK: %{{.*}} = fir.call @__nv_double2float_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f32
! 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