[flang][cuda] Add interfaces for double_as_longlong and longlong_as_double (#153719)

This commit is contained in:
Valentin Clement (バレンタイン クレメン) 2025-08-15 10:26:11 -07:00 committed by GitHub
parent bc77363235
commit 0e8c964c21
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 32 additions and 0 deletions

View File

@ -583,6 +583,20 @@ implicit none
end function
end interface
interface double_as_longlong
attributes(device) integer(8) function __double_as_longlong(i) bind(c, name='__nv_double_as_longlong')
!dir$ ignore_tkr (d) i
real(8), value :: i
end function
end interface
interface longlong_as_double
attributes(device) real(8) function __longlong_as_double(i) bind(c, name='__nv_longlong_as_double')
!dir$ ignore_tkr (d) i
integer(8), value :: i
end function
end interface
interface __double2int_rd
attributes(device) integer function __double2int_rd(r) bind(c, name='__nv_double2int_rd')
!dir$ ignore_tkr (d) r

View File

@ -245,6 +245,24 @@ end subroutine
! CHECK: %{{.*}} = fir.call @__nv_float2uint_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
attributes(global) subroutine test_double_as_longlong()
integer(8) :: res
real(8) :: r
res = double_as_longlong(r)
end subroutine
! CHECK-LABEL: _QPtest_double_as_longlong
! CHECK: %{{.*}} = fir.call @__nv_double_as_longlong(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
attributes(global) subroutine test_longlong_as_double()
integer(8) :: i
real(8) :: res
res = longlong_as_double(i)
end subroutine
! CHECK-LABEL: _QPtest_longlong_as_double
! CHECK: %{{.*}} = fir.call @__nv_longlong_as_double(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f64
attributes(global) subroutine test_int_as_float()
integer :: i
real :: res