diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90 index cec1147ed5b21..66d54bc2b8276 100644 --- a/flang/module/cudadevice.f90 +++ b/flang/module/cudadevice.f90 @@ -324,6 +324,20 @@ attributes(device) real(8) function rsqrt(x) bind(c,name='__nv_rsqrt') real(8), value :: x end function end interface + + interface __sad + attributes(device) integer function __sad(i,j,k) bind(c, name='__nv_sad') + !dir$ ignore_tkr (d) i, (d) j, (d) k + integer, value :: i,j,k + end function + end interface + + interface __usad + attributes(device) integer function __usad(i,j,k) bind(c, name='__nv_usad') + !dir$ ignore_tkr (d) i, (d) j, (d) k + integer, value :: i,j,k + end function + end interface interface signbit attributes(device) integer(4) function signbitf(x) bind(c,name='__nv_signbitf') diff --git a/flang/test/Lower/CUDA/cuda-libdevice.cuf b/flang/test/Lower/CUDA/cuda-libdevice.cuf new file mode 100644 index 0000000000000..10e4c2757d825 --- /dev/null +++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf @@ -0,0 +1,21 @@ +! RUN: bbc -emit-hlfir -fcuda %s -o - | FileCheck %s + +! Test CUDA Fortran procedures available in cudadevice module + +attributes(global) subroutine test_sad() + integer :: res + integer :: i, j, k + res = __sad(i, j, k) +end subroutine + +! CHECK-LABEL: _QPtest_sad +! CHECK: %{{.*}} = fir.call @__nv_sad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs fastmath : (i32, i32, i32) -> i32 + +attributes(global) subroutine test_usad() + integer :: res + integer :: i, j, k + res = __usad(i, j, k) +end subroutine + +! CHECK-LABEL: _QPtest_usad +! CHECK: %{{.*}} = fir.call @__nv_usad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs fastmath : (i32, i32, i32) -> i32