Skip to content

Commit ffe4870

Browse files
authored
[flang][cuda] Add interfaces for __float2int_rX and __float2unit_rX (#153691)
1 parent 47bc6ac commit ffe4870

File tree

2 files changed

+85
-1
lines changed

2 files changed

+85
-1
lines changed

flang/module/cudadevice.f90

Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,62 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
478478
end function
479479
end interface
480480

481+
interface __float2int_rd
482+
attributes(device) integer function __float2int_rd(r) bind(c, name='__nv_float2int_rd')
483+
!dir$ ignore_tkr (d) r
484+
real, value :: r
485+
end function
486+
end interface
487+
488+
interface __float2int_rn
489+
attributes(device) integer function __float2int_rn(r) bind(c, name='__nv_float2int_rn')
490+
!dir$ ignore_tkr (d) r
491+
real, value :: r
492+
end function
493+
end interface
494+
495+
interface __float2int_ru
496+
attributes(device) integer function __float2int_ru(r) bind(c, name='__nv_float2int_ru')
497+
!dir$ ignore_tkr (d) r
498+
real, value :: r
499+
end function
500+
end interface
501+
502+
interface __float2int_rz
503+
attributes(device) integer function __float2int_rz(r) bind(c, name='__nv_float2int_rz')
504+
!dir$ ignore_tkr (d) r
505+
real, value :: r
506+
end function
507+
end interface
508+
509+
interface __float2uint_rd
510+
attributes(device) integer function __float2uint_rd(r) bind(c, name='__nv_float2uint_rd')
511+
!dir$ ignore_tkr (d) r
512+
real, value :: r
513+
end function
514+
end interface
515+
516+
interface __float2uint_rn
517+
attributes(device) integer function __float2uint_rn(r) bind(c, name='__nv_float2uint_rn')
518+
!dir$ ignore_tkr (d) r
519+
real, value :: r
520+
end function
521+
end interface
522+
523+
interface __float2uint_ru
524+
attributes(device) integer function __float2uint_ru(r) bind(c, name='__nv_float2uint_ru')
525+
!dir$ ignore_tkr (d) r
526+
real, value :: r
527+
end function
528+
end interface
529+
530+
interface __float2uint_rz
531+
attributes(device) integer function __float2uint_rz(r) bind(c, name='__nv_float2uint_rz')
532+
!dir$ ignore_tkr (d) r
533+
real, value :: r
534+
end function
535+
end interface
536+
481537
interface __float2ll_rd
482538
attributes(device) integer(8) function __float2ll_rd(r) bind(c, name='__nv_float2ll_rd')
483539
!dir$ ignore_tkr (d) r

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

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,6 @@ end subroutine
131131
! CHECK: %{{.*}} = fir.call @__nv_double2ll_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
132132
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
133133

134-
135134
attributes(global) subroutine test_drcp_rX()
136135
double precision :: res
137136
double precision :: r
@@ -200,3 +199,32 @@ end subroutine
200199
! CHECK: %{{.*}} = fir.call @__nv_ll2float_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
201200
! CHECK: %{{.*}} = fir.call @__nv_ll2float_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
202201
! CHECK: %{{.*}} = fir.call @__nv_ll2float_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
202+
attributes(global) subroutine test_float2int_rX()
203+
integer :: res
204+
real :: r
205+
res = __float2int_rd(r)
206+
res = __float2int_rn(r)
207+
res = __float2int_ru(r)
208+
res = __float2int_rz(r)
209+
end subroutine
210+
211+
! CHECK-LABEL: _QPtest_float2int_rx
212+
! CHECK: %{{.*}} = fir.call @__nv_float2int_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
213+
! CHECK: %{{.*}} = fir.call @__nv_float2int_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
214+
! CHECK: %{{.*}} = fir.call @__nv_float2int_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
215+
! CHECK: %{{.*}} = fir.call @__nv_float2int_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
216+
217+
attributes(global) subroutine test_float2uint_rX()
218+
integer :: res
219+
real :: r
220+
res = __float2uint_rd(r)
221+
res = __float2uint_rn(r)
222+
res = __float2uint_ru(r)
223+
res = __float2uint_rz(r)
224+
end subroutine
225+
226+
! CHECK-LABEL: _QPtest_float2uint_rx
227+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
228+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
229+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
230+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32

0 commit comments

Comments
 (0)