[flang-commits] [flang] [flang][cuda] Add interfaces for __drcp_rX (PR #153681)
via flang-commits
flang-commits at lists.llvm.org
Thu Aug 14 13:58:40 PDT 2025
llvmbot wrote:
<!--LLVM PR SUMMARY COMMENT-->
@llvm/pr-subscribers-flang-fir-hlfir
Author: Valentin Clement (バレンタイン クレメン) (clementval)
<details>
<summary>Changes</summary>
---
Full diff: https://github.com/llvm/llvm-project/pull/153681.diff
2 Files Affected:
- (modified) flang/module/cudadevice.f90 (+28)
- (modified) flang/test/Lower/CUDA/cuda-libdevice.cuf (+15)
``````````diff
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index 1e403b1ffdb91..a1a337a387cea 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -779,6 +779,34 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
end function
end interface
+ interface __drcp_rd
+ attributes(device) double precision function __drcp_rd(x) bind(c, name='__nv_drcp_rd')
+ !dir$ ignore_tkr (d) x
+ double precision, value :: x
+ end function
+ end interface
+
+ interface __drcp_rn
+ attributes(device) double precision function __drcp_rn(x) bind(c, name='__nv_drcp_rn')
+ !dir$ ignore_tkr (d) x
+ double precision, value :: x
+ end function
+ end interface
+
+ interface __drcp_ru
+ attributes(device) double precision function __drcp_ru(x) bind(c, name='__nv_drcp_ru')
+ !dir$ ignore_tkr (d) x
+ double precision, value :: x
+ end function
+ end interface
+
+ interface __drcp_rz
+ attributes(device) double precision function __drcp_rz(x) bind(c, name='__nv_drcp_rz')
+ !dir$ ignore_tkr (d) x
+ double precision, value :: x
+ end function
+ end interface
+
interface __dsqrt_rd
attributes(device) double precision function __dsqrt_rd(x) bind(c, name='__nv_dsqrt_rd')
!dir$ ignore_tkr (d) x
diff --git a/flang/test/Lower/CUDA/cuda-libdevice.cuf b/flang/test/Lower/CUDA/cuda-libdevice.cuf
index 844bdb954924a..a3c80f3179cca 100644
--- a/flang/test/Lower/CUDA/cuda-libdevice.cuf
+++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf
@@ -115,3 +115,18 @@ end subroutine
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
! CHECK: %{{.*}} = fir.call @__nv_double2ll_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
! CHECK: %{{.*}} = fir.call @__nv_double2ll_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> i64
+
+attributes(global) subroutine test_drcp_rX()
+ double precision :: res
+ double precision :: r
+ res = __drcp_rd(r)
+ res = __drcp_rn(r)
+ res = __drcp_ru(r)
+ res = __drcp_rz(r)
+end subroutine
+
+! CHECK-LABEL: _QPtest_drcp_rx
+! CHECK: %{{.*}} = fir.call @__nv_drcp_rd(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
+! CHECK: %{{.*}} = fir.call @__nv_drcp_rn(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
+! CHECK: %{{.*}} = fir.call @__nv_drcp_ru(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
+! CHECK: %{{.*}} = fir.call @__nv_drcp_rz(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f64) -> f64
``````````
</details>
https://github.com/llvm/llvm-project/pull/153681
More information about the flang-commits
mailing list