[flang-commits] [flang] 60170f9 - [flang][cuda] Add missing interface for __powf (#153294)

via flang-commits flang-commits at lists.llvm.org
Tue Aug 12 23:08:45 PDT 2025


Author: Valentin Clement (バレンタイン クレメン)
Date: 2025-08-12T23:08:41-07:00
New Revision: 60170f92a3fee8532e92913dfe01430c368a8ba6

URL: https://github.com/llvm/llvm-project/commit/60170f92a3fee8532e92913dfe01430c368a8ba6
DIFF: https://github.com/llvm/llvm-project/commit/60170f92a3fee8532e92913dfe01430c368a8ba6.diff

LOG: [flang][cuda] Add missing interface for __powf (#153294)

`__powf` is defined in the CUDA Fortran programming guide but it's
missing from our cudadevice module. Add the interface and bind name to
`__nv_powf`


https://docs.nvidia.com/hpc-sdk/compilers/cuda-fortran-prog-guide/index.html#fortran-device-modules


https://docs.nvidia.com/cuda/libdevice-users-guide/__nv_powf.html#__nv_powf

Added: 
    

Modified: 
    flang/module/cudadevice.f90
    flang/test/Lower/CUDA/cuda-device-proc.cuf

Removed: 
    


################################################################################
diff  --git a/flang/module/cudadevice.f90 b/flang/module/cudadevice.f90
index a2bec3f633c5a..f7b7d856ecb90 100644
--- a/flang/module/cudadevice.f90
+++ b/flang/module/cudadevice.f90
@@ -770,6 +770,13 @@ attributes(device) real(8) function sinpi(x) bind(c,name='__nv_sinpi')
     end function
   end interface
 
+  interface
+    attributes(device) real(4) function __powf(x,y) bind(c, name='__nv_powf')
+      !dir$ ignore_tkr (d) x, y
+      real(4), value :: x, y
+    end function
+  end interface
+
   interface __brev
     attributes(device) integer function __brev(i) bind(c, name='__nv_brev')
       !dir$ ignore_tkr (d) i

diff  --git a/flang/test/Lower/CUDA/cuda-device-proc.cuf b/flang/test/Lower/CUDA/cuda-device-proc.cuf
index 2fea9a0ccbc96..6c56f8616c404 100644
--- a/flang/test/Lower/CUDA/cuda-device-proc.cuf
+++ b/flang/test/Lower/CUDA/cuda-device-proc.cuf
@@ -63,6 +63,7 @@ attributes(global) subroutine devsub()
   af = __cosf(af)
   ai = __mul24(ai, ai)
   ai = __umul24(ai, ai)
+  af = __powf(af, af)
 end
 
 ! CHECK-LABEL: func.func @_QPdevsub() attributes {cuf.proc_attr = #cuf.cuda_proc<global>}
@@ -114,6 +115,7 @@ end
 ! CHECK: %{{.*}} = fir.call @__nv_cosf(%{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32) -> f32
 ! CHECK: %{{.*}} = fir.call @__nv_mul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
 ! CHECK: %{{.*}} = fir.call @__nv_umul24(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (i32, i32) -> i32
+! CHECK: %{{.*}} = fir.call @__nv_powf(%{{.*}}, %{{.*}}) proc_attrs<bind_c> fastmath<contract> : (f32, f32) -> f32
 
 subroutine host1()
   integer, device :: a(32)


        


More information about the flang-commits mailing list