[flang-commits] [flang] [flang][cuda] Add interfaces for __expf and __exp10f (PR #153633)
Valentin Clement バレンタイン クレメン via flang-commits
flang-commits at lists.llvm.org
Thu Aug 14 10:51:22 PDT 2025
https://github.com/clementval updated https://github.com/llvm/llvm-project/pull/153633
>From 2e6b8766bfdf6ade195767d8abce1557aaf5b490 Mon Sep 17 00:00:00 2001
From: Valentin Clement <clementval at gmail.com>
Date: Thu, 14 Aug 2025 10:48:37 -0700
Subject: [PATCH] [flang][cuda] Add interfaces for __expf and __exp10f
---
flang/module/cudadevice.f90 | 14 ++++++++++++++
flang/test/Lower/CUDA/cuda-libdevice.cuf | 11 +++++++++++
2 files changed, 25 insertions(+)
diff --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index 28577ee495368..d0c7411230545 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -1713,6 +1713,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 06515b1c5f6df..d367daeb12512 100644
--- a/flang/test/Lower/CUDA/cuda-libdevice.cuf
+++ b/flang/test/Lower/CUDA/cuda-libdevice.cuf
@@ -65,3 +65,14 @@ end subroutine
! CHECK-LABEL: _QPtest_tanf
! CHECK: %{{.*}} = fir.call @__nv_tanf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
+
+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
More information about the flang-commits
mailing list