Skip to content

Commit bd689bc

Browse files
committed
[flang][cuda] Add interfaces for __float2int_rX and __float2unit_rX
1 parent 2775c79 commit bd689bc

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
@@ -471,6 +471,62 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
471471
end function
472472
end interface
473473

474+
interface __float2int_rd
475+
attributes(device) integer function __float2int_rd(r) bind(c, name='__nv_float2int_rd')
476+
!dir$ ignore_tkr (d) r
477+
real, value :: r
478+
end function
479+
end interface
480+
481+
interface __float2int_rn
482+
attributes(device) integer function __float2int_rn(r) bind(c, name='__nv_float2int_rn')
483+
!dir$ ignore_tkr (d) r
484+
real, value :: r
485+
end function
486+
end interface
487+
488+
interface __float2int_ru
489+
attributes(device) integer function __float2int_ru(r) bind(c, name='__nv_float2int_ru')
490+
!dir$ ignore_tkr (d) r
491+
real, value :: r
492+
end function
493+
end interface
494+
495+
interface __float2int_rz
496+
attributes(device) integer function __float2int_rz(r) bind(c, name='__nv_float2int_rz')
497+
!dir$ ignore_tkr (d) r
498+
real, value :: r
499+
end function
500+
end interface
501+
502+
interface __float2uint_rd
503+
attributes(device) integer function __float2uint_rd(r) bind(c, name='__nv_float2uint_rd')
504+
!dir$ ignore_tkr (d) r
505+
real, value :: r
506+
end function
507+
end interface
508+
509+
interface __float2uint_rn
510+
attributes(device) integer function __float2uint_rn(r) bind(c, name='__nv_float2uint_rn')
511+
!dir$ ignore_tkr (d) r
512+
real, value :: r
513+
end function
514+
end interface
515+
516+
interface __float2uint_ru
517+
attributes(device) integer function __float2uint_ru(r) bind(c, name='__nv_float2uint_ru')
518+
!dir$ ignore_tkr (d) r
519+
real, value :: r
520+
end function
521+
end interface
522+
523+
interface __float2uint_rz
524+
attributes(device) integer function __float2uint_rz(r) bind(c, name='__nv_float2uint_rz')
525+
!dir$ ignore_tkr (d) r
526+
real, value :: r
527+
end function
528+
end interface
529+
474530
interface __float2ll_rd
475531
attributes(device) integer(8) function __float2ll_rd(r) bind(c, name='__nv_float2ll_rd')
476532
!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
@@ -191,3 +190,32 @@ end subroutine
191190
! CHECK: %{{.*}} = fir.call @__nv_ll2float_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
192191
! CHECK: %{{.*}} = fir.call @__nv_ll2float_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
193192
! CHECK: %{{.*}} = fir.call @__nv_ll2float_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i64) -> f32
193+
attributes(global) subroutine test_float2int_rX()
194+
integer :: res
195+
real :: r
196+
res = __float2int_rd(r)
197+
res = __float2int_rn(r)
198+
res = __float2int_ru(r)
199+
res = __float2int_rz(r)
200+
end subroutine
201+
202+
! CHECK-LABEL: _QPtest_float2int_rx
203+
! CHECK: %{{.*}} = fir.call @__nv_float2int_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
204+
! CHECK: %{{.*}} = fir.call @__nv_float2int_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
205+
! CHECK: %{{.*}} = fir.call @__nv_float2int_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
206+
! CHECK: %{{.*}} = fir.call @__nv_float2int_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
207+
208+
attributes(global) subroutine test_float2uint_rX()
209+
integer :: res
210+
real :: r
211+
res = __float2uint_rd(r)
212+
res = __float2uint_rn(r)
213+
res = __float2uint_ru(r)
214+
res = __float2uint_rz(r)
215+
end subroutine
216+
217+
! CHECK-LABEL: _QPtest_float2uint_rx
218+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
219+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
220+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32
221+
! CHECK: %{{.*}} = fir.call @__nv_float2uint_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> i32

0 commit comments

Comments
 (0)