Skip to content
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
56 changes: 56 additions & 0 deletions flang/module/cudadevice.f90
Original file line number Diff line number Diff line change
Expand Up @@ -471,6 +471,62 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
end function
end interface

interface __float2int_rd
attributes(device) integer function __float2int_rd(r) bind(c, name='__nv_float2int_rd')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2int_rn
attributes(device) integer function __float2int_rn(r) bind(c, name='__nv_float2int_rn')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2int_ru
attributes(device) integer function __float2int_ru(r) bind(c, name='__nv_float2int_ru')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2int_rz
attributes(device) integer function __float2int_rz(r) bind(c, name='__nv_float2int_rz')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2uint_rd
attributes(device) integer function __float2uint_rd(r) bind(c, name='__nv_float2uint_rd')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2uint_rn
attributes(device) integer function __float2uint_rn(r) bind(c, name='__nv_float2uint_rn')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2uint_ru
attributes(device) integer function __float2uint_ru(r) bind(c, name='__nv_float2uint_ru')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2uint_rz
attributes(device) integer function __float2uint_rz(r) bind(c, name='__nv_float2uint_rz')
!dir$ ignore_tkr (d) r
real, value :: r
end function
end interface

interface __float2ll_rd
attributes(device) integer(8) function __float2ll_rd(r) bind(c, name='__nv_float2ll_rd')
!dir$ ignore_tkr (d) r
Expand Down
30 changes: 29 additions & 1 deletion flang/test/Lower/CUDA/cuda-libdevice.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,6 @@ end subroutine
! CHECK: %{{.*}} = fir.call @__nv_double2ll_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64


attributes(global) subroutine test_drcp_rX()
double precision :: res
double precision :: r
Expand Down Expand Up @@ -191,3 +190,32 @@ end subroutine
! CHECK: %{{.*}} = fir.call @__nv_ll2float_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
! CHECK: %{{.*}} = fir.call @__nv_ll2float_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
! CHECK: %{{.*}} = fir.call @__nv_ll2float_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
attributes(global) subroutine test_float2int_rX()
integer :: res
real :: r
res = __float2int_rd(r)
res = __float2int_rn(r)
res = __float2int_ru(r)
res = __float2int_rz(r)
end subroutine

! CHECK-LABEL: _QPtest_float2int_rx
! CHECK: %{{.*}} = fir.call @__nv_float2int_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_float2int_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_float2int_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_float2int_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32

attributes(global) subroutine test_float2uint_rX()
integer :: res
real :: r
res = __float2uint_rd(r)
res = __float2uint_rn(r)
res = __float2uint_ru(r)
res = __float2uint_rz(r)
end subroutine

! CHECK-LABEL: _QPtest_float2uint_rx
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
! 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