Skip to content

Commit 602f308

Browse files
authored
[flang][cuda] Add interface for __saturatef (#153705)
1 parent a629119 commit 602f308

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -325,6 +325,13 @@ attributes(device) real(8) function rsqrt(x) bind(c,name='__nv_rsqrt')
325325
end function
326326
end interface
327327

328+
interface saturate
329+
attributes(device) real function __saturatef(r) bind(c, name='__nv_saturatef')
330+
!dir$ ignore_tkr (d) r
331+
real, value :: r
332+
end function
333+
end interface
334+
328335
interface __sad
329336
attributes(device) integer function __sad(i,j,k) bind(c, name='__nv_sad')
330337
!dir$ ignore_tkr (d) i, (d) j, (d) k

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

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,15 @@ end subroutine
162162
! CHECK: %{{.*}} = fir.call @__nv_double2ull_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
163163
! CHECK: %{{.*}} = fir.call @__nv_double2ull_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
164164

165+
attributes(global) subroutine test_saturatef()
166+
real :: res
167+
real :: r
168+
res = __saturatef(r)
169+
end subroutine
170+
171+
! CHECK-LABEL: _QPtest_saturatef
172+
! CHECK: %{{.*}} = fir.call @__nv_saturatef(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
173+
165174
attributes(global) subroutine test_float2ll_rX()
166175
integer(8) :: res
167176
real :: r

0 commit comments

Comments
 (0)