[flang-commits] [flang] 088b8ff - [flang][cuda] Add interfaces for __usad and __sad (#153470)
via flang-commits
flang-commits at lists.llvm.org
Wed Aug 13 12:31:58 PDT 2025
Author: Valentin Clement (バレンタイン クレメン)
Date: 2025-08-13T12:31:55-07:00
New Revision: 088b8ffca10700475e98ccebeb54622967e28397
URL: https://github.com/llvm/llvm-project/commit/088b8ffca10700475e98ccebeb54622967e28397
DIFF: https://github.com/llvm/llvm-project/commit/088b8ffca10700475e98ccebeb54622967e28397.diff
LOG: [flang][cuda] Add interfaces for __usad and __sad (#153470)
Added:
flang/test/Lower/CUDA/cuda-libdevice.cuf
Modified:
flang/module/cudadevice.f90
Removed:
################################################################################
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index 1df9fe7c5727b..6cc18f4cbc18c 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<bind_c> fastmath<contract> : (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<bind_c> fastmath<contract> : (i32, i32, i32) -> i32
More information about the flang-commits
mailing list