[flang-commits] [flang] [flang][cuda] Add interfaces for __expf and __exp10f (PR #153633)
via flang-commits
flang-commits at lists.llvm.org
Thu Aug 14 10:49:41 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/153633.diff
2 Files Affected:
- (modified) flang/module/cudadevice.f90 (+14)
- (modified) flang/test/Lower/CUDA/cuda-libdevice.cuf (+11)
``````````diff
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index 4f3625a8b07af..428fac6390aef 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -1650,6 +1650,20 @@ attributes(device,host) logical function on_device() bind(c)
end function
end interface
+ interface __expf
+ attributes(device) real function __expf(r) bind(c, name='__nv_expf')
+ !dir$ ignore_tkr (d) r
+ real, value :: r
+ end function
+ end interface
+
+ interface __exp10f
+ attributes(device) real function __exp10f(r) bind(c, name='__nv_exp10f')
+ !dir$ ignore_tkr (d) r
+ real, value :: r
+ end function
+ end interface
+
contains
attributes(device) subroutine syncthreads()
diff --git a/flang/test/Lower/CUDA/cuda-libdevice.cuf b/flang/test/Lower/CUDA/cuda-libdevice.cuf
index 10e4c2757d825..1ec375192c384 100644
--- a/flang/test/Lower/CUDA/cuda-libdevice.cuf
+++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf
@@ -19,3 +19,14 @@ end subroutine
! CHECK-LABEL: _QPtest_usad
! CHECK: %{{.*}} = fir.call @__nv_usad(%{{.*}}, %{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32, i32) -> i32
+
+attributes(global) subroutine test_exp()
+ real :: res
+ real :: r
+ res = __expf(r)
+ res = __exp10f(r)
+end subroutine
+
+! CHECK-LABEL: _QPtest_exp
+! CHECK: %{{.*}} = fir.call @__nv_expf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
+! CHECK: %{{.*}} = fir.call @__nv_exp10f(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
``````````
</details>
https://github.com/llvm/llvm-project/pull/153633
More information about the flang-commits
mailing list