Skip to content

Commit 0e8c964

Browse files
authored
[flang][cuda] Add interfaces for double_as_longlong and longlong_as_double (#153719)
1 parent bc77363 commit 0e8c964

File tree

2 files changed

+32
-0
lines changed

2 files changed

+32
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -583,6 +583,20 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
583583
end function
584584
end interface
585585

586+
interface double_as_longlong
587+
attributes(device) integer(8) function __double_as_longlong(i) bind(c, name='__nv_double_as_longlong')
588+
!dir$ ignore_tkr (d) i
589+
real(8), value :: i
590+
end function
591+
end interface
592+
593+
interface longlong_as_double
594+
attributes(device) real(8) function __longlong_as_double(i) bind(c, name='__nv_longlong_as_double')
595+
!dir$ ignore_tkr (d) i
596+
integer(8), value :: i
597+
end function
598+
end interface
599+
586600
interface __double2int_rd
587601
attributes(device) integer function __double2int_rd(r) bind(c, name='__nv_double2int_rd')
588602
!dir$ ignore_tkr (d) r

flang/test/Lower/CUDA/cuda-libdevice.cuf

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -245,6 +245,24 @@ end subroutine
245245
! CHECK: %{{.*}} = fir.call @__nv_float2uint_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
246246
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
247247

248+
attributes(global) subroutine test_double_as_longlong()
249+
integer(8) :: res
250+
real(8) :: r
251+
res = double_as_longlong(r)
252+
end subroutine
253+
254+
! CHECK-LABEL: _QPtest_double_as_longlong
255+
! CHECK: %{{.*}} = fir.call @__nv_double_as_longlong(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
256+
257+
attributes(global) subroutine test_longlong_as_double()
258+
integer(8) :: i
259+
real(8) :: res
260+
res = longlong_as_double(i)
261+
end subroutine
262+
263+
! CHECK-LABEL: _QPtest_longlong_as_double
264+
! CHECK: %{{.*}} = fir.call @__nv_longlong_as_double(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f64
265+
248266
attributes(global) subroutine test_int_as_float()
249267
integer :: i
250268
real :: res

0 commit comments

Comments
 (0)