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

interface int_as_float
attributes(device) real function __int_as_float(i) bind(c, name='__nv_int_as_float')
!dir$ ignore_tkr (d) i
integer, value :: i
end function
end interface

interface float_as_int
attributes(device) integer function __float_as_int(i) bind(c, name='__nv_float_as_int')
!dir$ ignore_tkr (d) i
real, value :: i
end function
end interface

interface __float2half_rn
attributes(device) real(2) function __float2half_rn(r) bind(c, name='__nv_float2half_rn')
!dir$ ignore_tkr (d) r
Expand Down
18 changes: 18 additions & 0 deletions flang/test/Lower/CUDA/cuda-libdevice.cuf
Original file line number Diff line number Diff line change
Expand Up @@ -244,3 +244,21 @@ end subroutine
! 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

attributes(global) subroutine test_int_as_float()
integer :: i
real :: res
res = int_as_float(i)
end subroutine

! CHECK-LABEL: _QPtest_int_as_float
! CHECK: %{{.*}} = fir.call @__nv_int_as_float(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32) -> f32

attributes(global) subroutine test_float_as_int()
integer :: res
real :: r
res = float_as_int(r)
end subroutine

! CHECK-LABEL: _QPtest_float_as_int
! CHECK: %{{.*}} = fir.call @__nv_float_as_int(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32