Skip to content

Commit 088b8ff

Browse files
authored
[flang][cuda] Add interfaces for __usad and __sad (#153470)
1 parent dedc591 commit 088b8ff

File tree

2 files changed

+35
-0
lines changed

2 files changed

+35
-0
lines changed

flang/module/cudadevice.f90

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -324,6 +324,20 @@ attributes(device) real(8) function rsqrt(x) bind(c,name='__nv_rsqrt')
324324
real(8), value :: x
325325
end function
326326
end interface
327+
328+
interface __sad
329+
attributes(device) integer function __sad(i,j,k) bind(c, name='__nv_sad')
330+
!dir$ ignore_tkr (d) i, (d) j, (d) k
331+
integer, value :: i,j,k
332+
end function
333+
end interface
334+
335+
interface __usad
336+
attributes(device) integer function __usad(i,j,k) bind(c, name='__nv_usad')
337+
!dir$ ignore_tkr (d) i, (d) j, (d) k
338+
integer, value :: i,j,k
339+
end function
340+
end interface
327341

328342
interface signbit
329343
attributes(device) integer(4) function signbitf(x) bind(c,name='__nv_signbitf')
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s
2+
3+
! Test CUDA Fortran procedures available in cudadevice module
4+
5+
attributes(global) subroutine test_sad()
6+
integer :: res
7+
integer :: i, j, k
8+
res = __sad(i, j, k)
9+
end subroutine
10+
11+
! CHECK-LABEL: _QPtest_sad
12+
! CHECK: %{{.*}} = fir.call @__nv_sad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32, i32) -> i32
13+
14+
attributes(global) subroutine test_usad()
15+
integer :: res
16+
integer :: i, j, k
17+
res = __usad(i, j, k)
18+
end subroutine
19+
20+
! CHECK-LABEL: _QPtest_usad
21+
! CHECK: %{{.*}} = fir.call @__nv_usad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32, i32) -> i32

0 commit comments

Comments
 (0)