[flang-commits] [flang] [flang][cuda] Add interfaces for __drcp_rX (PR #153681)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Aug 14 13:58:02 PDT 2025
https://github.com/clementval created https://github.com/llvm/llvm-project/pull/153681
None
>From 005c64b303d42b310501ebfe51a6459a0bf4c2ed Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 14 Aug 2025 13:57:19 -0700
Subject: [PATCH] [flang][cuda] Add interfaces for __drcp_rX
---
flang/module/cudadevice.f90 | 28 ++++++++++++++++++++++++
flang/test/Lower/CUDA/cuda-libdevice.cuf | 15 +++++++++++++
2 files changed, 43 insertions(+)
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
More information about the flang-commits
mailing list